Skip to content

Commit

Permalink
Unrolled build for rust-lang#134908
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rust-timer authored Jan 10, 2025
2 parents 88ab2d8 + 5966ba0 commit cfb859b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions library/core/src/ptr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ⚠️
/// ```
Expand Down Expand Up @@ -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 ⚠️
/// ```
Expand Down

0 comments on commit cfb859b

Please sign in to comment.