diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-08-25 16:51:03 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-25 16:51:03 +0200 |
| commit | 7edbd6353b2f906bb8e7c4a3dfcd64b754268df0 (patch) | |
| tree | e9a8efae4ea83111955df6cf157a56fc9e823fbb /compiler/rustc_middle | |
| parent | 89103466d77a3ae068bab0fd17c53bf7104f627b (diff) | |
| parent | 58dcd1c2e6f020369e9e9c0d8ad76435cb34a6f3 (diff) | |
| download | rust-7edbd6353b2f906bb8e7c4a3dfcd64b754268df0.tar.gz rust-7edbd6353b2f906bb8e7c4a3dfcd64b754268df0.zip | |
Rollup merge of #129091 - RalfJung:box_as_ptr, r=Amanieu
add Box::as_ptr and Box::as_mut_ptr methods Unstably implements https://github.com/rust-lang/libs-team/issues/355. Tracking issue: https://github.com/rust-lang/rust/issues/129090. r? libs-api
Diffstat (limited to 'compiler/rustc_middle')
| -rw-r--r-- | compiler/rustc_middle/src/lib.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/mir/interpret/allocation.rs | 6 |
2 files changed, 3 insertions, 4 deletions
diff --git a/compiler/rustc_middle/src/lib.rs b/compiler/rustc_middle/src/lib.rs index 5bd7736a3f3..6886562d9b7 100644 --- a/compiler/rustc_middle/src/lib.rs +++ b/compiler/rustc_middle/src/lib.rs @@ -34,6 +34,7 @@ #![feature(allocator_api)] #![feature(array_windows)] #![feature(assert_matches)] +#![feature(box_as_ptr)] #![feature(box_patterns)] #![feature(closure_track_caller)] #![feature(const_option)] diff --git a/compiler/rustc_middle/src/mir/interpret/allocation.rs b/compiler/rustc_middle/src/mir/interpret/allocation.rs index 665ab2797f2..3e101c0c635 100644 --- a/compiler/rustc_middle/src/mir/interpret/allocation.rs +++ b/compiler/rustc_middle/src/mir/interpret/allocation.rs @@ -62,13 +62,11 @@ impl AllocBytes for Box<[u8]> { } fn as_mut_ptr(&mut self) -> *mut u8 { - // Carefully avoiding any intermediate references. - ptr::addr_of_mut!(**self).cast() + Box::as_mut_ptr(self).cast() } fn as_ptr(&self) -> *const u8 { - // Carefully avoiding any intermediate references. - ptr::addr_of!(**self).cast() + Box::as_ptr(self).cast() } } |
