diff options
| author | Ralf Jung <post@ralfj.de> | 2024-03-05 11:32:03 +0100 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2024-03-05 15:03:33 +0100 |
| commit | 804eeff1806ce6a3cd88abf4290e569ebe939051 (patch) | |
| tree | d201b7ca72ef5b14c51e7dbeb3123a6b035a5fda /example | |
| parent | 927776684070a8a61f4883ccfdf255515bcbb4a3 (diff) | |
only set noalias on Box with the global allocator
Diffstat (limited to 'example')
| -rw-r--r-- | example/mini_core.rs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/example/mini_core.rs b/example/mini_core.rs index a79909ce0c8..67a0d0dabea 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -525,8 +525,11 @@ pub struct Unique<T: ?Sized> { impl<T: ?Sized, U: ?Sized> CoerceUnsized<Unique<U>> for Unique<T> where T: Unsize<U> {} impl<T: ?Sized, U: ?Sized> DispatchFromDyn<Unique<U>> for Unique<T> where T: Unsize<U> {} +#[lang = "global_alloc_ty"] +pub struct Global; + #[lang = "owned_box"] -pub struct Box<T: ?Sized, A = ()>(Unique<T>, A); +pub struct Box<T: ?Sized, A = Global>(Unique<T>, A); impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Box<U>> for Box<T> {} @@ -536,7 +539,7 @@ impl<T> Box<T> { let size = intrinsics::size_of::<T>(); let ptr = libc::malloc(size); intrinsics::copy(&val as *const T as *const u8, ptr, size); - Box(Unique { pointer: NonNull(ptr as *const T), _marker: PhantomData }, ()) + Box(Unique { pointer: NonNull(ptr as *const T), _marker: PhantomData }, Global) } } } |
