about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAdam Perry <adam.n.perry@gmail.com>2019-12-08 04:51:55 -0800
committerAdam Perry <adam.n.perry@gmail.com>2020-01-04 10:02:17 -0800
commite218da425160d4babaa46d7da1720a11ac6c02fa (patch)
treee1765b57669b5abe1f3ac51cd093b50335f0c410
parenteaccda009f5891c67e554b31cfad4a52738f9b91 (diff)
downloadrust-e218da425160d4babaa46d7da1720a11ac6c02fa.tar.gz
rust-e218da425160d4babaa46d7da1720a11ac6c02fa.zip
Test cleanups to match #[track_caller] in panic!.
* Removes unnecessary feature flag from track_caller test.
* Tests of panic internals no longer need to explicitly construct Location.
* Add #![warn(const_err)] to retain-never-const per @oli-obk.
* Add track_caller test with diverging function.
-rw-r--r--src/test/mir-opt/retain-never-const.rs1
-rw-r--r--src/test/ui/extern/issue-64655-allow-unwind-when-calling-panic-directly.rs6
-rw-r--r--src/test/ui/rfc-2091-track-caller/caller-location-intrinsic.rs6
-rw-r--r--src/test/ui/rfc-2091-track-caller/diverging-caller-location.rs19
-rw-r--r--src/test/ui/rfc-2091-track-caller/track-caller-attribute.rs2
5 files changed, 26 insertions, 8 deletions
diff --git a/src/test/mir-opt/retain-never-const.rs b/src/test/mir-opt/retain-never-const.rs
index 04394dcdf13..8e9bae8569f 100644
--- a/src/test/mir-opt/retain-never-const.rs
+++ b/src/test/mir-opt/retain-never-const.rs
@@ -6,6 +6,7 @@
 
 #![feature(const_panic)]
 #![feature(never_type)]
+#![warn(const_err)]
 
 struct PrintName<T>(T);
 
diff --git a/src/test/ui/extern/issue-64655-allow-unwind-when-calling-panic-directly.rs b/src/test/ui/extern/issue-64655-allow-unwind-when-calling-panic-directly.rs
index 8727c9d1ca6..74c6e501c91 100644
--- a/src/test/ui/extern/issue-64655-allow-unwind-when-calling-panic-directly.rs
+++ b/src/test/ui/extern/issue-64655-allow-unwind-when-calling-panic-directly.rs
@@ -22,7 +22,7 @@
 //[thin]compile-flags: -C lto=thin
 //[fat]compile-flags: -C lto=fat
 
-#![feature(core_panic, panic_internals)]
+#![feature(core_panic)]
 
 // (For some reason, reproducing the LTO issue requires pulling in std
 // explicitly this way.)
@@ -50,9 +50,7 @@ fn main() {
         }
 
         let _guard = Droppable;
-        let s = "issue-64655-allow-unwind-when-calling-panic-directly.rs";
-        let location = core::panic::Location::internal_constructor(s, 17, 4);
-        core::panicking::panic("???", &location);
+        core::panicking::panic("???");
     });
 
     let wait = handle.join();
diff --git a/src/test/ui/rfc-2091-track-caller/caller-location-intrinsic.rs b/src/test/ui/rfc-2091-track-caller/caller-location-intrinsic.rs
index 0a79aea376f..090e912c1d0 100644
--- a/src/test/ui/rfc-2091-track-caller/caller-location-intrinsic.rs
+++ b/src/test/ui/rfc-2091-track-caller/caller-location-intrinsic.rs
@@ -4,16 +4,16 @@
 
 #[inline(never)]
 #[track_caller]
-fn defeat_const_prop() -> &'static core::panic::Location<'static> {
+fn codegen_caller_loc() -> &'static core::panic::Location<'static> {
     core::panic::Location::caller()
 }
 
 macro_rules! caller_location_from_macro {
-    () => (defeat_const_prop());
+    () => (codegen_caller_loc());
 }
 
 fn main() {
-    let loc = defeat_const_prop();
+    let loc = codegen_caller_loc();
     assert_eq!(loc.file(), file!());
     assert_eq!(loc.line(), 16);
     assert_eq!(loc.column(), 15);
diff --git a/src/test/ui/rfc-2091-track-caller/diverging-caller-location.rs b/src/test/ui/rfc-2091-track-caller/diverging-caller-location.rs
new file mode 100644
index 00000000000..1fb75ef35ff
--- /dev/null
+++ b/src/test/ui/rfc-2091-track-caller/diverging-caller-location.rs
@@ -0,0 +1,19 @@
+// run-fail
+
+//! This test ensures that `#[track_caller]` can be applied directly to diverging functions, as
+//! the tracking issue says: https://github.com/rust-lang/rust/issues/47809#issue-292138490.
+//! Because the annotated function must diverge and a panic keeps that faster than an infinite loop,
+//! we don't inspect the location returned -- it would be difficult to distinguish between the
+//! explicit panic and a failed assertion. That it compiles and runs is enough for this one.
+
+#![feature(track_caller)]
+
+#[track_caller]
+fn doesnt_return() -> ! {
+    let _location = core::panic::Location::caller();
+    panic!("huzzah");
+}
+
+fn main() {
+    doesnt_return();
+}
diff --git a/src/test/ui/rfc-2091-track-caller/track-caller-attribute.rs b/src/test/ui/rfc-2091-track-caller/track-caller-attribute.rs
index 8436ee510a5..76a380ed3e3 100644
--- a/src/test/ui/rfc-2091-track-caller/track-caller-attribute.rs
+++ b/src/test/ui/rfc-2091-track-caller/track-caller-attribute.rs
@@ -1,6 +1,6 @@
 // run-pass
 
-#![feature(const_fn, track_caller)]
+#![feature(track_caller)]
 
 use std::panic::Location;