Skip to content

Commit 25e8127

Browse files
authored
Clarify provenance and reborrowing
1 parent 48261cd commit 25e8127

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

library/core/src/mem/maybe_uninit.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,12 @@ use crate::{fmt, intrinsics, ptr, slice};
284284
/// and back will always produce the original value `t` again. This is true even if `t` contains [provenance]:
285285
/// the resulting value will have the same provenance as the original `t`.
286286
///
287+
/// Note a potential footgun: if `t` contains a reference, then there may be implicit reborrows of the
288+
/// reference any time it is copied, which may alter its provenance. In that case, while the value returned
289+
/// by `identity` is exactly the same as its argument, that value may immediately be reborrowed upon return,
290+
/// altering its provenance. This may make this call to `identity` behave as though it does *not* exactly
291+
/// preserve provenance.
292+
///
287293
/// [provenance]: crate::ptr#provenance
288294
///
289295
/// [reference-byte]: ../../reference/memory-model.html#bytes

0 commit comments

Comments
 (0)