54
54
//! [aliasing]: ../../nomicon/aliasing.html
55
55
//! [book]: ../../book/ch19-01-unsafe-rust.html#dereferencing-a-raw-pointer
56
56
//! [ub]: ../../reference/behavior-considered-undefined.html
57
- //! [null]: ./fn.null.html
58
57
//! [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
61
59
//! [`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
67
60
68
61
#![ stable( feature = "rust1" , since = "1.0.0" ) ]
69
62
@@ -118,9 +111,9 @@ mod mut_ptr;
118
111
/// done automatically by the compiler. This means the fields of packed structs
119
112
/// are not dropped in-place.
120
113
///
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
124
117
///
125
118
/// # Safety
126
119
///
@@ -136,14 +129,12 @@ mod mut_ptr;
136
129
/// Additionally, if `T` is not [`Copy`], using the pointed-to value after
137
130
/// calling `drop_in_place` can cause undefined behavior. Note that `*to_drop =
138
131
/// foo` counts as a use because it will cause the value to be dropped
139
- /// again. [`write`] can be used to overwrite data without causing it to be
132
+ /// again. [`write() `] can be used to overwrite data without causing it to be
140
133
/// dropped.
141
134
///
142
135
/// Note that even if `T` has size `0`, the pointer must be non-NULL and properly aligned.
143
136
///
144
- /// [valid]: ../ptr/index.html#safety
145
- /// [`Copy`]: ../marker/trait.Copy.html
146
- /// [`write`]: ../ptr/fn.write.html
137
+ /// [valid]: self#safety
147
138
///
148
139
/// # Examples
149
140
///
@@ -243,9 +234,9 @@ pub(crate) struct FatPtr<T> {
243
234
/// The `len` argument is the number of **elements**, not the number of bytes.
244
235
///
245
236
/// 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.
247
238
///
248
- /// [`from_raw_parts`]: ../../std/ slice/fn. from_raw_parts.html
239
+ /// [`slice:: from_raw_parts`]: crate:: slice:: from_raw_parts
249
240
///
250
241
/// # Examples
251
242
///
@@ -274,10 +265,9 @@ pub const fn slice_from_raw_parts<T>(data: *const T, len: usize) -> *const [T] {
274
265
/// See the documentation of [`slice_from_raw_parts`] for more details.
275
266
///
276
267
/// 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.
278
269
///
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
281
271
///
282
272
/// # Examples
283
273
///
@@ -316,8 +306,6 @@ pub const fn slice_from_raw_parts_mut<T>(data: *mut T, len: usize) -> *mut [T] {
316
306
/// overlapping region of memory from `x` will be used. This is demonstrated
317
307
/// in the second example below.
318
308
///
319
- /// [`mem::swap`]: ../mem/fn.swap.html
320
- ///
321
309
/// # Safety
322
310
///
323
311
/// 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] {
328
316
///
329
317
/// Note that even if `T` has size `0`, the pointers must be non-NULL and properly aligned.
330
318
///
331
- /// [valid]: ../ptr/index.html #safety
319
+ /// [valid]: self #safety
332
320
///
333
321
/// # Examples
334
322
///
@@ -406,7 +394,7 @@ pub unsafe fn swap<T>(x: *mut T, y: *mut T) {
406
394
/// Note that even if the effectively copied size (`count * size_of::<T>()`) is `0`,
407
395
/// the pointers must be non-NULL and properly aligned.
408
396
///
409
- /// [valid]: ../ptr/index.html #safety
397
+ /// [valid]: self #safety
410
398
///
411
399
/// # Examples
412
400
///
@@ -533,8 +521,6 @@ unsafe fn swap_nonoverlapping_bytes(x: *mut u8, y: *mut u8, len: usize) {
533
521
/// operates on raw pointers instead of references. When references are
534
522
/// available, [`mem::replace`] should be preferred.
535
523
///
536
- /// [`mem::replace`]: ../mem/fn.replace.html
537
- ///
538
524
/// # Safety
539
525
///
540
526
/// 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) {
547
533
///
548
534
/// Note that even if `T` has size `0`, the pointer must be non-NULL and properly aligned.
549
535
///
550
- /// [valid]: ../ptr/index.html #safety
536
+ /// [valid]: self #safety
551
537
///
552
538
/// # Examples
553
539
///
@@ -653,7 +639,7 @@ pub unsafe fn replace<T>(dst: *mut T, mut src: T) -> T {
653
639
/// `*src` can violate memory safety. Note that assigning to `*src` counts as a
654
640
/// use because it will attempt to drop the value at `*src`.
655
641
///
656
- /// [`write`] can be used to overwrite data without causing it to be dropped.
642
+ /// [`write() `] can be used to overwrite data without causing it to be dropped.
657
643
///
658
644
/// ```
659
645
/// use std::ptr;
@@ -682,11 +668,7 @@ pub unsafe fn replace<T>(dst: *mut T, mut src: T) -> T {
682
668
/// assert_eq!(s, "bar");
683
669
/// ```
684
670
///
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]: self#safety
690
672
#[ inline]
691
673
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
692
674
pub unsafe fn read < T > ( src : * const T ) -> T {
@@ -723,11 +705,8 @@ pub unsafe fn read<T>(src: *const T) -> T {
723
705
///
724
706
/// Note that even if `T` has size `0`, the pointer must be non-NULL.
725
707
///
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]: self#safety
731
710
///
732
711
/// ## On `packed` structs
733
712
///
@@ -819,8 +798,6 @@ pub unsafe fn read_unaligned<T>(src: *const T) -> T {
819
798
/// This is appropriate for initializing uninitialized memory, or overwriting
820
799
/// memory that has previously been [`read`] from.
821
800
///
822
- /// [`read`]: ./fn.read.html
823
- ///
824
801
/// # Safety
825
802
///
826
803
/// 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 {
832
809
///
833
810
/// Note that even if `T` has size `0`, the pointer must be non-NULL and properly aligned.
834
811
///
835
- /// [valid]: ../ptr/index.html#safety
836
- /// [`write_unaligned`]: ./fn.write_unaligned.html
812
+ /// [valid]: self#safety
837
813
///
838
814
/// # Examples
839
815
///
@@ -888,8 +864,6 @@ pub unsafe fn read_unaligned<T>(src: *const T) -> T {
888
864
/// assert_eq!(foo, "bar");
889
865
/// assert_eq!(bar, "foo");
890
866
/// ```
891
- ///
892
- /// [`mem::swap`]: ../mem/fn.swap.html
893
867
#[ inline]
894
868
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
895
869
pub unsafe fn write < T > ( dst : * mut T , src : T ) {
@@ -904,7 +878,7 @@ pub unsafe fn write<T>(dst: *mut T, src: T) {
904
878
/// Overwrites a memory location with the given value without reading or
905
879
/// dropping the old value.
906
880
///
907
- /// Unlike [`write`], the pointer may be unaligned.
881
+ /// Unlike [`write() `], the pointer may be unaligned.
908
882
///
909
883
/// `write_unaligned` does not drop the contents of `dst`. This is safe, but it
910
884
/// could leak allocations or resources, so care should be taken not to overwrite
@@ -916,9 +890,6 @@ pub unsafe fn write<T>(dst: *mut T, src: T) {
916
890
/// This is appropriate for initializing uninitialized memory, or overwriting
917
891
/// memory that has previously been read with [`read_unaligned`].
918
892
///
919
- /// [`write`]: ./fn.write.html
920
- /// [`read_unaligned`]: ./fn.read_unaligned.html
921
- ///
922
893
/// # Safety
923
894
///
924
895
/// 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) {
927
898
///
928
899
/// Note that even if `T` has size `0`, the pointer must be non-NULL.
929
900
///
930
- /// [valid]: ../ptr/index.html #safety
901
+ /// [valid]: self #safety
931
902
///
932
903
/// ## On `packed` structs
933
904
///
@@ -1007,8 +978,6 @@ pub unsafe fn write_unaligned<T>(dst: *mut T, src: T) {
1007
978
/// to not be elided or reordered by the compiler across other volatile
1008
979
/// operations.
1009
980
///
1010
- /// [`write_volatile`]: ./fn.write_volatile.html
1011
- ///
1012
981
/// # Notes
1013
982
///
1014
983
/// 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) {
1041
1010
///
1042
1011
/// Note that even if `T` has size `0`, the pointer must be non-NULL and properly aligned.
1043
1012
///
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]: self#safety
1014
+ /// [read-ownership]: read#ownership-of-the-returned-value
1048
1015
///
1049
1016
/// Just like in C, whether an operation is volatile has no bearing whatsoever
1050
1017
/// on questions involving concurrent access from multiple threads. Volatile
@@ -1089,8 +1056,6 @@ pub unsafe fn read_volatile<T>(src: *const T) -> T {
1089
1056
/// Additionally, it does not drop `src`. Semantically, `src` is moved into the
1090
1057
/// location pointed to by `dst`.
1091
1058
///
1092
- /// [`read_volatile`]: ./fn.read_volatile.html
1093
- ///
1094
1059
/// # Notes
1095
1060
///
1096
1061
/// Rust does not currently have a rigorously and formally defined memory model,
@@ -1115,7 +1080,7 @@ pub unsafe fn read_volatile<T>(src: *const T) -> T {
1115
1080
///
1116
1081
/// Note that even if `T` has size `0`, the pointer must be non-NULL and properly aligned.
1117
1082
///
1118
- /// [valid]: ../ptr/index.html #safety
1083
+ /// [valid]: self #safety
1119
1084
///
1120
1085
/// Just like in C, whether an operation is volatile has no bearing whatsoever
1121
1086
/// on questions involving concurrent access from multiple threads. Volatile
0 commit comments