Skip to content

Commit e4bdf47

Browse files
committed
Do not require ptr validity in rc::data_offset
1 parent db539c6 commit e4bdf47

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/liballoc/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@
100100
#![feature(fundamental)]
101101
#![feature(internal_uninit_const)]
102102
#![feature(lang_items)]
103+
#![feature(layout_for_ptr)]
103104
#![feature(libc)]
104105
#![feature(negative_impls)]
105106
#![feature(new_uninit)]

src/liballoc/rc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ use core::hash::{Hash, Hasher};
245245
use core::intrinsics::abort;
246246
use core::iter;
247247
use core::marker::{self, PhantomData, Unpin, Unsize};
248-
use core::mem::{self, align_of, align_of_val, forget, size_of_val};
248+
use core::mem::{self, align_of, align_of_val_raw, forget, size_of_val};
249249
use core::ops::{CoerceUnsized, Deref, DispatchFromDyn, Receiver};
250250
use core::pin::Pin;
251251
use core::ptr::{self, NonNull};
@@ -2114,7 +2114,7 @@ unsafe fn data_offset<T: ?Sized>(ptr: *const T) -> isize {
21142114
// Because it is ?Sized, it will always be the last field in memory.
21152115
// Note: This is a detail of the current implementation of the compiler,
21162116
// and is not a guaranteed language detail. Do not rely on it outside of std.
2117-
unsafe { data_offset_align(align_of_val(&*ptr)) }
2117+
unsafe { data_offset_align(align_of_val_raw(ptr)) }
21182118
}
21192119

21202120
/// Computes the offset of the data field within `RcBox`.

0 commit comments

Comments
 (0)