]> git.proxmox.com Git - rustc.git/blobdiff - compiler/rustc_codegen_cranelift/example/mini_core.rs
New upstream version 1.61.0+dfsg1
[rustc.git] / compiler / rustc_codegen_cranelift / example / mini_core.rs
index c4834c804087199822e4552a19874744235992ef..7efc8dc785a1912476b3d6e93e9f3f5896d6e39c 100644 (file)
@@ -1,7 +1,14 @@
 #![feature(
-    no_core, lang_items, intrinsics, unboxed_closures, type_ascription, extern_types,
-    untagged_unions, decl_macro, rustc_attrs, transparent_unions, auto_traits,
-    thread_local,
+    no_core,
+    lang_items,
+    intrinsics,
+    unboxed_closures,
+    extern_types,
+    decl_macro,
+    rustc_attrs,
+    transparent_unions,
+    auto_traits,
+    thread_local
 )]
 #![no_core]
 #![allow(dead_code)]
@@ -55,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 {}
@@ -483,8 +491,17 @@ pub trait Deref {
     fn deref(&self) -> &Self::Target;
 }
 
+pub struct Unique<T: ?Sized> {
+    pub pointer: *const T,
+    pub _marker: PhantomData<T>,
+}
+
+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 = "owned_box"]
-pub struct Box<T: ?Sized>(*mut T);
+pub struct Box<T: ?Sized>(Unique<T>, ());
 
 impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Box<U>> for Box<T> {}
 
@@ -508,8 +525,8 @@ unsafe fn allocate(size: usize, _align: usize) -> *mut u8 {
 }
 
 #[lang = "box_free"]
-unsafe fn box_free<T: ?Sized>(ptr: *mut T) {
-    libc::free(ptr as *mut u8);
+unsafe fn box_free<T: ?Sized>(ptr: Unique<T>, alloc: ()) {
+    libc::free(ptr.pointer as *mut u8);
 }
 
 #[lang = "drop"]