From 182450f20c5cf65f3610572c04b50916fd9f8e52 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 12 Jul 2018 09:29:32 -0700 Subject: [PATCH] Try to fix intrinsics example on nightly --- Cargo.toml | 3 +++ crates/panic-implementation/Cargo.toml | 6 ++++++ crates/panic-implementation/src/lib.rs | 11 +++++++++++ examples/intrinsics.rs | 15 +++++++++------ 4 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 crates/panic-implementation/Cargo.toml create mode 100644 crates/panic-implementation/src/lib.rs diff --git a/Cargo.toml b/Cargo.toml index 0ebeb17..3112662 100644 --- a/Cargo.toml +++ b/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"] diff --git a/crates/panic-implementation/Cargo.toml b/crates/panic-implementation/Cargo.toml new file mode 100644 index 0000000..a076cbc --- /dev/null +++ b/crates/panic-implementation/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "panic-implementation" +version = "0.1.0" +authors = ["Alex Crichton "] + +[dependencies] diff --git a/crates/panic-implementation/src/lib.rs b/crates/panic-implementation/src/lib.rs new file mode 100644 index 0000000..1bb2397 --- /dev/null +++ b/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 {} +} diff --git a/examples/intrinsics.rs b/examples/intrinsics.rs index 6468a83..c165fcc 100644 --- a/examples/intrinsics.rs +++ b/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 {} -}