Skip to content

Commit 767e84a

Browse files
committed
change approach and run ui tests
1 parent 132c9ef commit 767e84a

File tree

8 files changed

+22
-12
lines changed

8 files changed

+22
-12
lines changed

compiler/rustc_driver/src/lib.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1205,7 +1205,9 @@ pub fn report_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str) {
12051205
// If backtraces are enabled, also print the query stack
12061206
let backtrace = env::var_os("RUST_BACKTRACE").map(|x| &x != "0").unwrap_or(false);
12071207

1208-
TyCtxt::try_print_query_stack(&handler, Some(2), Some(backtrace));
1208+
let num_frames = if backtrace { Some(2) } else { None };
1209+
1210+
TyCtxt::try_print_query_stack(&handler, num_frames);
12091211

12101212
#[cfg(windows)]
12111213
unsafe {

compiler/rustc_middle/src/ty/query/plumbing.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,7 @@ impl<'tcx> TyCtxt<'tcx> {
124124
})
125125
}
126126

127-
pub fn try_print_query_stack(
128-
handler: &Handler,
129-
num_frames: Option<usize>,
130-
backtrace: Option<bool>,
131-
) {
127+
pub fn try_print_query_stack(handler: &Handler, num_frames: Option<usize>) {
132128
eprintln!("query stack during panic:");
133129

134130
// Be careful reyling on global state here: this code is called from
@@ -142,7 +138,7 @@ impl<'tcx> TyCtxt<'tcx> {
142138
let mut i = 0;
143139

144140
while let Some(query) = current_query {
145-
if backtrace.unwrap() == false && i == num_frames.unwrap() {
141+
if num_frames == Some(i) {
146142
break;
147143
}
148144
let query_info =

src/test/ui/consts/const-eval/const-eval-query-stack.stderr

-4
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,4 @@ LL | let x: &'static i32 = &(1 / 0);
1111
query stack during panic:
1212
#0 [const_eval_raw] const-evaluating `main::promoted[1]`
1313
#1 [const_eval_validated] const-evaluating + checking `main::promoted[1]`
14-
#2 [const_eval_validated] const-evaluating + checking `main::promoted[1]`
15-
#3 [normalize_generic_arg_after_erasing_regions] normalizing `main::promoted[1]`
16-
#4 [optimized_mir] optimizing MIR for `main`
17-
#5 [collect_and_partition_mono_items] collect_and_partition_mono_items
1814
end of query stack

src/test/ui/pattern/const-pat-ice.stderr

+4
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,7 @@ note: rustc VERSION running on TARGET
1111

1212
note: compiler flags: FLAGS
1313

14+
query stack during panic:
15+
#0 [check_match] match-checking `main`
16+
#1 [analysis] running analysis passes on this crate
17+
end of query stack

src/test/ui/proc-macro/invalid-punct-ident-1.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
query stack during panic:
2+
end of query stack
13
error: proc macro panicked
24
--> $DIR/invalid-punct-ident-1.rs:16:1
35
|

src/test/ui/proc-macro/invalid-punct-ident-2.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
query stack during panic:
2+
end of query stack
13
error: proc macro panicked
24
--> $DIR/invalid-punct-ident-2.rs:16:1
35
|

src/test/ui/proc-macro/invalid-punct-ident-3.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
query stack during panic:
2+
end of query stack
13
error: proc macro panicked
24
--> $DIR/invalid-punct-ident-3.rs:16:1
35
|

src/tools/clippy/src/driver.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,13 @@ fn report_clippy_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str) {
277277
// If backtraces are enabled, also print the query stack
278278
let backtrace = env::var_os("RUST_BACKTRACE").map_or(false, |x| &x != "0");
279279

280-
TyCtxt::try_print_query_stack(&handler, Some(2), Some(backtrace));
280+
let num_frames = if backtrace {
281+
Some(2)
282+
} else {
283+
None
284+
};
285+
286+
TyCtxt::try_print_query_stack(&handler, num_frames);
281287
}
282288

283289
fn toolchain_path(home: Option<String>, toolchain: Option<String>) -> Option<PathBuf> {

0 commit comments

Comments
 (0)