Skip to content

Commit 9c04532

Browse files
borspoliorcetics
authored andcommitted
Auto merge of rust-lang#134774 - jyn514:rustc-dev-short-backtraces, r=jieyouxu
fix default-backtrace-ice test when running `tests/ui/panics/default-backtrace-ice.rs locally it gave this error: ``` failures: ---- [ui] tests/ui/panics/default-backtrace-ice.rs stdout ---- Saved the actual stderr to "/home/jyn/src/rust3/build/x86_64-unknown-linux-gnu/test/ui/panics/default-backtrace-ice/default-backtrace-ice.stderr" diff of stderr: 7 8 aborting due to `-Z treat-err-as-bug=1` 9 stack backtrace: - (end_short_backtrace) - (begin_short_backtrace) - (end_short_backtrace) - (begin_short_backtrace) + [... omitted 22 frames ...] + ``` (note that you must *not* use --bless; we previously did not have an error annotation to verify it was a full backtrace instead of a short backtrace.) this is a regression from setting RUST_BACKTRACE=1 by default in rust-lang#134743. we need to turn off the new behavior when running UI tests so that they reflect our dist compiler. normally that's done by checking `sess.unstable_opts.ui_testing`, but this happens extremely early in the compiler before we've expanded arg files. do an extremely simple hack that doesn't work in all cases - we don't need it to work in all cases, only when running UI tests. cc rust-lang#129658 (comment) r? `@jieyouxu`
2 parents 60fef6b + 801c1d8 commit 9c04532

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

compiler/rustc_driver_impl/src/lib.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1388,7 +1388,9 @@ pub fn install_ice_hook(
13881388
// opt in to less-verbose backtraces by manually setting "RUST_BACKTRACE"
13891389
// (e.g. `RUST_BACKTRACE=1`)
13901390
if env::var_os("RUST_BACKTRACE").is_none() {
1391-
if env!("CFG_RELEASE_CHANNEL") == "dev" {
1391+
// HACK: this check is extremely dumb, but we don't really need it to be smarter since this should only happen in the test suite anyway.
1392+
let ui_testing = std::env::args().any(|arg| arg == "-Zui-testing");
1393+
if env!("CFG_RELEASE_CHANNEL") == "dev" && !ui_testing {
13921394
panic::set_backtrace_style(panic::BacktraceStyle::Short);
13931395
} else {
13941396
panic::set_backtrace_style(panic::BacktraceStyle::Full);

tests/ui/panics/default-backtrace-ice.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
//@ unset-rustc-env:RUST_BACKTRACE
22
//@ compile-flags:-Z treat-err-as-bug=1
33
//@ error-pattern:stack backtrace:
4+
// Verify this is a full backtrace, not a short backtrace.
5+
//@ error-pattern:__rust_begin_short_backtrace
46
//@ failure-status:101
57
//@ ignore-msvc
68
//@ normalize-stderr-test: "note: .*" -> ""

tests/ui/panics/default-backtrace-ice.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: internal compiler error[E0425]: cannot find value `missing_ident` in this scope
2-
--> $DIR/default-backtrace-ice.rs:21:13
2+
--> $DIR/default-backtrace-ice.rs:23:13
33
|
44
LL | fn main() { missing_ident; }
55
| ^^^^^^^^^^^^^ not found in this scope

0 commit comments

Comments
 (0)