summaryrefslogtreecommitdiffstats
path: root/src/test/ui/rfc-2091-track-caller/diverging-caller-location.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /src/test/ui/rfc-2091-track-caller/diverging-caller-location.rs
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/rfc-2091-track-caller/diverging-caller-location.rs')
-rw-r--r--src/test/ui/rfc-2091-track-caller/diverging-caller-location.rs17
1 files changed, 17 insertions, 0 deletions
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 000000000..668111955
--- /dev/null
+++ b/src/test/ui/rfc-2091-track-caller/diverging-caller-location.rs
@@ -0,0 +1,17 @@
+// 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.
+
+#[track_caller]
+fn doesnt_return() -> ! {
+ let _location = core::panic::Location::caller();
+ panic!("huzzah");
+}
+
+fn main() {
+ doesnt_return();
+}