about summary refs log tree commit diff
path: root/compiler/rustc_codegen_cranelift/example
diff options
context:
space:
mode:
authorbjorn3 <17426603+bjorn3@users.noreply.github.com>2023-07-22 13:32:34 +0000
committerbjorn3 <17426603+bjorn3@users.noreply.github.com>2023-07-22 13:32:34 +0000
commit36708123c1f73554c7bb5e8a2f0565aa25daef13 (patch)
tree89bd04173490c39f9624715dbe7166836f2bb633 /compiler/rustc_codegen_cranelift/example
parent42f5419dd29046612138413cbde4567def218341 (diff)
parent1eded3619d0e55d57521a259bf27a03906fdfad0 (diff)
downloadrust-36708123c1f73554c7bb5e8a2f0565aa25daef13.tar.gz
rust-36708123c1f73554c7bb5e8a2f0565aa25daef13.zip
Merge commit '1eded3619d0e55d57521a259bf27a03906fdfad0' into sync_cg_clif-2023-07-22
Diffstat (limited to 'compiler/rustc_codegen_cranelift/example')
-rw-r--r--compiler/rustc_codegen_cranelift/example/issue-59326.rs27
-rw-r--r--compiler/rustc_codegen_cranelift/example/mini_core.rs4
-rw-r--r--compiler/rustc_codegen_cranelift/example/std_example.rs32
3 files changed, 61 insertions, 2 deletions
diff --git a/compiler/rustc_codegen_cranelift/example/issue-59326.rs b/compiler/rustc_codegen_cranelift/example/issue-59326.rs
new file mode 100644
index 00000000000..70b7c94e15c
--- /dev/null
+++ b/compiler/rustc_codegen_cranelift/example/issue-59326.rs
@@ -0,0 +1,27 @@
+// Based on https://github.com/rust-lang/rust/blob/689511047a75a30825e367d4fd45c74604d0b15e/tests/ui/issues/issue-59326.rs#L1
+// check-pass
+trait Service {
+    type S;
+}
+
+trait Framing {
+    type F;
+}
+
+impl Framing for () {
+    type F = ();
+}
+
+trait HttpService<F: Framing>: Service<S = F::F> {}
+
+type BoxService = Box<dyn HttpService<(), S = ()>>;
+
+fn build_server<F: FnOnce() -> BoxService>(_: F) {}
+
+fn make_server<F: Framing>() -> Box<dyn HttpService<F, S = F::F>> {
+    unimplemented!()
+}
+
+fn main() {
+    build_server(|| make_server())
+}
diff --git a/compiler/rustc_codegen_cranelift/example/mini_core.rs b/compiler/rustc_codegen_cranelift/example/mini_core.rs
index 79ca4c03985..9ecc4c5dd5b 100644
--- a/compiler/rustc_codegen_cranelift/example/mini_core.rs
+++ b/compiler/rustc_codegen_cranelift/example/mini_core.rs
@@ -547,7 +547,9 @@ impl<T> Box<T> {
 impl<T: ?Sized, A> Drop for Box<T, A> {
     fn drop(&mut self) {
         // inner value is dropped by compiler
-        libc::free(self.0.pointer.0 as *mut u8);
+        unsafe {
+            libc::free(self.0.pointer.0 as *mut u8);
+        }
     }
 }
 
diff --git a/compiler/rustc_codegen_cranelift/example/std_example.rs b/compiler/rustc_codegen_cranelift/example/std_example.rs
index 1bf0ff64c92..490cc2404f6 100644
--- a/compiler/rustc_codegen_cranelift/example/std_example.rs
+++ b/compiler/rustc_codegen_cranelift/example/std_example.rs
@@ -1,4 +1,12 @@
-#![feature(core_intrinsics, generators, generator_trait, is_sorted, repr_simd)]
+#![feature(
+    core_intrinsics,
+    generators,
+    generator_trait,
+    is_sorted,
+    repr_simd,
+    tuple_trait,
+    unboxed_closures
+)]
 
 #[cfg(target_arch = "x86_64")]
 use std::arch::x86_64::*;
@@ -155,12 +163,34 @@ fn main() {
     }
 
     foo(I64X2(0, 0));
+
+    transmute_fat_pointer();
+
+    rust_call_abi();
 }
 
 fn panic(_: u128) {
     panic!();
 }
 
+use std::mem::transmute;
+
+#[cfg(target_pointer_width = "32")]
+type TwoPtrs = i64;
+#[cfg(target_pointer_width = "64")]
+type TwoPtrs = i128;
+
+fn transmute_fat_pointer() -> TwoPtrs {
+    unsafe { transmute::<_, TwoPtrs>("true !") }
+}
+
+extern "rust-call" fn rust_call_abi_callee<T: std::marker::Tuple>(_: T) {}
+
+fn rust_call_abi() {
+    rust_call_abi_callee(());
+    rust_call_abi_callee((1, 2));
+}
+
 #[repr(simd)]
 struct I64X2(i64, i64);