diff options
| author | CAD97 <cad97@cad97.com> | 2020-06-28 14:24:09 -0400 |
|---|---|---|
| committer | CAD97 <cad97@cad97.com> | 2020-06-28 14:24:09 -0400 |
| commit | e4bdf47f4c0773bba93f50900612242b929eca0b (patch) | |
| tree | 7c5702496e96771bd3f0a273da5fa0cc77c65f18 /src/liballoc | |
| parent | db539c649866d9a25cb18a741436b3086b5d6e04 (diff) | |
| download | rust-e4bdf47f4c0773bba93f50900612242b929eca0b.tar.gz rust-e4bdf47f4c0773bba93f50900612242b929eca0b.zip | |
Do not require ptr validity in rc::data_offset
Diffstat (limited to 'src/liballoc')
| -rw-r--r-- | src/liballoc/lib.rs | 1 | ||||
| -rw-r--r-- | src/liballoc/rc.rs | 4 |
2 files changed, 3 insertions, 2 deletions
diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index c812d0c6316..ed3b09bae05 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -100,6 +100,7 @@ #![feature(fundamental)] #![feature(internal_uninit_const)] #![feature(lang_items)] +#![feature(layout_for_ptr)] #![feature(libc)] #![feature(negative_impls)] #![feature(new_uninit)] diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index c69f2ffc437..408278d5b61 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -245,7 +245,7 @@ use core::hash::{Hash, Hasher}; use core::intrinsics::abort; use core::iter; use core::marker::{self, PhantomData, Unpin, Unsize}; -use core::mem::{self, align_of, align_of_val, forget, size_of_val}; +use core::mem::{self, align_of, align_of_val_raw, forget, size_of_val}; use core::ops::{CoerceUnsized, Deref, DispatchFromDyn, Receiver}; use core::pin::Pin; use core::ptr::{self, NonNull}; @@ -2114,7 +2114,7 @@ unsafe fn data_offset<T: ?Sized>(ptr: *const T) -> isize { // Because it is ?Sized, it will always be the last field in memory. // Note: This is a detail of the current implementation of the compiler, // and is not a guaranteed language detail. Do not rely on it outside of std. - unsafe { data_offset_align(align_of_val(&*ptr)) } + unsafe { data_offset_align(align_of_val_raw(ptr)) } } /// Computes the offset of the data field within `RcBox`. |
