Skip to content

Commit e75d149

Browse files
Rollup merge of rust-lang#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 rust-lang/rust-clippy#16336.
2 parents 85c8ff6 + 7061adc commit e75d149

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

compiler/rustc_span/src/symbol.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1788,6 +1788,8 @@ symbols! {
17881788
ptr_slice_from_raw_parts_mut,
17891789
ptr_swap,
17901790
ptr_swap_nonoverlapping,
1791+
ptr_without_provenance,
1792+
ptr_without_provenance_mut,
17911793
ptr_write,
17921794
ptr_write_bytes,
17931795
ptr_write_unaligned,

library/core/src/ptr/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -880,6 +880,7 @@ pub const fn null_mut<T: PointeeSized + Thin>() -> *mut T {
880880
#[must_use]
881881
#[stable(feature = "strict_provenance", since = "1.84.0")]
882882
#[rustc_const_stable(feature = "strict_provenance", since = "1.84.0")]
883+
#[rustc_diagnostic_item = "ptr_without_provenance"]
883884
pub const fn without_provenance<T>(addr: usize) -> *const T {
884885
without_provenance_mut(addr)
885886
}
@@ -918,6 +919,7 @@ pub const fn dangling<T>() -> *const T {
918919
#[must_use]
919920
#[stable(feature = "strict_provenance", since = "1.84.0")]
920921
#[rustc_const_stable(feature = "strict_provenance", since = "1.84.0")]
922+
#[rustc_diagnostic_item = "ptr_without_provenance_mut"]
921923
#[allow(integer_to_ptr_transmutes)] // Expected semantics here.
922924
pub const fn without_provenance_mut<T>(addr: usize) -> *mut T {
923925
// An int-to-pointer transmute currently has exactly the intended semantics: it creates a

0 commit comments

Comments
 (0)