@@ -494,6 +494,7 @@ mod mut_ptr;
494
494
#[ stable( feature = "drop_in_place" , since = "1.8.0" ) ]
495
495
#[ lang = "drop_in_place" ]
496
496
#[ allow( unconditional_recursion) ]
497
+ #[ rustc_diagnostic_item = "ptr_drop_in_place" ]
497
498
pub unsafe fn drop_in_place < T : ?Sized > ( to_drop : * mut T ) {
498
499
// Code here does not matter - this is replaced by the
499
500
// real drop glue by the compiler.
@@ -740,6 +741,7 @@ pub const fn from_mut<T: ?Sized>(r: &mut T) -> *mut T {
740
741
#[ stable( feature = "slice_from_raw_parts" , since = "1.42.0" ) ]
741
742
#[ rustc_const_stable( feature = "const_slice_from_raw_parts" , since = "1.64.0" ) ]
742
743
#[ rustc_allow_const_fn_unstable( ptr_metadata) ]
744
+ #[ rustc_diagnostic_item = "ptr_slice_from_raw_parts" ]
743
745
pub const fn slice_from_raw_parts < T > ( data : * const T , len : usize ) -> * const [ T ] {
744
746
from_raw_parts ( data. cast ( ) , len)
745
747
}
@@ -772,6 +774,7 @@ pub const fn slice_from_raw_parts<T>(data: *const T, len: usize) -> *const [T] {
772
774
#[ inline]
773
775
#[ stable( feature = "slice_from_raw_parts" , since = "1.42.0" ) ]
774
776
#[ rustc_const_unstable( feature = "const_slice_from_raw_parts_mut" , issue = "67456" ) ]
777
+ #[ rustc_diagnostic_item = "ptr_slice_from_raw_parts_mut" ]
775
778
pub const fn slice_from_raw_parts_mut < T > ( data : * mut T , len : usize ) -> * mut [ T ] {
776
779
from_raw_parts_mut ( data. cast ( ) , len)
777
780
}
@@ -850,6 +853,7 @@ pub const fn slice_from_raw_parts_mut<T>(data: *mut T, len: usize) -> *mut [T] {
850
853
#[ inline]
851
854
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
852
855
#[ rustc_const_unstable( feature = "const_swap" , issue = "83163" ) ]
856
+ #[ rustc_diagnostic_item = "ptr_swap" ]
853
857
pub const unsafe fn swap < T > ( x : * mut T , y : * mut T ) {
854
858
// Give ourselves some scratch space to work with.
855
859
// We do not have to worry about drops: `MaybeUninit` does nothing when dropped.
@@ -911,6 +915,7 @@ pub const unsafe fn swap<T>(x: *mut T, y: *mut T) {
911
915
#[ inline]
912
916
#[ stable( feature = "swap_nonoverlapping" , since = "1.27.0" ) ]
913
917
#[ rustc_const_unstable( feature = "const_swap" , issue = "83163" ) ]
918
+ #[ rustc_diagnostic_item = "ptr_swap_nonoverlapping" ]
914
919
pub const unsafe fn swap_nonoverlapping < T > ( x : * mut T , y : * mut T , count : usize ) {
915
920
#[ allow( unused) ]
916
921
macro_rules! attempt_swap_as_chunks {
@@ -1022,6 +1027,7 @@ const unsafe fn swap_nonoverlapping_simple_untyped<T>(x: *mut T, y: *mut T, coun
1022
1027
#[ inline]
1023
1028
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1024
1029
#[ rustc_const_unstable( feature = "const_replace" , issue = "83164" ) ]
1030
+ #[ rustc_diagnostic_item = "ptr_replace" ]
1025
1031
pub const unsafe fn replace < T > ( dst : * mut T , mut src : T ) -> T {
1026
1032
// SAFETY: the caller must guarantee that `dst` is valid to be
1027
1033
// cast to a mutable reference (valid for writes, aligned, initialized),
@@ -1147,6 +1153,7 @@ pub const unsafe fn replace<T>(dst: *mut T, mut src: T) -> T {
1147
1153
#[ rustc_const_stable( feature = "const_ptr_read" , since = "1.71.0" ) ]
1148
1154
#[ rustc_allow_const_fn_unstable( const_mut_refs, const_maybe_uninit_as_mut_ptr) ]
1149
1155
#[ cfg_attr( miri, track_caller) ] // even without panics, this helps for Miri backtraces
1156
+ #[ rustc_diagnostic_item = "ptr_read" ]
1150
1157
pub const unsafe fn read < T > ( src : * const T ) -> T {
1151
1158
// It would be semantically correct to implement this via `copy_nonoverlapping`
1152
1159
// and `MaybeUninit`, as was done before PR #109035. Calling `assume_init`
@@ -1264,6 +1271,7 @@ pub const unsafe fn read<T>(src: *const T) -> T {
1264
1271
#[ rustc_const_stable( feature = "const_ptr_read" , since = "1.71.0" ) ]
1265
1272
#[ rustc_allow_const_fn_unstable( const_mut_refs, const_maybe_uninit_as_mut_ptr) ]
1266
1273
#[ cfg_attr( miri, track_caller) ] // even without panics, this helps for Miri backtraces
1274
+ #[ rustc_diagnostic_item = "ptr_read_unaligned" ]
1267
1275
pub const unsafe fn read_unaligned < T > ( src : * const T ) -> T {
1268
1276
let mut tmp = MaybeUninit :: < T > :: uninit ( ) ;
1269
1277
// SAFETY: the caller must guarantee that `src` is valid for reads.
@@ -1539,6 +1547,7 @@ pub const unsafe fn write_unaligned<T>(dst: *mut T, src: T) {
1539
1547
#[ inline]
1540
1548
#[ stable( feature = "volatile" , since = "1.9.0" ) ]
1541
1549
#[ cfg_attr( miri, track_caller) ] // even without panics, this helps for Miri backtraces
1550
+ #[ rustc_diagnostic_item = "ptr_read_volatile" ]
1542
1551
pub unsafe fn read_volatile < T > ( src : * const T ) -> T {
1543
1552
// SAFETY: the caller must uphold the safety contract for `volatile_load`.
1544
1553
unsafe {
@@ -1865,6 +1874,7 @@ pub(crate) const unsafe fn align_offset<T: Sized>(p: *const T, a: usize) -> usiz
1865
1874
#[ stable( feature = "ptr_eq" , since = "1.17.0" ) ]
1866
1875
#[ inline( always) ]
1867
1876
#[ must_use = "pointer comparison produces a value" ]
1877
+ #[ rustc_diagnostic_item = "ptr_eq" ]
1868
1878
pub fn eq < T : ?Sized > ( a : * const T , b : * const T ) -> bool {
1869
1879
a == b
1870
1880
}
0 commit comments