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:
Coca 2026-01-02 21:26:16 +00:00
parent 5497a36a7f
commit 7061adc5a4
No known key found for this signature in database
GPG key ID: 03282DF88179AB19
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