Auto merge of #104449 - oli-obk:unhide_unknown_spans, r=estebank,RalfJung

Start emitting labels even if their pointed to file is not available locally

r? `@estebank`

cc `@RalfJung`

fixes #97699
This commit is contained in:
bors 2022-12-09 06:24:28 +00:00
commit badd6a5a03
103 changed files with 2204 additions and 878 deletions

View file

@ -123,14 +123,14 @@ impl<'tcx> ConstEvalErr<'tcx> {
// Helper closure to print duplicated lines.
let mut flush_last_line = |last_frame, times| {
if let Some((line, span)) = last_frame {
err.span_label(span, &line);
err.span_note(span, &line);
// Don't print [... additional calls ...] if the number of lines is small
if times < 3 {
for _ in 0..times {
err.span_label(span, &line);
err.span_note(span, &line);
}
} else {
err.span_label(
err.span_note(
span,
format!("[... {} additional calls {} ...]", times, &line),
);

View file

@ -17,7 +17,7 @@ use rustc_middle::ty::{
};
use rustc_mir_dataflow::storage::always_storage_live_locals;
use rustc_session::Limit;
use rustc_span::{Pos, Span};
use rustc_span::Span;
use rustc_target::abi::{call::FnAbi, Align, HasDataLayout, Size, TargetDataLayout};
use super::{
@ -256,25 +256,13 @@ impl<'tcx> fmt::Display for FrameInfo<'tcx> {
if tcx.def_key(self.instance.def_id()).disambiguated_data.data
== DefPathData::ClosureExpr
{
write!(f, "inside closure")?;
write!(f, "inside closure")
} else {
// Note: this triggers a `good_path_bug` state, which means that if we ever get here
// we must emit a diagnostic. We should never display a `FrameInfo` unless we
// actually want to emit a warning or error to the user.
write!(f, "inside `{}`", self.instance)?;
write!(f, "inside `{}`", self.instance)
}
if !self.span.is_dummy() {
let sm = tcx.sess.source_map();
let lo = sm.lookup_char_pos(self.span.lo());
write!(
f,
" at {}:{}:{}",
sm.filename_for_diagnostics(&lo.file.name),
lo.line,
lo.col.to_usize() + 1
)?;
}
Ok(())
})
}
}