Rollup merge of #103970 - oli-obk:unhide_unknown_spans, r=estebank
Unhide unknown spans r? ```@estebank```
This commit is contained in:
commit
fcbe990093
17 changed files with 121 additions and 69 deletions
|
@ -52,7 +52,6 @@ impl Emitter for AnnotateSnippetEmitterWriter {
|
|||
let (mut primary_span, suggestions) = self.primary_span_formatted(&diag, &fluent_args);
|
||||
|
||||
self.fix_multispans_in_extern_macros_and_render_macro_backtrace(
|
||||
&self.source_map,
|
||||
&mut primary_span,
|
||||
&mut children,
|
||||
&diag.level,
|
||||
|
|
|
@ -314,7 +314,6 @@ pub trait Emitter: Translate {
|
|||
|
||||
fn fix_multispans_in_extern_macros_and_render_macro_backtrace(
|
||||
&self,
|
||||
source_map: &Option<Lrc<SourceMap>>,
|
||||
span: &mut MultiSpan,
|
||||
children: &mut Vec<SubDiagnostic>,
|
||||
level: &Level,
|
||||
|
@ -340,7 +339,7 @@ pub trait Emitter: Translate {
|
|||
.collect();
|
||||
|
||||
if !backtrace {
|
||||
self.fix_multispans_in_extern_macros(source_map, span, children);
|
||||
self.fix_multispans_in_extern_macros(span, children);
|
||||
}
|
||||
|
||||
self.render_multispans_macro_backtrace(span, children, backtrace);
|
||||
|
@ -480,15 +479,13 @@ pub trait Emitter: Translate {
|
|||
// this will change the span to point at the use site.
|
||||
fn fix_multispans_in_extern_macros(
|
||||
&self,
|
||||
source_map: &Option<Lrc<SourceMap>>,
|
||||
span: &mut MultiSpan,
|
||||
children: &mut Vec<SubDiagnostic>,
|
||||
) {
|
||||
let Some(source_map) = source_map else { return };
|
||||
debug!("fix_multispans_in_extern_macros: before: span={:?} children={:?}", span, children);
|
||||
self.fix_multispan_in_extern_macros(source_map, span);
|
||||
self.fix_multispan_in_extern_macros(span);
|
||||
for child in children.iter_mut() {
|
||||
self.fix_multispan_in_extern_macros(source_map, &mut child.span);
|
||||
self.fix_multispan_in_extern_macros(&mut child.span);
|
||||
}
|
||||
debug!("fix_multispans_in_extern_macros: after: span={:?} children={:?}", span, children);
|
||||
}
|
||||
|
@ -496,7 +493,8 @@ pub trait Emitter: Translate {
|
|||
// This "fixes" MultiSpans that contain `Span`s pointing to locations inside of external macros.
|
||||
// Since these locations are often difficult to read,
|
||||
// we move these spans from the external macros to their corresponding use site.
|
||||
fn fix_multispan_in_extern_macros(&self, source_map: &Lrc<SourceMap>, span: &mut MultiSpan) {
|
||||
fn fix_multispan_in_extern_macros(&self, span: &mut MultiSpan) {
|
||||
let Some(source_map) = self.source_map() else { return };
|
||||
// First, find all the spans in external macros and point instead at their use site.
|
||||
let replacements: Vec<(Span, Span)> = span
|
||||
.primary_spans()
|
||||
|
@ -544,7 +542,6 @@ impl Emitter for EmitterWriter {
|
|||
debug!("emit_diagnostic: suggestions={:?}", suggestions);
|
||||
|
||||
self.fix_multispans_in_extern_macros_and_render_macro_backtrace(
|
||||
&self.sm,
|
||||
&mut primary_span,
|
||||
&mut children,
|
||||
&diag.level,
|
||||
|
@ -2213,22 +2210,45 @@ impl FileWithAnnotatedLines {
|
|||
|
||||
if let Some(ref sm) = emitter.source_map() {
|
||||
for span_label in msp.span_labels() {
|
||||
let fixup_lo_hi = |span: Span| {
|
||||
let lo = sm.lookup_char_pos(span.lo());
|
||||
let mut hi = sm.lookup_char_pos(span.hi());
|
||||
|
||||
// Watch out for "empty spans". If we get a span like 6..6, we
|
||||
// want to just display a `^` at 6, so convert that to
|
||||
// 6..7. This is degenerate input, but it's best to degrade
|
||||
// gracefully -- and the parser likes to supply a span like
|
||||
// that for EOF, in particular.
|
||||
|
||||
if lo.col_display == hi.col_display && lo.line == hi.line {
|
||||
hi.col_display += 1;
|
||||
}
|
||||
(lo, hi)
|
||||
};
|
||||
|
||||
if span_label.span.is_dummy() {
|
||||
if let Some(span) = msp.primary_span() {
|
||||
// if we don't know where to render the annotation, emit it as a note
|
||||
// on the primary span.
|
||||
|
||||
let (lo, hi) = fixup_lo_hi(span);
|
||||
|
||||
let ann = Annotation {
|
||||
start_col: lo.col_display,
|
||||
end_col: hi.col_display,
|
||||
is_primary: span_label.is_primary,
|
||||
label: span_label
|
||||
.label
|
||||
.as_ref()
|
||||
.map(|m| emitter.translate_message(m, args).to_string()),
|
||||
annotation_type: AnnotationType::Singleline,
|
||||
};
|
||||
add_annotation_to_file(&mut output, lo.file, lo.line, ann);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
let lo = sm.lookup_char_pos(span_label.span.lo());
|
||||
let mut hi = sm.lookup_char_pos(span_label.span.hi());
|
||||
|
||||
// Watch out for "empty spans". If we get a span like 6..6, we
|
||||
// want to just display a `^` at 6, so convert that to
|
||||
// 6..7. This is degenerate input, but it's best to degrade
|
||||
// gracefully -- and the parser likes to supply a span like
|
||||
// that for EOF, in particular.
|
||||
|
||||
if lo.col_display == hi.col_display && lo.line == hi.line {
|
||||
hi.col_display += 1;
|
||||
}
|
||||
let (lo, hi) = fixup_lo_hi(span_label.span);
|
||||
|
||||
if lo.line != hi.line {
|
||||
let ml = MultilineAnnotation {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue