clarify must_produce_diag
ICE for debugging
This commit is contained in:
parent
9a9daddd0d
commit
c6659251c9
1 changed files with 16 additions and 3 deletions
|
@ -623,12 +623,25 @@ impl Drop for DiagCtxtInner {
|
||||||
self.flush_delayed()
|
self.flush_delayed()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sanity check: did we use some of the expensive `trimmed_def_paths` functions
|
||||||
|
// unexpectedly, that is, without producing diagnostics? If so, for debugging purposes, we
|
||||||
|
// suggest where this happened and how to avoid it.
|
||||||
if !self.has_printed && !self.suppressed_expected_diag && !std::thread::panicking() {
|
if !self.has_printed && !self.suppressed_expected_diag && !std::thread::panicking() {
|
||||||
if let Some(backtrace) = &self.must_produce_diag {
|
if let Some(backtrace) = &self.must_produce_diag {
|
||||||
|
let suggestion = match backtrace.status() {
|
||||||
|
BacktraceStatus::Disabled => String::from(
|
||||||
|
"Backtraces are currently disabled: set `RUST_BACKTRACE=1` and re-run \
|
||||||
|
to see where it happened.",
|
||||||
|
),
|
||||||
|
BacktraceStatus::Captured => format!(
|
||||||
|
"This happened in the following `must_produce_diag` call's backtrace:\n\
|
||||||
|
{backtrace}",
|
||||||
|
),
|
||||||
|
_ => String::from("(impossible to capture backtrace where this happened)"),
|
||||||
|
};
|
||||||
panic!(
|
panic!(
|
||||||
"must_produce_diag: `trimmed_def_paths` called but no diagnostics emitted; \
|
"`trimmed_def_paths` called, diagnostics were expected but none were emitted. \
|
||||||
`with_no_trimmed_paths` for debugging. \
|
Use `with_no_trimmed_paths` for debugging. {suggestion}"
|
||||||
called at: {backtrace}"
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue