diff options
| author | Jorge Aparicio <jorge@japaric.io> | 2018-05-29 12:33:11 +0200 |
|---|---|---|
| committer | Jorge Aparicio <jorge@japaric.io> | 2018-06-03 13:46:20 +0200 |
| commit | a174f2ab7c061ece4529ffa9b897236761298717 (patch) | |
| tree | 75d28b29612786bf429fc78cfe861c1783cc64b1 | |
| parent | da2ee5dcb29b3675cb342c9bc240a22eea9cc2b7 (diff) | |
| download | rust-a174f2ab7c061ece4529ffa9b897236761298717.tar.gz rust-a174f2ab7c061ece4529ffa9b897236761298717.zip | |
add more tests
6 files changed, 115 insertions, 0 deletions
diff --git a/src/test/compile-fail/auxiliary/some-panic-impl.rs b/src/test/compile-fail/auxiliary/some-panic-impl.rs new file mode 100644 index 00000000000..db16ac325ac --- /dev/null +++ b/src/test/compile-fail/auxiliary/some-panic-impl.rs @@ -0,0 +1,22 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "rlib"] +#![feature(panic_implementation)] +#![no_std] + +use core::panic::PanicInfo; + +#[panic_implementation] +fn panic(info: &PanicInfo) -> ! { + loop {} +} diff --git a/src/test/compile-fail/panic-implementation-std.rs b/src/test/compile-fail/panic-implementation-std.rs new file mode 100644 index 00000000000..f25cd3605c1 --- /dev/null +++ b/src/test/compile-fail/panic-implementation-std.rs @@ -0,0 +1,22 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern: duplicate lang item found: `panic_impl`. + +#![feature(panic_implementation)] + +use std::panic::PanicInfo; + +#[panic_implementation] +fn panic(info: PanicInfo) -> ! { + loop {} +} + +fn main() {} diff --git a/src/test/compile-fail/panic-implementation-twice.rs b/src/test/compile-fail/panic-implementation-twice.rs new file mode 100644 index 00000000000..78dc545c036 --- /dev/null +++ b/src/test/compile-fail/panic-implementation-twice.rs @@ -0,0 +1,29 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:some-panic-impl.rs + +#![feature(panic_implementation)] +#![feature(lang_items)] +#![no_std] +#![no_main] + +extern crate some_panic_impl; + +use core::panic::PanicInfo; + +#[panic_implementation] +fn panic(info: &PanicInfo) -> ! { + //~^ error duplicate lang item found: `panic_impl` + loop {} +} + +#[lang = "eh_personality"] +fn eh() {} diff --git a/src/test/run-make/panic-impl-transitive/Makefile b/src/test/run-make/panic-impl-transitive/Makefile new file mode 100644 index 00000000000..1714578b2ba --- /dev/null +++ b/src/test/run-make/panic-impl-transitive/Makefile @@ -0,0 +1,7 @@ +-include ../../run-make-fulldeps/tools.mk + +# NOTE we use --emit=llvm-ir to avoid running the linker (linking will fail because there's no main +# in this crate) +all: + $(RUSTC) panic-impl-provider.rs + $(RUSTC) panic-impl-consumer.rs -C panic=abort --emit=llvm-ir -L $(TMPDIR) diff --git a/src/test/run-make/panic-impl-transitive/panic-impl-consumer.rs b/src/test/run-make/panic-impl-transitive/panic-impl-consumer.rs new file mode 100644 index 00000000000..592fab8be85 --- /dev/null +++ b/src/test/run-make/panic-impl-transitive/panic-impl-consumer.rs @@ -0,0 +1,15 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![no_std] +#![no_main] + +// this crate provides the `panic_impl` lang item so we don't need to define it here +extern crate panic_impl_provider; diff --git a/src/test/run-make/panic-impl-transitive/panic-impl-provider.rs b/src/test/run-make/panic-impl-transitive/panic-impl-provider.rs new file mode 100644 index 00000000000..46cdf2e2fa5 --- /dev/null +++ b/src/test/run-make/panic-impl-transitive/panic-impl-provider.rs @@ -0,0 +1,20 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] +#![feature(panic_implementation)] +#![no_std] + +use core::panic::PanicInfo; + +#[panic_implementation] +fn panic(info: &PanicInfo) -> ! { + loop {} +} |
