diff options
Diffstat (limited to 'src/test/ui/panic-handler')
| -rw-r--r-- | src/test/ui/panic-handler/auxiliary/weak-lang-items.rs | 22 | ||||
| -rw-r--r-- | src/test/ui/panic-handler/panic-handler-missing.rs | 9 | ||||
| -rw-r--r-- | src/test/ui/panic-handler/panic-handler-twice.rs | 19 | ||||
| -rw-r--r-- | src/test/ui/panic-handler/weak-lang-item.rs | 11 | ||||
| -rw-r--r-- | src/test/ui/panic-handler/weak-lang-item.stderr | 19 |
5 files changed, 80 insertions, 0 deletions
diff --git a/src/test/ui/panic-handler/auxiliary/weak-lang-items.rs b/src/test/ui/panic-handler/auxiliary/weak-lang-items.rs new file mode 100644 index 00000000000..7a698cf76ae --- /dev/null +++ b/src/test/ui/panic-handler/auxiliary/weak-lang-items.rs @@ -0,0 +1,22 @@ +// no-prefer-dynamic + +// This aux-file will require the eh_personality function to be codegen'd, but +// it hasn't been defined just yet. Make sure we don't explode. + +#![no_std] +#![crate_type = "rlib"] + +struct A; + +impl core::ops::Drop for A { + fn drop(&mut self) {} +} + +pub fn foo() { + let _a = A; + panic!("wut"); +} + +mod std { + pub use core::{option, fmt}; +} diff --git a/src/test/ui/panic-handler/panic-handler-missing.rs b/src/test/ui/panic-handler/panic-handler-missing.rs new file mode 100644 index 00000000000..6bb062ba657 --- /dev/null +++ b/src/test/ui/panic-handler/panic-handler-missing.rs @@ -0,0 +1,9 @@ +// dont-check-compiler-stderr +// error-pattern: `#[panic_handler]` function required, but not found + +#![feature(lang_items)] +#![no_main] +#![no_std] + +#[lang = "eh_personality"] +fn eh() {} diff --git a/src/test/ui/panic-handler/panic-handler-twice.rs b/src/test/ui/panic-handler/panic-handler-twice.rs new file mode 100644 index 00000000000..05bef66d849 --- /dev/null +++ b/src/test/ui/panic-handler/panic-handler-twice.rs @@ -0,0 +1,19 @@ +// dont-check-compiler-stderr +// aux-build:some-panic-impl.rs + +#![feature(lang_items)] +#![no_std] +#![no_main] + +extern crate some_panic_impl; + +use core::panic::PanicInfo; + +#[panic_handler] +fn panic(info: &PanicInfo) -> ! { + //~^ ERROR found duplicate lang item `panic_impl` + loop {} +} + +#[lang = "eh_personality"] +fn eh() {} diff --git a/src/test/ui/panic-handler/weak-lang-item.rs b/src/test/ui/panic-handler/weak-lang-item.rs new file mode 100644 index 00000000000..3fa3822831b --- /dev/null +++ b/src/test/ui/panic-handler/weak-lang-item.rs @@ -0,0 +1,11 @@ +// aux-build:weak-lang-items.rs +// error-pattern: `#[panic_handler]` function required, but not found +// error-pattern: language item required, but not found: `eh_personality` +// ignore-emscripten compiled with panic=abort, personality not required + +#![no_std] + +extern crate core; +extern crate weak_lang_items; + +fn main() {} diff --git a/src/test/ui/panic-handler/weak-lang-item.stderr b/src/test/ui/panic-handler/weak-lang-item.stderr new file mode 100644 index 00000000000..b7c040c7a85 --- /dev/null +++ b/src/test/ui/panic-handler/weak-lang-item.stderr @@ -0,0 +1,19 @@ +error[E0259]: the name `core` is defined multiple times + --> $DIR/weak-lang-item.rs:8:1 + | +LL | extern crate core; + | ^^^^^^^^^^^^^^^^^^ `core` reimported here + | + = note: `core` must be defined only once in the type namespace of this module +help: you can use `as` to change the binding name of the import + | +LL | extern crate core as other_core; + | + +error: `#[panic_handler]` function required, but not found + +error: language item required, but not found: `eh_personality` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0259`. |
