ソースを参照

Try to fix intrinsics example on nightly

Alex Crichton 6 年 前
コミット
182450f20c

+ 3 - 0
Cargo.toml

@@ -9,6 +9,9 @@ test = false
 [build-dependencies]
 cc = { optional = true, version = "1.0" }
 
+[dev-dependencies]
+panic-implementation = { path = 'crates/panic-implementation' }
+
 [features]
 default = ["compiler-builtins"]
 

+ 6 - 0
crates/panic-implementation/Cargo.toml

@@ -0,0 +1,6 @@
+[package]
+name = "panic-implementation"
+version = "0.1.0"
+authors = ["Alex Crichton <alex@alexcrichton.com>"]
+
+[dependencies]

+ 11 - 0
crates/panic-implementation/src/lib.rs

@@ -0,0 +1,11 @@
+// Hack of a crate until rust-lang/rust#51647 is fixed
+
+#![feature(no_core, panic_implementation)]
+#![no_core]
+
+extern crate core;
+
+#[panic_implementation]
+fn panic(_: &core::panic::PanicInfo) -> ! {
+    loop {}
+}

+ 9 - 6
examples/intrinsics.rs

@@ -12,12 +12,13 @@
 #![feature(core_float)]
 #![feature(lang_items)]
 #![feature(start)]
-#![feature(global_allocator)]
 #![feature(allocator_api)]
 #![feature(panic_implementation)]
 #![cfg_attr(windows, feature(panic_unwind))]
 #![no_std]
 
+extern crate panic_implementation;
+
 #[cfg(not(thumb))]
 #[link(name = "c")]
 extern {}
@@ -393,6 +394,13 @@ fn run() {
     bb(modti3(bb(2), bb(2)));
 
     something_with_a_dtor(&|| assert_eq!(bb(1), 1));
+
+    extern {
+        fn rust_begin_unwind();
+    }
+    // if bb(false) {
+        unsafe { rust_begin_unwind(); }
+    // }
 }
 
 fn something_with_a_dtor(f: &Fn()) {
@@ -442,8 +450,3 @@ pub fn _Unwind_Resume() {}
 #[lang = "eh_personality"]
 #[no_mangle]
 pub extern "C" fn eh_personality() {}
-
-#[panic_implementation]
-fn panic(x: &core::panic::PanicInfo) -> ! {
-    loop {}
-}