Skip to content

Commit 5fd6301

Browse files
committed
ICEs should print the top of the query stack
1 parent 683d1bc commit 5fd6301

File tree

3 files changed

+6
-13
lines changed

3 files changed

+6
-13
lines changed

compiler/rustc_driver/src/lib.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,12 +1202,7 @@ pub fn report_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str) {
12021202
handler.note_without_error(&note);
12031203
}
12041204

1205-
// If backtraces are enabled, also print the query stack
1206-
let backtrace = env::var_os("RUST_BACKTRACE").map(|x| &x != "0").unwrap_or(false);
1207-
1208-
if backtrace {
1209-
TyCtxt::try_print_query_stack(&handler);
1210-
}
1205+
TyCtxt::try_print_query_stack(&handler, Some(2));
12111206

12121207
#[cfg(windows)]
12131208
unsafe {

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ impl<'tcx> TyCtxt<'tcx> {
124124
})
125125
}
126126

127-
pub fn try_print_query_stack(handler: &Handler) {
127+
pub fn try_print_query_stack(handler: &Handler, num_frames: Option<usize>) {
128128
eprintln!("query stack during panic:");
129129

130130
// Be careful reyling on global state here: this code is called from
@@ -138,6 +138,9 @@ impl<'tcx> TyCtxt<'tcx> {
138138
let mut i = 0;
139139

140140
while let Some(query) = current_query {
141+
if i == num_frames.unwrap() {
142+
break;
143+
}
141144
let query_info =
142145
if let Some(info) = query_map.as_ref().and_then(|map| map.get(&query)) {
143146
info

src/tools/clippy/src/driver.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -274,12 +274,7 @@ fn report_clippy_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str) {
274274
handler.note_without_error(&note);
275275
}
276276

277-
// If backtraces are enabled, also print the query stack
278-
let backtrace = env::var_os("RUST_BACKTRACE").map_or(false, |x| &x != "0");
279-
280-
if backtrace {
281-
TyCtxt::try_print_query_stack(&handler);
282-
}
277+
TyCtxt::try_print_query_stack(&handler, Some(2));
283278
}
284279

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

0 commit comments

Comments
 (0)