Rollup merge of #148836 - ericseppanen:primitive_reference_docs, r=Mark-Simulacrum

tweak primitive reference docs

This is a docs-only change for primitive reference.

I noticed a typo ("safe to use at type `T`") and fixed it to read "safe to use *as* type `T`".

While reading over the whole page, I also noticed another sentence that was hard to read. I tried to improve it: feel free to comment on the wisdom of this change...
This commit is contained in:
Stuart Cook 2025-11-16 14:39:59 +11:00 committed by GitHub
commit 8ea74b1a8f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1531,9 +1531,8 @@ mod prim_usize {}
/// `&mut T` references can be freely coerced into `&T` references with the same referent type, and
/// references with longer lifetimes can be freely coerced into references with shorter ones.
///
/// Reference equality by address, instead of comparing the values pointed to, is accomplished via
/// implicit reference-pointer coercion and raw pointer equality via [`ptr::eq`], while
/// [`PartialEq`] compares values.
/// [`PartialEq`] will compare referenced values. It is possible to compare the reference address
/// using reference-pointer coercion and raw pointer equality via [`ptr::eq`].
///
/// ```
/// use std::ptr;
@ -1648,7 +1647,7 @@ mod prim_usize {}
/// For the other direction, things are more complicated: when unsafe code passes arguments
/// to safe functions or returns values from safe functions, they generally must *at least*
/// not violate these invariants. The full requirements are stronger, as the reference generally
/// must point to data that is safe to use at type `T`.
/// must point to data that is safe to use as type `T`.
///
/// It is not decided yet whether unsafe code may violate these invariants temporarily on internal
/// data. As a consequence, unsafe code which violates these invariants temporarily on internal data