Skip to content

Commit 6bf4c57

Browse files
author
Lukas Markeffsky
committed
update comment
1 parent bc0788b commit 6bf4c57

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

library/core/src/ptr/mod.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -1013,10 +1013,9 @@ const unsafe fn swap_nonoverlapping_simple<T>(x: *mut T, y: *mut T, count: usize
10131013
#[stable(feature = "rust1", since = "1.0.0")]
10141014
#[rustc_const_unstable(feature = "const_replace", issue = "83164")]
10151015
pub const unsafe fn replace<T>(dst: *mut T, src: T) -> T {
1016-
// SAFETY: the caller must guarantee that `dst` is valid to be
1017-
// cast to a mutable reference (valid for writes, aligned, initialized),
1018-
// and cannot overlap `src` since `dst` must point to a distinct
1019-
// allocated object.
1016+
// SAFETY: The caller must guarantee that `dst` is valid to be
1017+
// cast to a mutable reference (valid for writes, aligned, initialized).
1018+
// `dst` cannot overlap `src` since `src` is a freshly stack-allocated local variable.
10201019
unsafe {
10211020
assert_unsafe_precondition!(is_aligned_and_not_null(dst));
10221021
mem::replace(&mut *dst, src)

0 commit comments

Comments
 (0)