Skip to content

Commit a6ad139

Browse files
authored
Rollup merge of rust-lang#96136 - thomcc:lifetime-wording, r=RalfJung
Reword clarification on lifetime for ptr->ref safety docs I believe the current wording of the safety comment is somewhat misleading, and that this is more accurate. Suggested by `@CAD97` in this thread on the topic https://rust-lang.zulipchat.com/#narrow/stream/136281-t-lang.2Fwg-unsafe-code-guidelines/topic/Lifetime.20of.20reference.20pointer.20docs.20issue Just to check that this is correct, CC `@RalfJung.` I suppose it's open for interpretation as to whether or not this is more clear. I think it is.
2 parents 718b184 + be30e40 commit a6ad139

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

library/core/src/ptr/const_ptr.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ impl<T: ?Sized> *const T {
295295
///
296296
/// * You must enforce Rust's aliasing rules, since the returned lifetime `'a` is
297297
/// arbitrarily chosen and does not necessarily reflect the actual lifetime of the data.
298-
/// In particular, for the duration of this lifetime, the memory the pointer points to must
298+
/// In particular, while this reference exists, the memory the pointer points to must
299299
/// not get mutated (except inside `UnsafeCell`).
300300
///
301301
/// This applies even if the result of this method is unused!
@@ -358,7 +358,7 @@ impl<T: ?Sized> *const T {
358358
///
359359
/// * You must enforce Rust's aliasing rules, since the returned lifetime `'a` is
360360
/// arbitrarily chosen and does not necessarily reflect the actual lifetime of the data.
361-
/// In particular, for the duration of this lifetime, the memory the pointer points to must
361+
/// In particular, while this reference exists, the memory the pointer points to must
362362
/// not get mutated (except inside `UnsafeCell`).
363363
///
364364
/// This applies even if the result of this method is unused!
@@ -1188,7 +1188,7 @@ impl<T> *const [T] {
11881188
///
11891189
/// * You must enforce Rust's aliasing rules, since the returned lifetime `'a` is
11901190
/// arbitrarily chosen and does not necessarily reflect the actual lifetime of the data.
1191-
/// In particular, for the duration of this lifetime, the memory the pointer points to must
1191+
/// In particular, while this reference exists, the memory the pointer points to must
11921192
/// not get mutated (except inside `UnsafeCell`).
11931193
///
11941194
/// This applies even if the result of this method is unused!

library/core/src/ptr/mut_ptr.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ impl<T: ?Sized> *mut T {
302302
///
303303
/// * You must enforce Rust's aliasing rules, since the returned lifetime `'a` is
304304
/// arbitrarily chosen and does not necessarily reflect the actual lifetime of the data.
305-
/// In particular, for the duration of this lifetime, the memory the pointer points to must
305+
/// In particular, while this reference exists, the memory the pointer points to must
306306
/// not get mutated (except inside `UnsafeCell`).
307307
///
308308
/// This applies even if the result of this method is unused!
@@ -368,7 +368,7 @@ impl<T: ?Sized> *mut T {
368368
///
369369
/// * You must enforce Rust's aliasing rules, since the returned lifetime `'a` is
370370
/// arbitrarily chosen and does not necessarily reflect the actual lifetime of the data.
371-
/// In particular, for the duration of this lifetime, the memory the pointer points to must
371+
/// In particular, while this reference exists, the memory the pointer points to must
372372
/// not get mutated (except inside `UnsafeCell`).
373373
///
374374
/// This applies even if the result of this method is unused!
@@ -550,7 +550,7 @@ impl<T: ?Sized> *mut T {
550550
///
551551
/// * You must enforce Rust's aliasing rules, since the returned lifetime `'a` is
552552
/// arbitrarily chosen and does not necessarily reflect the actual lifetime of the data.
553-
/// In particular, for the duration of this lifetime, the memory the pointer points to must
553+
/// In particular, while this reference exists, the memory the pointer points to must
554554
/// not get accessed (read or written) through any other pointer.
555555
///
556556
/// This applies even if the result of this method is unused!
@@ -615,7 +615,7 @@ impl<T: ?Sized> *mut T {
615615
///
616616
/// * You must enforce Rust's aliasing rules, since the returned lifetime `'a` is
617617
/// arbitrarily chosen and does not necessarily reflect the actual lifetime of the data.
618-
/// In particular, for the duration of this lifetime, the memory the pointer points to must
618+
/// In particular, while this reference exists, the memory the pointer points to must
619619
/// not get accessed (read or written) through any other pointer.
620620
///
621621
/// This applies even if the result of this method is unused!
@@ -1461,7 +1461,7 @@ impl<T> *mut [T] {
14611461
///
14621462
/// * You must enforce Rust's aliasing rules, since the returned lifetime `'a` is
14631463
/// arbitrarily chosen and does not necessarily reflect the actual lifetime of the data.
1464-
/// In particular, for the duration of this lifetime, the memory the pointer points to must
1464+
/// In particular, while this reference exists, the memory the pointer points to must
14651465
/// not get mutated (except inside `UnsafeCell`).
14661466
///
14671467
/// This applies even if the result of this method is unused!
@@ -1513,7 +1513,7 @@ impl<T> *mut [T] {
15131513
///
15141514
/// * You must enforce Rust's aliasing rules, since the returned lifetime `'a` is
15151515
/// arbitrarily chosen and does not necessarily reflect the actual lifetime of the data.
1516-
/// In particular, for the duration of this lifetime, the memory the pointer points to must
1516+
/// In particular, while this reference exists, the memory the pointer points to must
15171517
/// not get accessed (read or written) through any other pointer.
15181518
///
15191519
/// This applies even if the result of this method is unused!

library/core/src/ptr/non_null.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ impl<T: Sized> NonNull<T> {
114114
///
115115
/// * You must enforce Rust's aliasing rules, since the returned lifetime `'a` is
116116
/// arbitrarily chosen and does not necessarily reflect the actual lifetime of the data.
117-
/// In particular, for the duration of this lifetime, the memory the pointer points to must
117+
/// In particular, while this reference exists, the memory the pointer points to must
118118
/// not get mutated (except inside `UnsafeCell`).
119119
///
120120
/// This applies even if the result of this method is unused!
@@ -148,7 +148,7 @@ impl<T: Sized> NonNull<T> {
148148
///
149149
/// * You must enforce Rust's aliasing rules, since the returned lifetime `'a` is
150150
/// arbitrarily chosen and does not necessarily reflect the actual lifetime of the data.
151-
/// In particular, for the duration of this lifetime, the memory the pointer points to must
151+
/// In particular, while this reference exists, the memory the pointer points to must
152152
/// not get accessed (read or written) through any other pointer.
153153
///
154154
/// This applies even if the result of this method is unused!
@@ -350,7 +350,7 @@ impl<T: ?Sized> NonNull<T> {
350350
///
351351
/// * You must enforce Rust's aliasing rules, since the returned lifetime `'a` is
352352
/// arbitrarily chosen and does not necessarily reflect the actual lifetime of the data.
353-
/// In particular, for the duration of this lifetime, the memory the pointer points to must
353+
/// In particular, while this reference exists, the memory the pointer points to must
354354
/// not get mutated (except inside `UnsafeCell`).
355355
///
356356
/// This applies even if the result of this method is unused!
@@ -400,7 +400,7 @@ impl<T: ?Sized> NonNull<T> {
400400
///
401401
/// * You must enforce Rust's aliasing rules, since the returned lifetime `'a` is
402402
/// arbitrarily chosen and does not necessarily reflect the actual lifetime of the data.
403-
/// In particular, for the duration of this lifetime, the memory the pointer points to must
403+
/// In particular, while this reference exists, the memory the pointer points to must
404404
/// not get accessed (read or written) through any other pointer.
405405
///
406406
/// This applies even if the result of this method is unused!
@@ -580,7 +580,7 @@ impl<T> NonNull<[T]> {
580580
///
581581
/// * You must enforce Rust's aliasing rules, since the returned lifetime `'a` is
582582
/// arbitrarily chosen and does not necessarily reflect the actual lifetime of the data.
583-
/// In particular, for the duration of this lifetime, the memory the pointer points to must
583+
/// In particular, while this reference exists, the memory the pointer points to must
584584
/// not get mutated (except inside `UnsafeCell`).
585585
///
586586
/// This applies even if the result of this method is unused!
@@ -626,7 +626,7 @@ impl<T> NonNull<[T]> {
626626
///
627627
/// * You must enforce Rust's aliasing rules, since the returned lifetime `'a` is
628628
/// arbitrarily chosen and does not necessarily reflect the actual lifetime of the data.
629-
/// In particular, for the duration of this lifetime, the memory the pointer points to must
629+
/// In particular, while this reference exists, the memory the pointer points to must
630630
/// not get accessed (read or written) through any other pointer.
631631
///
632632
/// This applies even if the result of this method is unused!

0 commit comments

Comments
 (0)