Rollup merge of #150627 - Coca162:without_provenance_diagnostics, r=Urgau

Add diagnostic items for `without_provenance` and `without_provenance_mut`

Adds diagnostic items for `core::ptr::without_provenance` and `core::ptr::without_provenance_mut`. Will be used to enhance clippy lint `transmuting_null`, see https://github.com/rust-lang/rust-clippy/pull/16336.
This commit is contained in:
Jonathan Brouwer 2026-01-03 01:28:40 +01:00 committed by GitHub
commit e75d14917d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 0 deletions

View file

@ -1788,6 +1788,8 @@ symbols! {
ptr_slice_from_raw_parts_mut,
ptr_swap,
ptr_swap_nonoverlapping,
ptr_without_provenance,
ptr_without_provenance_mut,
ptr_write,
ptr_write_bytes,
ptr_write_unaligned,

View file

@ -880,6 +880,7 @@ pub const fn null_mut<T: PointeeSized + Thin>() -> *mut T {
#[must_use]
#[stable(feature = "strict_provenance", since = "1.84.0")]
#[rustc_const_stable(feature = "strict_provenance", since = "1.84.0")]
#[rustc_diagnostic_item = "ptr_without_provenance"]
pub const fn without_provenance<T>(addr: usize) -> *const T {
without_provenance_mut(addr)
}
@ -918,6 +919,7 @@ pub const fn dangling<T>() -> *const T {
#[must_use]
#[stable(feature = "strict_provenance", since = "1.84.0")]
#[rustc_const_stable(feature = "strict_provenance", since = "1.84.0")]
#[rustc_diagnostic_item = "ptr_without_provenance_mut"]
#[allow(integer_to_ptr_transmutes)] // Expected semantics here.
pub const fn without_provenance_mut<T>(addr: usize) -> *mut T {
// An int-to-pointer transmute currently has exactly the intended semantics: it creates a