]> git.lizzy.rs Git - rust.git/commitdiff
add more tests
authorJorge Aparicio <jorge@japaric.io>
Tue, 29 May 2018 10:33:11 +0000 (12:33 +0200)
committerJorge Aparicio <jorge@japaric.io>
Sun, 3 Jun 2018 11:46:20 +0000 (13:46 +0200)
src/test/compile-fail/auxiliary/some-panic-impl.rs [new file with mode: 0644]
src/test/compile-fail/panic-implementation-std.rs [new file with mode: 0644]
src/test/compile-fail/panic-implementation-twice.rs [new file with mode: 0644]
src/test/run-make/panic-impl-transitive/Makefile [new file with mode: 0644]
src/test/run-make/panic-impl-transitive/panic-impl-consumer.rs [new file with mode: 0644]
src/test/run-make/panic-impl-transitive/panic-impl-provider.rs [new file with mode: 0644]

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 (file)
index 0000000..db16ac3
--- /dev/null
@@ -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 (file)
index 0000000..f25cd36
--- /dev/null
@@ -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 (file)
index 0000000..78dc545
--- /dev/null
@@ -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 (file)
index 0000000..1714578
--- /dev/null
@@ -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 (file)
index 0000000..592fab8
--- /dev/null
@@ -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 (file)
index 0000000..46cdf2e
--- /dev/null
@@ -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 {}
+}