Rollup merge of #135596 - compiler-errors:stack, r=oli-obk
Properly note when query stack is being cut off cc #70953 also, i'm not certain whether we should even limit this at all. i don't see the problem with printing the full query stack, apparently it was limited b/c we used to ICE? but we're already printing the full stack to disk since #108714. r? oli-obk
This commit is contained in:
commit
5fab5429c4
7 changed files with 20 additions and 15 deletions
|
@ -1528,9 +1528,9 @@ fn report_ice(
|
||||||
// If backtraces are enabled, also print the query stack
|
// If backtraces are enabled, also print the query stack
|
||||||
let backtrace = env::var_os("RUST_BACKTRACE").is_some_and(|x| &x != "0");
|
let backtrace = env::var_os("RUST_BACKTRACE").is_some_and(|x| &x != "0");
|
||||||
|
|
||||||
let num_frames = if backtrace { None } else { Some(2) };
|
let limit_frames = if backtrace { None } else { Some(2) };
|
||||||
|
|
||||||
interface::try_print_query_stack(dcx, num_frames, file);
|
interface::try_print_query_stack(dcx, limit_frames, file);
|
||||||
|
|
||||||
// We don't trust this callback not to panic itself, so run it at the end after we're sure we've
|
// We don't trust this callback not to panic itself, so run it at the end after we're sure we've
|
||||||
// printed all the relevant info.
|
// printed all the relevant info.
|
||||||
|
|
|
@ -533,7 +533,7 @@ pub fn run_compiler<R: Send>(config: Config, f: impl FnOnce(&Compiler) -> R + Se
|
||||||
|
|
||||||
pub fn try_print_query_stack(
|
pub fn try_print_query_stack(
|
||||||
dcx: DiagCtxtHandle<'_>,
|
dcx: DiagCtxtHandle<'_>,
|
||||||
num_frames: Option<usize>,
|
limit_frames: Option<usize>,
|
||||||
file: Option<std::fs::File>,
|
file: Option<std::fs::File>,
|
||||||
) {
|
) {
|
||||||
eprintln!("query stack during panic:");
|
eprintln!("query stack during panic:");
|
||||||
|
@ -541,13 +541,13 @@ pub fn try_print_query_stack(
|
||||||
// Be careful relying on global state here: this code is called from
|
// Be careful relying on global state here: this code is called from
|
||||||
// a panic hook, which means that the global `DiagCtxt` may be in a weird
|
// a panic hook, which means that the global `DiagCtxt` may be in a weird
|
||||||
// state if it was responsible for triggering the panic.
|
// state if it was responsible for triggering the panic.
|
||||||
let i = ty::tls::with_context_opt(|icx| {
|
let all_frames = ty::tls::with_context_opt(|icx| {
|
||||||
if let Some(icx) = icx {
|
if let Some(icx) = icx {
|
||||||
ty::print::with_no_queries!(print_query_stack(
|
ty::print::with_no_queries!(print_query_stack(
|
||||||
QueryCtxt::new(icx.tcx),
|
QueryCtxt::new(icx.tcx),
|
||||||
icx.query,
|
icx.query,
|
||||||
dcx,
|
dcx,
|
||||||
num_frames,
|
limit_frames,
|
||||||
file,
|
file,
|
||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
|
@ -555,9 +555,14 @@ pub fn try_print_query_stack(
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if num_frames == None || num_frames >= Some(i) {
|
if let Some(limit_frames) = limit_frames
|
||||||
eprintln!("end of query stack");
|
&& all_frames > limit_frames
|
||||||
|
{
|
||||||
|
eprintln!(
|
||||||
|
"... and {} other queries... use `env RUST_BACKTRACE=1` to see the full query stack",
|
||||||
|
all_frames - limit_frames
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
eprintln!("we're just showing a limited slice of the query stack");
|
eprintln!("end of query stack");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -567,7 +567,7 @@ pub fn print_query_stack<Qcx: QueryContext>(
|
||||||
qcx: Qcx,
|
qcx: Qcx,
|
||||||
mut current_query: Option<QueryJobId>,
|
mut current_query: Option<QueryJobId>,
|
||||||
dcx: DiagCtxtHandle<'_>,
|
dcx: DiagCtxtHandle<'_>,
|
||||||
num_frames: Option<usize>,
|
limit_frames: Option<usize>,
|
||||||
mut file: Option<std::fs::File>,
|
mut file: Option<std::fs::File>,
|
||||||
) -> usize {
|
) -> usize {
|
||||||
// Be careful relying on global state here: this code is called from
|
// Be careful relying on global state here: this code is called from
|
||||||
|
@ -584,7 +584,7 @@ pub fn print_query_stack<Qcx: QueryContext>(
|
||||||
let Some(query_info) = query_map.get(&query) else {
|
let Some(query_info) = query_map.get(&query) else {
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
if Some(count_printed) < num_frames || num_frames.is_none() {
|
if Some(count_printed) < limit_frames || limit_frames.is_none() {
|
||||||
// Only print to stderr as many stack frames as `num_frames` when present.
|
// Only print to stderr as many stack frames as `num_frames` when present.
|
||||||
// FIXME: needs translation
|
// FIXME: needs translation
|
||||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
#[allow(rustc::diagnostic_outside_of_impl)]
|
||||||
|
@ -615,5 +615,5 @@ pub fn print_query_stack<Qcx: QueryContext>(
|
||||||
if let Some(ref mut file) = file {
|
if let Some(ref mut file) = file {
|
||||||
let _ = writeln!(file, "end of query stack");
|
let _ = writeln!(file, "end of query stack");
|
||||||
}
|
}
|
||||||
count_printed
|
count_total
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,6 @@ Box<dyn Any>
|
||||||
query stack during panic:
|
query stack during panic:
|
||||||
#0 [eval_to_allocation_raw] const-evaluating + checking `<impl at $DIR/issue-80742.rs:26:1: 28:32>::{constant#0}`
|
#0 [eval_to_allocation_raw] const-evaluating + checking `<impl at $DIR/issue-80742.rs:26:1: 28:32>::{constant#0}`
|
||||||
#1 [eval_to_valtree] evaluating type-level constant
|
#1 [eval_to_valtree] evaluating type-level constant
|
||||||
end of query stack
|
... and 2 other queries... use `env RUST_BACKTRACE=1` to see the full query stack
|
||||||
error: aborting due to 1 previous error
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
|
|
|
@ -5,4 +5,4 @@ error: the compiler unexpectedly panicked. this is a bug.
|
||||||
query stack during panic:
|
query stack during panic:
|
||||||
#0 [layout_of] computing layout of `Foo`
|
#0 [layout_of] computing layout of `Foo`
|
||||||
#1 [eval_to_allocation_raw] const-evaluating + checking `FOO`
|
#1 [eval_to_allocation_raw] const-evaluating + checking `FOO`
|
||||||
end of query stack
|
... and 2 other queries... use `env RUST_BACKTRACE=1` to see the full query stack
|
||||||
|
|
|
@ -21,7 +21,7 @@ Box<dyn Any>
|
||||||
query stack during panic:
|
query stack during panic:
|
||||||
#0 [mir_built] building MIR for `<impl at $DIR/multiple_definitions_attribute_merging.rs:15:10: 15:19>::eq`
|
#0 [mir_built] building MIR for `<impl at $DIR/multiple_definitions_attribute_merging.rs:15:10: 15:19>::eq`
|
||||||
#1 [check_unsafety] unsafety-checking `<impl at $DIR/multiple_definitions_attribute_merging.rs:15:10: 15:19>::eq`
|
#1 [check_unsafety] unsafety-checking `<impl at $DIR/multiple_definitions_attribute_merging.rs:15:10: 15:19>::eq`
|
||||||
end of query stack
|
... and 1 other queries... use `env RUST_BACKTRACE=1` to see the full query stack
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0428`.
|
For more information about this error, try `rustc --explain E0428`.
|
||||||
|
|
|
@ -12,6 +12,6 @@ Box<dyn Any>
|
||||||
query stack during panic:
|
query stack during panic:
|
||||||
#0 [mir_built] building MIR for `<impl at $DIR/proc_macro_generated_packed.rs:15:10: 15:19>::eq`
|
#0 [mir_built] building MIR for `<impl at $DIR/proc_macro_generated_packed.rs:15:10: 15:19>::eq`
|
||||||
#1 [check_unsafety] unsafety-checking `<impl at $DIR/proc_macro_generated_packed.rs:15:10: 15:19>::eq`
|
#1 [check_unsafety] unsafety-checking `<impl at $DIR/proc_macro_generated_packed.rs:15:10: 15:19>::eq`
|
||||||
end of query stack
|
... and 1 other queries... use `env RUST_BACKTRACE=1` to see the full query stack
|
||||||
error: aborting due to 1 previous error
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue