Skip to content

Commit 325acef

Browse files
committed
Use intra-doc links in core::ptr
The only link that I did not change is a link to a function on the `pointer` primitive because intra-doc links for the `pointer` primitive don't work yet (see rust-lang#63351).
1 parent 5099914 commit 325acef

File tree

1 file changed

+21
-56
lines changed

1 file changed

+21
-56
lines changed

library/core/src/ptr/mod.rs

Lines changed: 21 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,9 @@
5454
//! [aliasing]: ../../nomicon/aliasing.html
5555
//! [book]: ../../book/ch19-01-unsafe-rust.html#dereferencing-a-raw-pointer
5656
//! [ub]: ../../reference/behavior-considered-undefined.html
57-
//! [null]: ./fn.null.html
5857
//! [zst]: ../../nomicon/exotic-sizes.html#zero-sized-types-zsts
59-
//! [atomic operations]: ../../std/sync/atomic/index.html
60-
//! [`copy`]: ../../std/ptr/fn.copy.html
58+
//! [atomic operations]: crate::sync::atomic
6159
//! [`offset`]: ../../std/primitive.pointer.html#method.offset
62-
//! [`read_unaligned`]: ./fn.read_unaligned.html
63-
//! [`write_unaligned`]: ./fn.write_unaligned.html
64-
//! [`read_volatile`]: ./fn.read_volatile.html
65-
//! [`write_volatile`]: ./fn.write_volatile.html
66-
//! [`NonNull::dangling`]: ./struct.NonNull.html#method.dangling
6760
6861
#![stable(feature = "rust1", since = "1.0.0")]
6962

@@ -118,9 +111,9 @@ mod mut_ptr;
118111
/// done automatically by the compiler. This means the fields of packed structs
119112
/// are not dropped in-place.
120113
///
121-
/// [`ptr::read`]: ../ptr/fn.read.html
122-
/// [`ptr::read_unaligned`]: ../ptr/fn.read_unaligned.html
123-
/// [pinned]: ../pin/index.html
114+
/// [`ptr::read`]: self::read
115+
/// [`ptr::read_unaligned`]: self::read_unaligned
116+
/// [pinned]: crate::pin
124117
///
125118
/// # Safety
126119
///
@@ -141,9 +134,7 @@ mod mut_ptr;
141134
///
142135
/// Note that even if `T` has size `0`, the pointer must be non-NULL and properly aligned.
143136
///
144-
/// [valid]: ../ptr/index.html#safety
145-
/// [`Copy`]: ../marker/trait.Copy.html
146-
/// [`write`]: ../ptr/fn.write.html
137+
/// [valid]: #safety
147138
///
148139
/// # Examples
149140
///
@@ -243,9 +234,9 @@ pub(crate) struct FatPtr<T> {
243234
/// The `len` argument is the number of **elements**, not the number of bytes.
244235
///
245236
/// This function is safe, but actually using the return value is unsafe.
246-
/// See the documentation of [`from_raw_parts`] for slice safety requirements.
237+
/// See the documentation of [`slice::from_raw_parts`] for slice safety requirements.
247238
///
248-
/// [`from_raw_parts`]: ../../std/slice/fn.from_raw_parts.html
239+
/// [`slice::from_raw_parts`]: crate::slice::from_raw_parts
249240
///
250241
/// # Examples
251242
///
@@ -274,10 +265,9 @@ pub const fn slice_from_raw_parts<T>(data: *const T, len: usize) -> *const [T] {
274265
/// See the documentation of [`slice_from_raw_parts`] for more details.
275266
///
276267
/// This function is safe, but actually using the return value is unsafe.
277-
/// See the documentation of [`from_raw_parts_mut`] for slice safety requirements.
268+
/// See the documentation of [`slice::from_raw_parts_mut`] for slice safety requirements.
278269
///
279-
/// [`slice_from_raw_parts`]: fn.slice_from_raw_parts.html
280-
/// [`from_raw_parts_mut`]: ../../std/slice/fn.from_raw_parts_mut.html
270+
/// [`slice::from_raw_parts_mut`]: crate::slice::from_raw_parts_mut
281271
///
282272
/// # Examples
283273
///
@@ -316,8 +306,6 @@ pub const fn slice_from_raw_parts_mut<T>(data: *mut T, len: usize) -> *mut [T] {
316306
/// overlapping region of memory from `x` will be used. This is demonstrated
317307
/// in the second example below.
318308
///
319-
/// [`mem::swap`]: ../mem/fn.swap.html
320-
///
321309
/// # Safety
322310
///
323311
/// Behavior is undefined if any of the following conditions are violated:
@@ -328,7 +316,7 @@ pub const fn slice_from_raw_parts_mut<T>(data: *mut T, len: usize) -> *mut [T] {
328316
///
329317
/// Note that even if `T` has size `0`, the pointers must be non-NULL and properly aligned.
330318
///
331-
/// [valid]: ../ptr/index.html#safety
319+
/// [valid]: #safety
332320
///
333321
/// # Examples
334322
///
@@ -406,7 +394,7 @@ pub unsafe fn swap<T>(x: *mut T, y: *mut T) {
406394
/// Note that even if the effectively copied size (`count * size_of::<T>()`) is `0`,
407395
/// the pointers must be non-NULL and properly aligned.
408396
///
409-
/// [valid]: ../ptr/index.html#safety
397+
/// [valid]: #safety
410398
///
411399
/// # Examples
412400
///
@@ -533,8 +521,6 @@ unsafe fn swap_nonoverlapping_bytes(x: *mut u8, y: *mut u8, len: usize) {
533521
/// operates on raw pointers instead of references. When references are
534522
/// available, [`mem::replace`] should be preferred.
535523
///
536-
/// [`mem::replace`]: ../mem/fn.replace.html
537-
///
538524
/// # Safety
539525
///
540526
/// Behavior is undefined if any of the following conditions are violated:
@@ -547,7 +533,7 @@ unsafe fn swap_nonoverlapping_bytes(x: *mut u8, y: *mut u8, len: usize) {
547533
///
548534
/// Note that even if `T` has size `0`, the pointer must be non-NULL and properly aligned.
549535
///
550-
/// [valid]: ../ptr/index.html#safety
536+
/// [valid]: #safety
551537
///
552538
/// # Examples
553539
///
@@ -682,11 +668,7 @@ pub unsafe fn replace<T>(dst: *mut T, mut src: T) -> T {
682668
/// assert_eq!(s, "bar");
683669
/// ```
684670
///
685-
/// [`mem::swap`]: ../mem/fn.swap.html
686-
/// [valid]: ../ptr/index.html#safety
687-
/// [`Copy`]: ../marker/trait.Copy.html
688-
/// [`read_unaligned`]: ./fn.read_unaligned.html
689-
/// [`write`]: ./fn.write.html
671+
/// [valid]: #safety
690672
#[inline]
691673
#[stable(feature = "rust1", since = "1.0.0")]
692674
pub unsafe fn read<T>(src: *const T) -> T {
@@ -723,11 +705,8 @@ pub unsafe fn read<T>(src: *const T) -> T {
723705
///
724706
/// Note that even if `T` has size `0`, the pointer must be non-NULL.
725707
///
726-
/// [`Copy`]: ../marker/trait.Copy.html
727-
/// [`read`]: ./fn.read.html
728-
/// [`write_unaligned`]: ./fn.write_unaligned.html
729-
/// [read-ownership]: ./fn.read.html#ownership-of-the-returned-value
730-
/// [valid]: ../ptr/index.html#safety
708+
/// [read-ownership]: read#ownership-of-the-returned-value
709+
/// [valid]: #safety
731710
///
732711
/// ## On `packed` structs
733712
///
@@ -819,8 +798,6 @@ pub unsafe fn read_unaligned<T>(src: *const T) -> T {
819798
/// This is appropriate for initializing uninitialized memory, or overwriting
820799
/// memory that has previously been [`read`] from.
821800
///
822-
/// [`read`]: ./fn.read.html
823-
///
824801
/// # Safety
825802
///
826803
/// Behavior is undefined if any of the following conditions are violated:
@@ -832,8 +809,7 @@ pub unsafe fn read_unaligned<T>(src: *const T) -> T {
832809
///
833810
/// Note that even if `T` has size `0`, the pointer must be non-NULL and properly aligned.
834811
///
835-
/// [valid]: ../ptr/index.html#safety
836-
/// [`write_unaligned`]: ./fn.write_unaligned.html
812+
/// [valid]: #safety
837813
///
838814
/// # Examples
839815
///
@@ -888,8 +864,6 @@ pub unsafe fn read_unaligned<T>(src: *const T) -> T {
888864
/// assert_eq!(foo, "bar");
889865
/// assert_eq!(bar, "foo");
890866
/// ```
891-
///
892-
/// [`mem::swap`]: ../mem/fn.swap.html
893867
#[inline]
894868
#[stable(feature = "rust1", since = "1.0.0")]
895869
pub unsafe fn write<T>(dst: *mut T, src: T) {
@@ -916,9 +890,6 @@ pub unsafe fn write<T>(dst: *mut T, src: T) {
916890
/// This is appropriate for initializing uninitialized memory, or overwriting
917891
/// memory that has previously been read with [`read_unaligned`].
918892
///
919-
/// [`write`]: ./fn.write.html
920-
/// [`read_unaligned`]: ./fn.read_unaligned.html
921-
///
922893
/// # Safety
923894
///
924895
/// Behavior is undefined if any of the following conditions are violated:
@@ -927,7 +898,7 @@ pub unsafe fn write<T>(dst: *mut T, src: T) {
927898
///
928899
/// Note that even if `T` has size `0`, the pointer must be non-NULL.
929900
///
930-
/// [valid]: ../ptr/index.html#safety
901+
/// [valid]: #safety
931902
///
932903
/// ## On `packed` structs
933904
///
@@ -1007,8 +978,6 @@ pub unsafe fn write_unaligned<T>(dst: *mut T, src: T) {
1007978
/// to not be elided or reordered by the compiler across other volatile
1008979
/// operations.
1009980
///
1010-
/// [`write_volatile`]: ./fn.write_volatile.html
1011-
///
1012981
/// # Notes
1013982
///
1014983
/// Rust does not currently have a rigorously and formally defined memory model,
@@ -1041,10 +1010,8 @@ pub unsafe fn write_unaligned<T>(dst: *mut T, src: T) {
10411010
///
10421011
/// Note that even if `T` has size `0`, the pointer must be non-NULL and properly aligned.
10431012
///
1044-
/// [valid]: ../ptr/index.html#safety
1045-
/// [`Copy`]: ../marker/trait.Copy.html
1046-
/// [`read`]: ./fn.read.html
1047-
/// [read-ownership]: ./fn.read.html#ownership-of-the-returned-value
1013+
/// [valid]: #safety
1014+
/// [read-ownership]: read#ownership-of-the-returned-value
10481015
///
10491016
/// Just like in C, whether an operation is volatile has no bearing whatsoever
10501017
/// on questions involving concurrent access from multiple threads. Volatile
@@ -1089,8 +1056,6 @@ pub unsafe fn read_volatile<T>(src: *const T) -> T {
10891056
/// Additionally, it does not drop `src`. Semantically, `src` is moved into the
10901057
/// location pointed to by `dst`.
10911058
///
1092-
/// [`read_volatile`]: ./fn.read_volatile.html
1093-
///
10941059
/// # Notes
10951060
///
10961061
/// Rust does not currently have a rigorously and formally defined memory model,
@@ -1115,12 +1080,12 @@ pub unsafe fn read_volatile<T>(src: *const T) -> T {
11151080
///
11161081
/// Note that even if `T` has size `0`, the pointer must be non-NULL and properly aligned.
11171082
///
1118-
/// [valid]: ../ptr/index.html#safety
1083+
/// [valid]: #safety
11191084
///
11201085
/// Just like in C, whether an operation is volatile has no bearing whatsoever
11211086
/// on questions involving concurrent access from multiple threads. Volatile
11221087
/// accesses behave exactly like non-atomic accesses in that regard. In particular,
1123-
/// a race between a `write_volatile` and any other operation (reading or writing)
1088+
/// a race between a [`write_volatile`] and any other operation (reading or writing)
11241089
/// on the same location is undefined behavior.
11251090
///
11261091
/// # Examples

0 commit comments

Comments
 (0)