Skip to content

Commit 6a40d50

Browse files
authored
Rollup merge of rust-lang#134908 - madsmtm:ptr-from_ref-docs, r=ibraheemdev
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. ``@rustbot`` label A-docs
2 parents 5f6d7cf + 5966ba0 commit 6a40d50

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

library/core/src/ptr/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@ pub fn with_exposed_provenance_mut<T>(addr: usize) -> *mut T {
777777
/// # type T = i32;
778778
/// # fn foo() -> T { 42 }
779779
/// // The temporary holding the return value of `foo` does *not* have its lifetime extended,
780-
/// // because the surrounding expression involves no function call.
780+
/// // because the surrounding expression involves a function call.
781781
/// let p = ptr::from_ref(&foo());
782782
/// unsafe { p.read() }; // UB! Reading from a dangling pointer ⚠️
783783
/// ```
@@ -828,7 +828,7 @@ pub const fn from_ref<T: ?Sized>(r: &T) -> *const T {
828828
/// # type T = i32;
829829
/// # fn foo() -> T { 42 }
830830
/// // The temporary holding the return value of `foo` does *not* have its lifetime extended,
831-
/// // because the surrounding expression involves no function call.
831+
/// // because the surrounding expression involves a function call.
832832
/// let p = ptr::from_mut(&mut foo());
833833
/// unsafe { p.write(T::default()) }; // UB! Writing to a dangling pointer ⚠️
834834
/// ```

0 commit comments

Comments
 (0)