diff options
| author | Mads Marquart <mads@marquart.dk> | 2024-12-30 00:26:47 +0100 |
|---|---|---|
| committer | Mads Marquart <mads@marquart.dk> | 2024-12-30 00:26:47 +0100 |
| commit | 5966ba0424e75accc4be35c2e334791a98c23aaf (patch) | |
| tree | bd547f2114491bcdd6c601b3aa165733a57c9d7d | |
| parent | 14ee63a3c651bb7a243c8b07333749ab4b152e13 (diff) | |
| download | rust-5966ba0424e75accc4be35c2e334791a98c23aaf.tar.gz rust-5966ba0424e75accc4be35c2e334791a98c23aaf.zip | |
Fix ptr::from_ref documentation example comment
The comment says that the expression involves no function call, but that was only true for the example above, the example here _does_ contain a function call.
| -rw-r--r-- | library/core/src/ptr/mod.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/library/core/src/ptr/mod.rs b/library/core/src/ptr/mod.rs index e6e13eaff7b..d2b60f06e45 100644 --- a/library/core/src/ptr/mod.rs +++ b/library/core/src/ptr/mod.rs @@ -777,7 +777,7 @@ pub fn with_exposed_provenance_mut<T>(addr: usize) -> *mut T { /// # type T = i32; /// # fn foo() -> T { 42 } /// // The temporary holding the return value of `foo` does *not* have its lifetime extended, -/// // because the surrounding expression involves no function call. +/// // because the surrounding expression involves a function call. /// let p = ptr::from_ref(&foo()); /// unsafe { p.read() }; // UB! Reading from a dangling pointer ⚠️ /// ``` @@ -828,7 +828,7 @@ pub const fn from_ref<T: ?Sized>(r: &T) -> *const T { /// # type T = i32; /// # fn foo() -> T { 42 } /// // The temporary holding the return value of `foo` does *not* have its lifetime extended, -/// // because the surrounding expression involves no function call. +/// // because the surrounding expression involves a function call. /// let p = ptr::from_mut(&mut foo()); /// unsafe { p.write(T::default()) }; // UB! Writing to a dangling pointer ⚠️ /// ``` |
