diff options
| author | bjorn3 <bjorn3@users.noreply.github.com> | 2022-03-26 18:29:37 +0100 |
|---|---|---|
| committer | bjorn3 <bjorn3@users.noreply.github.com> | 2022-03-26 18:29:37 +0100 |
| commit | 3888aafe3a4a030341fc21f9ac731e1a3bb108f0 (patch) | |
| tree | f466d9b0bff049dc9522a24fb201205400ffd7c9 /example | |
| parent | fadd1c536a1cc7b2b605abc8e8482fb15363b3a7 (diff) | |
| download | rust-3888aafe3a4a030341fc21f9ac731e1a3bb108f0.tar.gz rust-3888aafe3a4a030341fc21f9ac731e1a3bb108f0.zip | |
Merge commit '39683d8eb7a32a74bea96ecbf1e87675d3338506' into sync_cg_gcc-2022-03-26
Diffstat (limited to 'example')
| -rw-r--r-- | example/mini_core.rs | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/example/mini_core.rs b/example/mini_core.rs index 1067cee8814..a8435287d9f 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -14,6 +14,9 @@ unsafe extern "C" fn _Unwind_Resume() { #[lang = "sized"] pub trait Sized {} +#[lang = "destruct"] +pub trait Destruct {} + #[lang = "unsize"] pub trait Unsize<T: ?Sized> {} @@ -59,6 +62,7 @@ unsafe impl Copy for i16 {} unsafe impl Copy for i32 {} unsafe impl Copy for isize {} unsafe impl Copy for f32 {} +unsafe impl Copy for f64 {} unsafe impl Copy for char {} unsafe impl<'a, T: ?Sized> Copy for &'a T {} unsafe impl<T: ?Sized> Copy for *const T {} @@ -443,12 +447,22 @@ pub trait Deref { fn deref(&self) -> &Self::Target; } +pub trait Allocator { +} + +pub struct Global; + +impl Allocator for Global {} + #[lang = "owned_box"] -pub struct Box<T: ?Sized>(*mut T); +pub struct Box< + T: ?Sized, + A: Allocator = Global, +>(*mut T, A); impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Box<U>> for Box<T> {} -impl<T: ?Sized> Drop for Box<T> { +impl<T: ?Sized, A: Allocator> Drop for Box<T, A> { fn drop(&mut self) { // drop is currently performed by compiler. } @@ -468,7 +482,7 @@ unsafe fn allocate(size: usize, _align: usize) -> *mut u8 { } #[lang = "box_free"] -unsafe fn box_free<T: ?Sized>(ptr: *mut T) { +unsafe fn box_free<T: ?Sized, A: Allocator>(ptr: *mut T, alloc: A) { libc::free(ptr as *mut u8); } |
