From 64d98f8ee037282c35007b64c2649055c56af1db Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:03 +0200 Subject: Merging upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- .../ui/panic-runtime/abort-link-to-unwind-dylib.rs | 18 +++++++++ .../abort-link-to-unwind-dylib.stderr | 4 ++ .../abort-link-to-unwinding-crates.rs | 40 ++++++++++++++++++++ tests/ui/panic-runtime/abort.rs | 43 ++++++++++++++++++++++ tests/ui/panic-runtime/auxiliary/depends.rs | 8 ++++ .../auxiliary/exit-success-if-unwind.rs | 16 ++++++++ tests/ui/panic-runtime/auxiliary/needs-abort.rs | 5 +++ .../panic-runtime/auxiliary/needs-panic-runtime.rs | 6 +++ tests/ui/panic-runtime/auxiliary/needs-unwind.rs | 13 +++++++ .../panic-runtime/auxiliary/panic-runtime-abort.rs | 17 +++++++++ .../auxiliary/panic-runtime-lang-items.rs | 15 ++++++++ .../auxiliary/panic-runtime-unwind.rs | 17 +++++++++ .../auxiliary/panic-runtime-unwind2.rs | 17 +++++++++ .../auxiliary/wants-panic-runtime-abort.rs | 7 ++++ .../auxiliary/wants-panic-runtime-unwind.rs | 6 +++ tests/ui/panic-runtime/bad-panic-flag1.rs | 4 ++ tests/ui/panic-runtime/bad-panic-flag1.stderr | 2 + tests/ui/panic-runtime/bad-panic-flag2.rs | 4 ++ tests/ui/panic-runtime/bad-panic-flag2.stderr | 2 + tests/ui/panic-runtime/incompatible-type.rs | 24 ++++++++++++ tests/ui/panic-runtime/link-to-abort.rs | 11 ++++++ tests/ui/panic-runtime/link-to-unwind.rs | 10 +++++ tests/ui/panic-runtime/lto-abort.rs | 33 +++++++++++++++++ tests/ui/panic-runtime/lto-unwind.rs | 37 +++++++++++++++++++ tests/ui/panic-runtime/need-abort-got-unwind.rs | 8 ++++ .../ui/panic-runtime/need-abort-got-unwind.stderr | 4 ++ tests/ui/panic-runtime/need-unwind-got-abort.rs | 9 +++++ .../ui/panic-runtime/need-unwind-got-abort.stderr | 4 ++ tests/ui/panic-runtime/needs-gate.rs | 7 ++++ tests/ui/panic-runtime/needs-gate.stderr | 21 +++++++++++ .../runtime-depend-on-needs-runtime.rs | 8 ++++ tests/ui/panic-runtime/transitive-link-a-bunch.rs | 15 ++++++++ .../panic-runtime/transitive-link-a-bunch.stderr | 8 ++++ tests/ui/panic-runtime/two-panic-runtimes.rs | 15 ++++++++ tests/ui/panic-runtime/unwind-interleaved.rs | 16 ++++++++ tests/ui/panic-runtime/unwind-rec.rs | 15 ++++++++ tests/ui/panic-runtime/unwind-rec2.rs | 23 ++++++++++++ .../panic-runtime/unwind-tables-target-required.rs | 10 +++++ tests/ui/panic-runtime/unwind-unique.rs | 12 ++++++ tests/ui/panic-runtime/want-abort-got-unwind.rs | 9 +++++ tests/ui/panic-runtime/want-abort-got-unwind2.rs | 10 +++++ tests/ui/panic-runtime/want-unwind-got-abort.rs | 11 ++++++ .../ui/panic-runtime/want-unwind-got-abort.stderr | 4 ++ tests/ui/panic-runtime/want-unwind-got-abort2.rs | 12 ++++++ .../ui/panic-runtime/want-unwind-got-abort2.stderr | 6 +++ 45 files changed, 586 insertions(+) create mode 100644 tests/ui/panic-runtime/abort-link-to-unwind-dylib.rs create mode 100644 tests/ui/panic-runtime/abort-link-to-unwind-dylib.stderr create mode 100644 tests/ui/panic-runtime/abort-link-to-unwinding-crates.rs create mode 100644 tests/ui/panic-runtime/abort.rs create mode 100644 tests/ui/panic-runtime/auxiliary/depends.rs create mode 100644 tests/ui/panic-runtime/auxiliary/exit-success-if-unwind.rs create mode 100644 tests/ui/panic-runtime/auxiliary/needs-abort.rs create mode 100644 tests/ui/panic-runtime/auxiliary/needs-panic-runtime.rs create mode 100644 tests/ui/panic-runtime/auxiliary/needs-unwind.rs create mode 100644 tests/ui/panic-runtime/auxiliary/panic-runtime-abort.rs create mode 100644 tests/ui/panic-runtime/auxiliary/panic-runtime-lang-items.rs create mode 100644 tests/ui/panic-runtime/auxiliary/panic-runtime-unwind.rs create mode 100644 tests/ui/panic-runtime/auxiliary/panic-runtime-unwind2.rs create mode 100644 tests/ui/panic-runtime/auxiliary/wants-panic-runtime-abort.rs create mode 100644 tests/ui/panic-runtime/auxiliary/wants-panic-runtime-unwind.rs create mode 100644 tests/ui/panic-runtime/bad-panic-flag1.rs create mode 100644 tests/ui/panic-runtime/bad-panic-flag1.stderr create mode 100644 tests/ui/panic-runtime/bad-panic-flag2.rs create mode 100644 tests/ui/panic-runtime/bad-panic-flag2.stderr create mode 100644 tests/ui/panic-runtime/incompatible-type.rs create mode 100644 tests/ui/panic-runtime/link-to-abort.rs create mode 100644 tests/ui/panic-runtime/link-to-unwind.rs create mode 100644 tests/ui/panic-runtime/lto-abort.rs create mode 100644 tests/ui/panic-runtime/lto-unwind.rs create mode 100644 tests/ui/panic-runtime/need-abort-got-unwind.rs create mode 100644 tests/ui/panic-runtime/need-abort-got-unwind.stderr create mode 100644 tests/ui/panic-runtime/need-unwind-got-abort.rs create mode 100644 tests/ui/panic-runtime/need-unwind-got-abort.stderr create mode 100644 tests/ui/panic-runtime/needs-gate.rs create mode 100644 tests/ui/panic-runtime/needs-gate.stderr create mode 100644 tests/ui/panic-runtime/runtime-depend-on-needs-runtime.rs create mode 100644 tests/ui/panic-runtime/transitive-link-a-bunch.rs create mode 100644 tests/ui/panic-runtime/transitive-link-a-bunch.stderr create mode 100644 tests/ui/panic-runtime/two-panic-runtimes.rs create mode 100644 tests/ui/panic-runtime/unwind-interleaved.rs create mode 100644 tests/ui/panic-runtime/unwind-rec.rs create mode 100644 tests/ui/panic-runtime/unwind-rec2.rs create mode 100644 tests/ui/panic-runtime/unwind-tables-target-required.rs create mode 100644 tests/ui/panic-runtime/unwind-unique.rs create mode 100644 tests/ui/panic-runtime/want-abort-got-unwind.rs create mode 100644 tests/ui/panic-runtime/want-abort-got-unwind2.rs create mode 100644 tests/ui/panic-runtime/want-unwind-got-abort.rs create mode 100644 tests/ui/panic-runtime/want-unwind-got-abort.stderr create mode 100644 tests/ui/panic-runtime/want-unwind-got-abort2.rs create mode 100644 tests/ui/panic-runtime/want-unwind-got-abort2.stderr (limited to 'tests/ui/panic-runtime') diff --git a/tests/ui/panic-runtime/abort-link-to-unwind-dylib.rs b/tests/ui/panic-runtime/abort-link-to-unwind-dylib.rs new file mode 100644 index 000000000..58a90a592 --- /dev/null +++ b/tests/ui/panic-runtime/abort-link-to-unwind-dylib.rs @@ -0,0 +1,18 @@ +// build-fail +// compile-flags:-C panic=abort -C prefer-dynamic +// needs-unwind +// ignore-musl - no dylibs here +// ignore-emscripten +// ignore-sgx no dynamic lib support +// error-pattern:`panic_unwind` is not compiled with this crate's panic strategy + +// This is a test where the local crate, compiled with `panic=abort`, links to +// the standard library **dynamically** which is already linked against +// `panic=unwind`. We should fail because the linked panic runtime does not +// correspond with our `-C panic` option. +// +// Note that this test assumes that the dynamic version of the standard library +// is linked to `panic_unwind`, which is currently the case. + +fn main() { +} diff --git a/tests/ui/panic-runtime/abort-link-to-unwind-dylib.stderr b/tests/ui/panic-runtime/abort-link-to-unwind-dylib.stderr new file mode 100644 index 000000000..704b81ae1 --- /dev/null +++ b/tests/ui/panic-runtime/abort-link-to-unwind-dylib.stderr @@ -0,0 +1,4 @@ +error: the linked panic runtime `panic_unwind` is not compiled with this crate's panic strategy `abort` + +error: aborting due to previous error + diff --git a/tests/ui/panic-runtime/abort-link-to-unwinding-crates.rs b/tests/ui/panic-runtime/abort-link-to-unwinding-crates.rs new file mode 100644 index 000000000..566626513 --- /dev/null +++ b/tests/ui/panic-runtime/abort-link-to-unwinding-crates.rs @@ -0,0 +1,40 @@ +// run-pass +#![allow(unused_variables)] +// compile-flags:-C panic=abort +// aux-build:exit-success-if-unwind.rs +// no-prefer-dynamic +// ignore-emscripten no processes +// ignore-sgx no processes +// ignore-macos + +extern crate exit_success_if_unwind; + +use std::process::Command; +use std::env; + +fn main() { + let mut args = env::args_os(); + let me = args.next().unwrap(); + + if let Some(s) = args.next() { + if &*s == "foo" { + exit_success_if_unwind::bar(do_panic); + } + } + + let mut cmd = Command::new(env::args_os().next().unwrap()); + cmd.arg("foo"); + + + // ARMv6 hanges while printing the backtrace, see #41004 + if cfg!(target_arch = "arm") && cfg!(target_env = "gnu") { + cmd.env("RUST_BACKTRACE", "0"); + } + + let s = cmd.status(); + assert!(s.unwrap().code() != Some(0)); +} + +fn do_panic() { + panic!("try to catch me"); +} diff --git a/tests/ui/panic-runtime/abort.rs b/tests/ui/panic-runtime/abort.rs new file mode 100644 index 000000000..dcc4061fd --- /dev/null +++ b/tests/ui/panic-runtime/abort.rs @@ -0,0 +1,43 @@ +// run-pass +#![allow(unused_variables)] +// compile-flags:-C panic=abort +// no-prefer-dynamic +// ignore-emscripten no processes +// ignore-sgx no processes +// ignore-macos + +use std::process::Command; +use std::env; + +struct Bomb; + +impl Drop for Bomb { + fn drop(&mut self) { + std::process::exit(0); + } +} + +fn main() { + let mut args = env::args_os(); + let me = args.next().unwrap(); + + if let Some(s) = args.next() { + if &*s == "foo" { + + let _bomb = Bomb; + + panic!("try to catch me"); + } + } + + let mut cmd = Command::new(env::args_os().next().unwrap()); + cmd.arg("foo"); + + // ARMv6 hanges while printing the backtrace, see #41004 + if cfg!(target_arch = "arm") && cfg!(target_env = "gnu") { + cmd.env("RUST_BACKTRACE", "0"); + } + + let s = cmd.status(); + assert!(s.unwrap().code() != Some(0)); +} diff --git a/tests/ui/panic-runtime/auxiliary/depends.rs b/tests/ui/panic-runtime/auxiliary/depends.rs new file mode 100644 index 000000000..e9bc2f489 --- /dev/null +++ b/tests/ui/panic-runtime/auxiliary/depends.rs @@ -0,0 +1,8 @@ +// no-prefer-dynamic + +#![feature(panic_runtime)] +#![crate_type = "rlib"] +#![panic_runtime] +#![no_std] + +extern crate needs_panic_runtime; diff --git a/tests/ui/panic-runtime/auxiliary/exit-success-if-unwind.rs b/tests/ui/panic-runtime/auxiliary/exit-success-if-unwind.rs new file mode 100644 index 000000000..c0e057405 --- /dev/null +++ b/tests/ui/panic-runtime/auxiliary/exit-success-if-unwind.rs @@ -0,0 +1,16 @@ +// no-prefer-dynamic + +#![crate_type = "rlib"] + +struct Bomb; + +impl Drop for Bomb { + fn drop(&mut self) { + std::process::exit(0); + } +} + +pub fn bar(f: fn()) { + let _bomb = Bomb; + f(); +} diff --git a/tests/ui/panic-runtime/auxiliary/needs-abort.rs b/tests/ui/panic-runtime/auxiliary/needs-abort.rs new file mode 100644 index 000000000..8fad49b5e --- /dev/null +++ b/tests/ui/panic-runtime/auxiliary/needs-abort.rs @@ -0,0 +1,5 @@ +// compile-flags:-C panic=abort +// no-prefer-dynamic + +#![crate_type = "rlib"] +#![no_std] diff --git a/tests/ui/panic-runtime/auxiliary/needs-panic-runtime.rs b/tests/ui/panic-runtime/auxiliary/needs-panic-runtime.rs new file mode 100644 index 000000000..3f030c169 --- /dev/null +++ b/tests/ui/panic-runtime/auxiliary/needs-panic-runtime.rs @@ -0,0 +1,6 @@ +// no-prefer-dynamic + +#![feature(needs_panic_runtime)] +#![crate_type = "rlib"] +#![needs_panic_runtime] +#![no_std] diff --git a/tests/ui/panic-runtime/auxiliary/needs-unwind.rs b/tests/ui/panic-runtime/auxiliary/needs-unwind.rs new file mode 100644 index 000000000..d555b5319 --- /dev/null +++ b/tests/ui/panic-runtime/auxiliary/needs-unwind.rs @@ -0,0 +1,13 @@ +// compile-flags:-C panic=unwind +// no-prefer-dynamic + +#![crate_type = "rlib"] +#![no_std] +#![feature(c_unwind)] + +extern "C-unwind" fn foo() {} + +fn bar() { + let ptr: extern "C-unwind" fn() = foo; + ptr(); +} diff --git a/tests/ui/panic-runtime/auxiliary/panic-runtime-abort.rs b/tests/ui/panic-runtime/auxiliary/panic-runtime-abort.rs new file mode 100644 index 000000000..c92015eee --- /dev/null +++ b/tests/ui/panic-runtime/auxiliary/panic-runtime-abort.rs @@ -0,0 +1,17 @@ +// compile-flags:-C panic=abort +// no-prefer-dynamic + +#![feature(panic_runtime)] +#![crate_type = "rlib"] + +#![no_std] +#![panic_runtime] + +#[no_mangle] +pub extern "C" fn __rust_maybe_catch_panic() {} + +#[no_mangle] +pub extern "C" fn __rust_start_panic() {} + +#[no_mangle] +pub extern "C" fn rust_eh_personality() {} diff --git a/tests/ui/panic-runtime/auxiliary/panic-runtime-lang-items.rs b/tests/ui/panic-runtime/auxiliary/panic-runtime-lang-items.rs new file mode 100644 index 000000000..b9ef2f329 --- /dev/null +++ b/tests/ui/panic-runtime/auxiliary/panic-runtime-lang-items.rs @@ -0,0 +1,15 @@ +// no-prefer-dynamic + +#![crate_type = "rlib"] + +#![no_std] +#![feature(lang_items)] + +use core::panic::PanicInfo; + +#[lang = "panic_impl"] +fn panic_impl(info: &PanicInfo) -> ! { loop {} } +#[lang = "eh_personality"] +fn eh_personality() {} +#[lang = "eh_catch_typeinfo"] +static EH_CATCH_TYPEINFO: u8 = 0; diff --git a/tests/ui/panic-runtime/auxiliary/panic-runtime-unwind.rs b/tests/ui/panic-runtime/auxiliary/panic-runtime-unwind.rs new file mode 100644 index 000000000..2f7aed924 --- /dev/null +++ b/tests/ui/panic-runtime/auxiliary/panic-runtime-unwind.rs @@ -0,0 +1,17 @@ +// compile-flags:-C panic=unwind +// no-prefer-dynamic + +#![feature(panic_runtime)] +#![crate_type = "rlib"] + +#![no_std] +#![panic_runtime] + +#[no_mangle] +pub extern "C" fn __rust_maybe_catch_panic() {} + +#[no_mangle] +pub extern "C" fn __rust_start_panic() {} + +#[no_mangle] +pub extern "C" fn rust_eh_personality() {} diff --git a/tests/ui/panic-runtime/auxiliary/panic-runtime-unwind2.rs b/tests/ui/panic-runtime/auxiliary/panic-runtime-unwind2.rs new file mode 100644 index 000000000..2f7aed924 --- /dev/null +++ b/tests/ui/panic-runtime/auxiliary/panic-runtime-unwind2.rs @@ -0,0 +1,17 @@ +// compile-flags:-C panic=unwind +// no-prefer-dynamic + +#![feature(panic_runtime)] +#![crate_type = "rlib"] + +#![no_std] +#![panic_runtime] + +#[no_mangle] +pub extern "C" fn __rust_maybe_catch_panic() {} + +#[no_mangle] +pub extern "C" fn __rust_start_panic() {} + +#[no_mangle] +pub extern "C" fn rust_eh_personality() {} diff --git a/tests/ui/panic-runtime/auxiliary/wants-panic-runtime-abort.rs b/tests/ui/panic-runtime/auxiliary/wants-panic-runtime-abort.rs new file mode 100644 index 000000000..3c0d2d658 --- /dev/null +++ b/tests/ui/panic-runtime/auxiliary/wants-panic-runtime-abort.rs @@ -0,0 +1,7 @@ +// compile-flags:-C panic=abort +// no-prefer-dynamic + +#![crate_type = "rlib"] +#![no_std] + +extern crate panic_runtime_abort; diff --git a/tests/ui/panic-runtime/auxiliary/wants-panic-runtime-unwind.rs b/tests/ui/panic-runtime/auxiliary/wants-panic-runtime-unwind.rs new file mode 100644 index 000000000..d5f010219 --- /dev/null +++ b/tests/ui/panic-runtime/auxiliary/wants-panic-runtime-unwind.rs @@ -0,0 +1,6 @@ +// no-prefer-dynamic + +#![crate_type = "rlib"] +#![no_std] + +extern crate panic_runtime_unwind; diff --git a/tests/ui/panic-runtime/bad-panic-flag1.rs b/tests/ui/panic-runtime/bad-panic-flag1.rs new file mode 100644 index 000000000..1ac6a3423 --- /dev/null +++ b/tests/ui/panic-runtime/bad-panic-flag1.rs @@ -0,0 +1,4 @@ +// compile-flags:-C panic=foo +// error-pattern:either `unwind` or `abort` was expected + +fn main() {} diff --git a/tests/ui/panic-runtime/bad-panic-flag1.stderr b/tests/ui/panic-runtime/bad-panic-flag1.stderr new file mode 100644 index 000000000..013373c6f --- /dev/null +++ b/tests/ui/panic-runtime/bad-panic-flag1.stderr @@ -0,0 +1,2 @@ +error: incorrect value `foo` for codegen option `panic` - either `unwind` or `abort` was expected + diff --git a/tests/ui/panic-runtime/bad-panic-flag2.rs b/tests/ui/panic-runtime/bad-panic-flag2.rs new file mode 100644 index 000000000..c79701c83 --- /dev/null +++ b/tests/ui/panic-runtime/bad-panic-flag2.rs @@ -0,0 +1,4 @@ +// compile-flags:-C panic +// error-pattern:requires either `unwind` or `abort` + +fn main() {} diff --git a/tests/ui/panic-runtime/bad-panic-flag2.stderr b/tests/ui/panic-runtime/bad-panic-flag2.stderr new file mode 100644 index 000000000..6ab94ea70 --- /dev/null +++ b/tests/ui/panic-runtime/bad-panic-flag2.stderr @@ -0,0 +1,2 @@ +error: codegen option `panic` requires either `unwind` or `abort` (C panic=) + diff --git a/tests/ui/panic-runtime/incompatible-type.rs b/tests/ui/panic-runtime/incompatible-type.rs new file mode 100644 index 000000000..026364a20 --- /dev/null +++ b/tests/ui/panic-runtime/incompatible-type.rs @@ -0,0 +1,24 @@ +// Check that rust_eh_personality can have a different type signature than the +// one hardcoded in the compiler. Regression test for #70117. Used to fail with: +// +// Assertion `isa(Val) && "cast() argument of incompatible type!"' failed. +// +// build-pass +// compile-flags: --crate-type=lib -Ccodegen-units=1 +#![no_std] +#![panic_runtime] +#![feature(panic_runtime)] +#![feature(rustc_attrs)] + +pub struct DropMe; + +impl Drop for DropMe { + fn drop(&mut self) {} +} + +pub fn test(_: DropMe) { + unreachable!(); +} + +#[rustc_std_internal_symbol] +pub unsafe extern "C" fn rust_eh_personality() {} diff --git a/tests/ui/panic-runtime/link-to-abort.rs b/tests/ui/panic-runtime/link-to-abort.rs new file mode 100644 index 000000000..422206c57 --- /dev/null +++ b/tests/ui/panic-runtime/link-to-abort.rs @@ -0,0 +1,11 @@ +// run-pass + +// compile-flags:-C panic=abort +// no-prefer-dynamic +// ignore-macos + +#![feature(panic_abort)] + +extern crate panic_abort; + +fn main() {} diff --git a/tests/ui/panic-runtime/link-to-unwind.rs b/tests/ui/panic-runtime/link-to-unwind.rs new file mode 100644 index 000000000..59036ca99 --- /dev/null +++ b/tests/ui/panic-runtime/link-to-unwind.rs @@ -0,0 +1,10 @@ +// run-pass + +// no-prefer-dynamic + +#![feature(panic_unwind)] + +extern crate panic_unwind; + +fn main() { +} diff --git a/tests/ui/panic-runtime/lto-abort.rs b/tests/ui/panic-runtime/lto-abort.rs new file mode 100644 index 000000000..5cc4c0132 --- /dev/null +++ b/tests/ui/panic-runtime/lto-abort.rs @@ -0,0 +1,33 @@ +// run-pass +#![allow(unused_variables)] +// compile-flags:-C lto -C panic=abort +// no-prefer-dynamic +// ignore-emscripten no processes +// ignore-sgx no processes + +use std::process::Command; +use std::env; + +struct Bomb; + +impl Drop for Bomb { + fn drop(&mut self) { + std::process::exit(0); + } +} + +fn main() { + let mut args = env::args_os(); + let me = args.next().unwrap(); + + if let Some(s) = args.next() { + if &*s == "foo" { + + let _bomb = Bomb; + + panic!("try to catch me"); + } + } + let s = Command::new(env::args_os().next().unwrap()).arg("foo").status(); + assert!(s.unwrap().code() != Some(0)); +} diff --git a/tests/ui/panic-runtime/lto-unwind.rs b/tests/ui/panic-runtime/lto-unwind.rs new file mode 100644 index 000000000..24048ebe0 --- /dev/null +++ b/tests/ui/panic-runtime/lto-unwind.rs @@ -0,0 +1,37 @@ +// run-pass +#![allow(unused_variables)] + +// compile-flags:-C lto -C panic=unwind +// needs-unwind +// no-prefer-dynamic +// ignore-emscripten no processes +// ignore-sgx no processes + +use std::process::Command; +use std::env; + +struct Bomb; + +impl Drop for Bomb { + fn drop(&mut self) { + println!("hurray you ran me"); + } +} + +fn main() { + let mut args = env::args_os(); + let me = args.next().unwrap(); + + if let Some(s) = args.next() { + if &*s == "foo" { + + let _bomb = Bomb; + + panic!("try to catch me"); + } + } + let s = Command::new(env::args_os().next().unwrap()).arg("foo").output(); + let s = s.unwrap(); + assert!(!s.status.success()); + assert!(String::from_utf8_lossy(&s.stdout).contains("hurray you ran me")); +} diff --git a/tests/ui/panic-runtime/need-abort-got-unwind.rs b/tests/ui/panic-runtime/need-abort-got-unwind.rs new file mode 100644 index 000000000..e92400931 --- /dev/null +++ b/tests/ui/panic-runtime/need-abort-got-unwind.rs @@ -0,0 +1,8 @@ +// build-fail +// needs-unwind +// error-pattern:is incompatible with this crate's strategy of `unwind` +// aux-build:needs-abort.rs + +extern crate needs_abort; + +fn main() {} diff --git a/tests/ui/panic-runtime/need-abort-got-unwind.stderr b/tests/ui/panic-runtime/need-abort-got-unwind.stderr new file mode 100644 index 000000000..d29c7875f --- /dev/null +++ b/tests/ui/panic-runtime/need-abort-got-unwind.stderr @@ -0,0 +1,4 @@ +error: the crate `needs_abort` requires panic strategy `abort` which is incompatible with this crate's strategy of `unwind` + +error: aborting due to previous error + diff --git a/tests/ui/panic-runtime/need-unwind-got-abort.rs b/tests/ui/panic-runtime/need-unwind-got-abort.rs new file mode 100644 index 000000000..6752ecf90 --- /dev/null +++ b/tests/ui/panic-runtime/need-unwind-got-abort.rs @@ -0,0 +1,9 @@ +// build-fail +// error-pattern:is incompatible with this crate's strategy of `abort` +// aux-build:needs-unwind.rs +// compile-flags:-C panic=abort +// no-prefer-dynamic + +extern crate needs_unwind; + +fn main() {} diff --git a/tests/ui/panic-runtime/need-unwind-got-abort.stderr b/tests/ui/panic-runtime/need-unwind-got-abort.stderr new file mode 100644 index 000000000..4c71df3eb --- /dev/null +++ b/tests/ui/panic-runtime/need-unwind-got-abort.stderr @@ -0,0 +1,4 @@ +error: the crate `needs_unwind` requires panic strategy `unwind` which is incompatible with this crate's strategy of `abort` + +error: aborting due to previous error + diff --git a/tests/ui/panic-runtime/needs-gate.rs b/tests/ui/panic-runtime/needs-gate.rs new file mode 100644 index 000000000..9e143adfe --- /dev/null +++ b/tests/ui/panic-runtime/needs-gate.rs @@ -0,0 +1,7 @@ +// gate-test-needs_panic_runtime +// gate-test-panic_runtime + +#![panic_runtime] //~ ERROR: is an experimental feature +#![needs_panic_runtime] //~ ERROR: is an experimental feature + +fn main() {} diff --git a/tests/ui/panic-runtime/needs-gate.stderr b/tests/ui/panic-runtime/needs-gate.stderr new file mode 100644 index 000000000..e067ccaeb --- /dev/null +++ b/tests/ui/panic-runtime/needs-gate.stderr @@ -0,0 +1,21 @@ +error[E0658]: the `#[panic_runtime]` attribute is an experimental feature + --> $DIR/needs-gate.rs:4:1 + | +LL | #![panic_runtime] + | ^^^^^^^^^^^^^^^^^ + | + = note: see issue #32837 for more information + = help: add `#![feature(panic_runtime)]` to the crate attributes to enable + +error[E0658]: the `#[needs_panic_runtime]` attribute is an experimental feature + --> $DIR/needs-gate.rs:5:1 + | +LL | #![needs_panic_runtime] + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #32837 for more information + = help: add `#![feature(needs_panic_runtime)]` to the crate attributes to enable + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/panic-runtime/runtime-depend-on-needs-runtime.rs b/tests/ui/panic-runtime/runtime-depend-on-needs-runtime.rs new file mode 100644 index 000000000..d57f1643e --- /dev/null +++ b/tests/ui/panic-runtime/runtime-depend-on-needs-runtime.rs @@ -0,0 +1,8 @@ +// dont-check-compiler-stderr +// aux-build:needs-panic-runtime.rs +// aux-build:depends.rs +// error-pattern:cannot depend on a crate that needs a panic runtime + +extern crate depends; + +fn main() {} diff --git a/tests/ui/panic-runtime/transitive-link-a-bunch.rs b/tests/ui/panic-runtime/transitive-link-a-bunch.rs new file mode 100644 index 000000000..0e74e300f --- /dev/null +++ b/tests/ui/panic-runtime/transitive-link-a-bunch.rs @@ -0,0 +1,15 @@ +// build-fail +// needs-unwind +// aux-build:panic-runtime-unwind.rs +// aux-build:panic-runtime-abort.rs +// aux-build:wants-panic-runtime-unwind.rs +// aux-build:wants-panic-runtime-abort.rs +// aux-build:panic-runtime-lang-items.rs +// error-pattern: is not compiled with this crate's panic strategy `unwind` + +#![no_std] +#![no_main] + +extern crate wants_panic_runtime_unwind; +extern crate wants_panic_runtime_abort; +extern crate panic_runtime_lang_items; diff --git a/tests/ui/panic-runtime/transitive-link-a-bunch.stderr b/tests/ui/panic-runtime/transitive-link-a-bunch.stderr new file mode 100644 index 000000000..7f4a8ed29 --- /dev/null +++ b/tests/ui/panic-runtime/transitive-link-a-bunch.stderr @@ -0,0 +1,8 @@ +error: cannot link together two panic runtimes: panic_runtime_unwind and panic_runtime_abort + +error: the linked panic runtime `panic_runtime_abort` is not compiled with this crate's panic strategy `unwind` + +error: the crate `wants_panic_runtime_abort` requires panic strategy `abort` which is incompatible with this crate's strategy of `unwind` + +error: aborting due to 3 previous errors + diff --git a/tests/ui/panic-runtime/two-panic-runtimes.rs b/tests/ui/panic-runtime/two-panic-runtimes.rs new file mode 100644 index 000000000..7ec658ebc --- /dev/null +++ b/tests/ui/panic-runtime/two-panic-runtimes.rs @@ -0,0 +1,15 @@ +// build-fail +// dont-check-compiler-stderr +// error-pattern:cannot link together two panic runtimes: panic_runtime_unwind and panic_runtime_unwind2 +// aux-build:panic-runtime-unwind.rs +// aux-build:panic-runtime-unwind2.rs +// aux-build:panic-runtime-lang-items.rs + +#![no_std] +#![no_main] + +extern crate panic_runtime_unwind; +extern crate panic_runtime_unwind2; +extern crate panic_runtime_lang_items; + +fn main() {} diff --git a/tests/ui/panic-runtime/unwind-interleaved.rs b/tests/ui/panic-runtime/unwind-interleaved.rs new file mode 100644 index 000000000..a8b3f3493 --- /dev/null +++ b/tests/ui/panic-runtime/unwind-interleaved.rs @@ -0,0 +1,16 @@ +// run-fail +// error-pattern:explicit panic +// ignore-emscripten no processes + +fn a() {} + +fn b() { + panic!(); +} + +fn main() { + let _x = vec![0]; + a(); + let _y = vec![0]; + b(); +} diff --git a/tests/ui/panic-runtime/unwind-rec.rs b/tests/ui/panic-runtime/unwind-rec.rs new file mode 100644 index 000000000..a9b7ee8ec --- /dev/null +++ b/tests/ui/panic-runtime/unwind-rec.rs @@ -0,0 +1,15 @@ +// run-fail +// error-pattern:explicit panic +// ignore-emscripten no processes + +fn build() -> Vec { + panic!(); +} + +struct Blk { + node: Vec, +} + +fn main() { + let _blk = Blk { node: build() }; +} diff --git a/tests/ui/panic-runtime/unwind-rec2.rs b/tests/ui/panic-runtime/unwind-rec2.rs new file mode 100644 index 000000000..a130f9e87 --- /dev/null +++ b/tests/ui/panic-runtime/unwind-rec2.rs @@ -0,0 +1,23 @@ +// run-fail +// error-pattern:explicit panic +// ignore-emscripten no processes + +fn build1() -> Vec { + vec![0, 0, 0, 0, 0, 0, 0] +} + +fn build2() -> Vec { + panic!(); +} + +struct Blk { + node: Vec, + span: Vec, +} + +fn main() { + let _blk = Blk { + node: build1(), + span: build2(), + }; +} diff --git a/tests/ui/panic-runtime/unwind-tables-target-required.rs b/tests/ui/panic-runtime/unwind-tables-target-required.rs new file mode 100644 index 000000000..3abb52b67 --- /dev/null +++ b/tests/ui/panic-runtime/unwind-tables-target-required.rs @@ -0,0 +1,10 @@ +// Tests that the compiler errors if the user tries to turn off unwind tables +// when they are required. +// +// only-x86_64-windows-msvc +// compile-flags: -C force-unwind-tables=no +// +// error-pattern: target requires unwind tables, they cannot be disabled with `-C force-unwind-tables=no`. + +pub fn main() { +} diff --git a/tests/ui/panic-runtime/unwind-unique.rs b/tests/ui/panic-runtime/unwind-unique.rs new file mode 100644 index 000000000..d66e39110 --- /dev/null +++ b/tests/ui/panic-runtime/unwind-unique.rs @@ -0,0 +1,12 @@ +// run-fail +// error-pattern:explicit panic +// ignore-emscripten no processes + +fn failfn() { + panic!(); +} + +fn main() { + Box::new(0); + failfn(); +} diff --git a/tests/ui/panic-runtime/want-abort-got-unwind.rs b/tests/ui/panic-runtime/want-abort-got-unwind.rs new file mode 100644 index 000000000..e33c3bcc3 --- /dev/null +++ b/tests/ui/panic-runtime/want-abort-got-unwind.rs @@ -0,0 +1,9 @@ +// build-fail +// dont-check-compiler-stderr +// error-pattern:is not compiled with this crate's panic strategy `abort` +// aux-build:panic-runtime-unwind.rs +// compile-flags:-C panic=abort + +extern crate panic_runtime_unwind; + +fn main() {} diff --git a/tests/ui/panic-runtime/want-abort-got-unwind2.rs b/tests/ui/panic-runtime/want-abort-got-unwind2.rs new file mode 100644 index 000000000..438f1d85a --- /dev/null +++ b/tests/ui/panic-runtime/want-abort-got-unwind2.rs @@ -0,0 +1,10 @@ +// build-fail +// dont-check-compiler-stderr +// error-pattern:is not compiled with this crate's panic strategy `abort` +// aux-build:panic-runtime-unwind.rs +// aux-build:wants-panic-runtime-unwind.rs +// compile-flags:-C panic=abort + +extern crate wants_panic_runtime_unwind; + +fn main() {} diff --git a/tests/ui/panic-runtime/want-unwind-got-abort.rs b/tests/ui/panic-runtime/want-unwind-got-abort.rs new file mode 100644 index 000000000..b6174dc4e --- /dev/null +++ b/tests/ui/panic-runtime/want-unwind-got-abort.rs @@ -0,0 +1,11 @@ +// build-fail +// needs-unwind +// error-pattern:is not compiled with this crate's panic strategy `unwind` +// aux-build:panic-runtime-abort.rs +// aux-build:panic-runtime-lang-items.rs + +#![no_std] +#![no_main] + +extern crate panic_runtime_abort; +extern crate panic_runtime_lang_items; diff --git a/tests/ui/panic-runtime/want-unwind-got-abort.stderr b/tests/ui/panic-runtime/want-unwind-got-abort.stderr new file mode 100644 index 000000000..d306ce6c5 --- /dev/null +++ b/tests/ui/panic-runtime/want-unwind-got-abort.stderr @@ -0,0 +1,4 @@ +error: the linked panic runtime `panic_runtime_abort` is not compiled with this crate's panic strategy `unwind` + +error: aborting due to previous error + diff --git a/tests/ui/panic-runtime/want-unwind-got-abort2.rs b/tests/ui/panic-runtime/want-unwind-got-abort2.rs new file mode 100644 index 000000000..b54babbef --- /dev/null +++ b/tests/ui/panic-runtime/want-unwind-got-abort2.rs @@ -0,0 +1,12 @@ +// build-fail +// needs-unwind +// error-pattern:is incompatible with this crate's strategy of `unwind` +// aux-build:panic-runtime-abort.rs +// aux-build:wants-panic-runtime-abort.rs +// aux-build:panic-runtime-lang-items.rs + +#![no_std] +#![no_main] + +extern crate wants_panic_runtime_abort; +extern crate panic_runtime_lang_items; diff --git a/tests/ui/panic-runtime/want-unwind-got-abort2.stderr b/tests/ui/panic-runtime/want-unwind-got-abort2.stderr new file mode 100644 index 000000000..014437b7f --- /dev/null +++ b/tests/ui/panic-runtime/want-unwind-got-abort2.stderr @@ -0,0 +1,6 @@ +error: the linked panic runtime `panic_runtime_abort` is not compiled with this crate's panic strategy `unwind` + +error: the crate `wants_panic_runtime_abort` requires panic strategy `abort` which is incompatible with this crate's strategy of `unwind` + +error: aborting due to 2 previous errors + -- cgit v1.2.3