]> git.lizzy.rs Git - rust.git/commitdiff
Test std::backtrace::Backtrace
authorAaron Hill <aa1ronham@gmail.com>
Sat, 17 Oct 2020 19:36:05 +0000 (15:36 -0400)
committerAaron Hill <aa1ronham@gmail.com>
Sat, 17 Oct 2020 23:45:26 +0000 (19:45 -0400)
Fixes #1578

tests/run-pass/backtrace-std.rs [new file with mode: 0644]
tests/run-pass/backtrace-std.stderr [new file with mode: 0644]

diff --git a/tests/run-pass/backtrace-std.rs b/tests/run-pass/backtrace-std.rs
new file mode 100644 (file)
index 0000000..579b4f3
--- /dev/null
@@ -0,0 +1,22 @@
+// normalize-stderr-test ".*/(rust|checkout)/library/" -> "RUSTLIB/"
+// normalize-stderr-test "RUSTLIB/(.*):\d+:\d+ "-> "RUSTLIB/$1:LL:COL "
+// normalize-stderr-test "::<.*>" -> ""
+// compile-flags: -Zmiri-disable-isolation
+
+#![feature(backtrace)]
+
+use std::backtrace::Backtrace;
+
+#[inline(never)] fn func_a() -> Backtrace { func_b::<u8>() }
+#[inline(never)] fn func_b<T>() -> Backtrace { func_c() }
+
+macro_rules! invoke_func_d {
+    () => { func_d() }
+}
+
+#[inline(never)] fn func_c() -> Backtrace { invoke_func_d!() }
+#[inline(never)] fn func_d() -> Backtrace { Backtrace::capture() }
+
+fn main() {
+    eprint!("{}", func_a());
+}
diff --git a/tests/run-pass/backtrace-std.stderr b/tests/run-pass/backtrace-std.stderr
new file mode 100644 (file)
index 0000000..d14735c
--- /dev/null
@@ -0,0 +1,28 @@
+   0: func_d
+             at $DIR/backtrace-std.rs:18
+   1: func_c
+             at $DIR/backtrace-std.rs:17
+   2: func_b
+             at $DIR/backtrace-std.rs:11
+   3: func_a
+             at $DIR/backtrace-std.rs:10
+   4: main
+             at $DIR/backtrace-std.rs:21
+   5: <fn() as std::ops::FnOnce<()>>::call_once - shim(fn())
+RUSTLIB/core/src/ops/function.rs:227
+   6: std::sys_common::backtrace::__rust_begin_short_backtrace
+RUSTLIB/std/src/sys_common/backtrace.rs:125
+   7: std::rt::lang_start::{closure#0}
+RUSTLIB/std/src/rt.rs:66
+   8: std::ops::function::impls::call_once
+RUSTLIB/core/src/ops/function.rs:259
+   9: std::panicking::r#try::do_call
+RUSTLIB/std/src/panicking.rs:381
+  10: std::panicking::r#try
+RUSTLIB/std/src/panicking.rs:345
+  11: std::panic::catch_unwind
+RUSTLIB/std/src/panic.rs:382
+  12: std::rt::lang_start_internal
+RUSTLIB/std/src/rt.rs:51
+  13: std::rt::lang_start
+RUSTLIB/std/src/rt.rs:65