about summary refs log tree commit diff
path: root/compiler/rustc_middle/src
diff options
context:
space:
mode:
authorJosh Stone <jistone@redhat.com>2024-09-26 20:33:26 -0700
committerJosh Stone <jistone@redhat.com>2024-09-26 20:33:26 -0700
commit4160a54dc5751d08dd23c7e5b0dc6cbc0889ce32 (patch)
treed6bc98cfa79c53f552fd9b86ebeea9b34451c093 /compiler/rustc_middle/src
parent58420a065b68ecb3eec03b942740c761cdadd5c4 (diff)
downloadrust-4160a54dc5751d08dd23c7e5b0dc6cbc0889ce32.tar.gz
rust-4160a54dc5751d08dd23c7e5b0dc6cbc0889ce32.zip
Use `&raw` in the compiler
Like #130865 did for the standard library, we can use `&raw` in the
compiler now that stage0 supports it. Also like the other issue, I did
not make any doc or test changes at this time.
Diffstat (limited to 'compiler/rustc_middle/src')
-rw-r--r--compiler/rustc_middle/src/query/on_disk_cache.rs4
-rw-r--r--compiler/rustc_middle/src/ty/list.rs10
2 files changed, 7 insertions, 7 deletions
diff --git a/compiler/rustc_middle/src/query/on_disk_cache.rs b/compiler/rustc_middle/src/query/on_disk_cache.rs
index 06c9ebc87b5..35a16684615 100644
--- a/compiler/rustc_middle/src/query/on_disk_cache.rs
+++ b/compiler/rustc_middle/src/query/on_disk_cache.rs
@@ -233,7 +233,7 @@ impl<'sess> OnDiskCache<'sess> {
 
                 for (index, file) in files.iter().enumerate() {
                     let index = SourceFileIndex(index as u32);
-                    let file_ptr: *const SourceFile = std::ptr::addr_of!(**file);
+                    let file_ptr: *const SourceFile = &raw const **file;
                     file_to_file_index.insert(file_ptr, index);
                     let source_file_id = EncodedSourceFileId::new(tcx, file);
                     file_index_to_stable_id.insert(index, source_file_id);
@@ -827,7 +827,7 @@ pub struct CacheEncoder<'a, 'tcx> {
 impl<'a, 'tcx> CacheEncoder<'a, 'tcx> {
     #[inline]
     fn source_file_index(&mut self, source_file: Lrc<SourceFile>) -> SourceFileIndex {
-        self.file_to_file_index[&std::ptr::addr_of!(*source_file)]
+        self.file_to_file_index[&(&raw const *source_file)]
     }
 
     /// Encode something with additional information that allows to do some
diff --git a/compiler/rustc_middle/src/ty/list.rs b/compiler/rustc_middle/src/ty/list.rs
index ec9ca65dbda..ea07cd3a1b9 100644
--- a/compiler/rustc_middle/src/ty/list.rs
+++ b/compiler/rustc_middle/src/ty/list.rs
@@ -103,13 +103,13 @@ impl<H, T> RawList<H, T> {
         let mem = arena.dropless.alloc_raw(layout) as *mut RawList<H, T>;
         unsafe {
             // Write the header
-            ptr::addr_of_mut!((*mem).skel.header).write(header);
+            (&raw mut (*mem).skel.header).write(header);
 
             // Write the length
-            ptr::addr_of_mut!((*mem).skel.len).write(slice.len());
+            (&raw mut (*mem).skel.len).write(slice.len());
 
             // Write the elements
-            ptr::addr_of_mut!((*mem).skel.data)
+            (&raw mut (*mem).skel.data)
                 .cast::<T>()
                 .copy_from_nonoverlapping(slice.as_ptr(), slice.len());
 
@@ -160,7 +160,7 @@ macro_rules! impl_list_empty {
 
                 // SAFETY: `EMPTY` is sufficiently aligned to be an empty list for all
                 // types with `align_of(T) <= align_of(MaxAlign)`, which we checked above.
-                unsafe { &*(std::ptr::addr_of!(EMPTY) as *const RawList<$header_ty, T>) }
+                unsafe { &*((&raw const EMPTY) as *const RawList<$header_ty, T>) }
             }
         }
     };
@@ -238,7 +238,7 @@ impl<H, T> Deref for RawList<H, T> {
 impl<H, T> AsRef<[T]> for RawList<H, T> {
     #[inline(always)]
     fn as_ref(&self) -> &[T] {
-        let data_ptr = ptr::addr_of!(self.skel.data).cast::<T>();
+        let data_ptr = (&raw const self.skel.data).cast::<T>();
         // SAFETY: `data_ptr` has the same provenance as `self` and can therefore
         // access the `self.skel.len` elements stored at `self.skel.data`.
         // Note that we specifically don't reborrow `&self.skel.data`, because that