Skip to content

Commit 804eeff

Browse files
committed
only set noalias on Box with the global allocator
1 parent 9277766 commit 804eeff

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

example/mini_core.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -525,8 +525,11 @@ pub struct Unique<T: ?Sized> {
525525
impl<T: ?Sized, U: ?Sized> CoerceUnsized<Unique<U>> for Unique<T> where T: Unsize<U> {}
526526
impl<T: ?Sized, U: ?Sized> DispatchFromDyn<Unique<U>> for Unique<T> where T: Unsize<U> {}
527527

528+
#[lang = "global_alloc_ty"]
529+
pub struct Global;
530+
528531
#[lang = "owned_box"]
529-
pub struct Box<T: ?Sized, A = ()>(Unique<T>, A);
532+
pub struct Box<T: ?Sized, A = Global>(Unique<T>, A);
530533

531534
impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Box<U>> for Box<T> {}
532535

@@ -536,7 +539,7 @@ impl<T> Box<T> {
536539
let size = intrinsics::size_of::<T>();
537540
let ptr = libc::malloc(size);
538541
intrinsics::copy(&val as *const T as *const u8, ptr, size);
539-
Box(Unique { pointer: NonNull(ptr as *const T), _marker: PhantomData }, ())
542+
Box(Unique { pointer: NonNull(ptr as *const T), _marker: PhantomData }, Global)
540543
}
541544
}
542545
}

src/unsize.rs

-4
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,6 @@ fn unsize_ptr<'tcx>(
7474
| (&ty::RawPtr(ty::TypeAndMut { ty: a, .. }), &ty::RawPtr(ty::TypeAndMut { ty: b, .. })) => {
7575
(src, unsized_info(fx, *a, *b, old_info))
7676
}
77-
(&ty::Adt(def_a, _), &ty::Adt(def_b, _)) if def_a.is_box() && def_b.is_box() => {
78-
let (a, b) = (src_layout.ty.boxed_ty(), dst_layout.ty.boxed_ty());
79-
(src, unsized_info(fx, a, b, old_info))
80-
}
8177
(&ty::Adt(def_a, _), &ty::Adt(def_b, _)) => {
8278
assert_eq!(def_a, def_b);
8379

0 commit comments

Comments
 (0)