Skip to content

Commit 17eb8d8

Browse files
hosseind75hosseind88
authored andcommitted
ICEs should print the top of the query stack
1 parent be719d1 commit 17eb8d8

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
@@ -1211,12 +1211,7 @@ pub fn report_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str) {
12111211
handler.note_without_error(&note);
12121212
}
12131213

1214-
// If backtraces are enabled, also print the query stack
1215-
let backtrace = env::var_os("RUST_BACKTRACE").map(|x| &x != "0").unwrap_or(false);
1216-
1217-
if backtrace {
1218-
TyCtxt::try_print_query_stack(&handler);
1219-
}
1214+
TyCtxt::try_print_query_stack(&handler, Some(2));
12201215

12211216
#[cfg(windows)]
12221217
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)