Skip to content

Commit bccd52b

Browse files
authored
Unrolled build for rust-lang#130916
Rollup merge of rust-lang#130916 - cuviper:compiler-raw_ref_op, r=compiler-errors Use `&raw` in the compiler Like rust-lang#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.
2 parents a3f76a2 + 4160a54 commit bccd52b

File tree

7 files changed

+13
-13
lines changed

7 files changed

+13
-13
lines changed

compiler/rustc_codegen_llvm/src/back/archive.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ fn get_llvm_object_symbols(
123123
llvm::LLVMRustGetSymbols(
124124
buf.as_ptr(),
125125
buf.len(),
126-
std::ptr::addr_of_mut!(*state) as *mut c_void,
126+
(&raw mut *state) as *mut c_void,
127127
callback,
128128
error_callback,
129129
)

compiler/rustc_codegen_llvm/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ impl WriteBackendMethods for LlvmCodegenBackend {
167167
fn print_pass_timings(&self) {
168168
unsafe {
169169
let mut size = 0;
170-
let cstr = llvm::LLVMRustPrintPassTimings(std::ptr::addr_of_mut!(size));
170+
let cstr = llvm::LLVMRustPrintPassTimings(&raw mut size);
171171
if cstr.is_null() {
172172
println!("failed to get pass timings");
173173
} else {
@@ -180,7 +180,7 @@ impl WriteBackendMethods for LlvmCodegenBackend {
180180
fn print_statistics(&self) {
181181
unsafe {
182182
let mut size = 0;
183-
let cstr = llvm::LLVMRustPrintStatistics(std::ptr::addr_of_mut!(size));
183+
let cstr = llvm::LLVMRustPrintStatistics(&raw mut size);
184184
if cstr.is_null() {
185185
println!("failed to get pass stats");
186186
} else {

compiler/rustc_codegen_llvm/src/llvm_util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ pub(crate) fn print(req: &PrintRequest, mut out: &mut String, sess: &Session) {
478478
&tm,
479479
cpu_cstring.as_ptr(),
480480
callback,
481-
std::ptr::addr_of_mut!(out) as *mut c_void,
481+
(&raw mut out) as *mut c_void,
482482
);
483483
}
484484
}

compiler/rustc_data_structures/src/sync.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ impl<T> RwLock<T> {
437437
#[inline(always)]
438438
pub fn leak(&self) -> &T {
439439
let guard = self.read();
440-
let ret = unsafe { &*std::ptr::addr_of!(*guard) };
440+
let ret = unsafe { &*(&raw const *guard) };
441441
std::mem::forget(guard);
442442
ret
443443
}

compiler/rustc_middle/src/query/on_disk_cache.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ impl<'sess> OnDiskCache<'sess> {
233233

234234
for (index, file) in files.iter().enumerate() {
235235
let index = SourceFileIndex(index as u32);
236-
let file_ptr: *const SourceFile = std::ptr::addr_of!(**file);
236+
let file_ptr: *const SourceFile = &raw const **file;
237237
file_to_file_index.insert(file_ptr, index);
238238
let source_file_id = EncodedSourceFileId::new(tcx, file);
239239
file_index_to_stable_id.insert(index, source_file_id);
@@ -827,7 +827,7 @@ pub struct CacheEncoder<'a, 'tcx> {
827827
impl<'a, 'tcx> CacheEncoder<'a, 'tcx> {
828828
#[inline]
829829
fn source_file_index(&mut self, source_file: Lrc<SourceFile>) -> SourceFileIndex {
830-
self.file_to_file_index[&std::ptr::addr_of!(*source_file)]
830+
self.file_to_file_index[&(&raw const *source_file)]
831831
}
832832

833833
/// Encode something with additional information that allows to do some

compiler/rustc_middle/src/ty/list.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,13 @@ impl<H, T> RawList<H, T> {
103103
let mem = arena.dropless.alloc_raw(layout) as *mut RawList<H, T>;
104104
unsafe {
105105
// Write the header
106-
ptr::addr_of_mut!((*mem).skel.header).write(header);
106+
(&raw mut (*mem).skel.header).write(header);
107107

108108
// Write the length
109-
ptr::addr_of_mut!((*mem).skel.len).write(slice.len());
109+
(&raw mut (*mem).skel.len).write(slice.len());
110110

111111
// Write the elements
112-
ptr::addr_of_mut!((*mem).skel.data)
112+
(&raw mut (*mem).skel.data)
113113
.cast::<T>()
114114
.copy_from_nonoverlapping(slice.as_ptr(), slice.len());
115115

@@ -160,7 +160,7 @@ macro_rules! impl_list_empty {
160160

161161
// SAFETY: `EMPTY` is sufficiently aligned to be an empty list for all
162162
// types with `align_of(T) <= align_of(MaxAlign)`, which we checked above.
163-
unsafe { &*(std::ptr::addr_of!(EMPTY) as *const RawList<$header_ty, T>) }
163+
unsafe { &*((&raw const EMPTY) as *const RawList<$header_ty, T>) }
164164
}
165165
}
166166
};
@@ -238,7 +238,7 @@ impl<H, T> Deref for RawList<H, T> {
238238
impl<H, T> AsRef<[T]> for RawList<H, T> {
239239
#[inline(always)]
240240
fn as_ref(&self) -> &[T] {
241-
let data_ptr = ptr::addr_of!(self.skel.data).cast::<T>();
241+
let data_ptr = (&raw const self.skel.data).cast::<T>();
242242
// SAFETY: `data_ptr` has the same provenance as `self` and can therefore
243243
// access the `self.skel.len` elements stored at `self.skel.data`.
244244
// Note that we specifically don't reborrow `&self.skel.data`, because that

compiler/stable_mir/src/compiler_interface.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ where
255255
if TLV.is_set() {
256256
Err(Error::from("StableMIR already running"))
257257
} else {
258-
let ptr: *const () = std::ptr::addr_of!(context) as _;
258+
let ptr: *const () = (&raw const context) as _;
259259
TLV.set(&Cell::new(ptr), || Ok(f()))
260260
}
261261
}

0 commit comments

Comments
 (0)