@@ -414,22 +414,24 @@ pub trait Emitter {
414
414
}
415
415
416
416
// This does a small "fix" for multispans by looking to see if it can find any that
417
- // point directly at <* macros> . Since these are often difficult to read, this
418
- // will change the span to point at the use site.
417
+ // point directly at external macros. Since these are often difficult to read,
418
+ // this will change the span to point at the use site.
419
419
fn fix_multispans_in_extern_macros (
420
420
& self ,
421
421
source_map : & Option < Lrc < SourceMap > > ,
422
422
span : & mut MultiSpan ,
423
423
children : & mut Vec < SubDiagnostic > ,
424
424
) {
425
- for span in iter:: once ( span) . chain ( children. iter_mut ( ) . map ( |child| & mut child. span ) ) {
425
+ debug ! ( "fix_multispans_in_extern_macros: before: span={:?} children={:?}" , span, children) ;
426
+ for span in iter:: once ( & mut * span) . chain ( children. iter_mut ( ) . map ( |child| & mut child. span ) ) {
426
427
self . fix_multispan_in_extern_macros ( source_map, span) ;
427
428
}
429
+ debug ! ( "fix_multispans_in_extern_macros: after: span={:?} children={:?}" , span, children) ;
428
430
}
429
431
430
- // This "fixes" MultiSpans that contain Spans that are pointing to locations inside of
431
- // <*macros>. Since these locations are often difficult to read, we move these Spans from
432
- // <* macros> to their corresponding use site.
432
+ // This "fixes" MultiSpans that contain `Span`s pointing to locations inside of external macros.
433
+ // Since these locations are often difficult to read,
434
+ // we move these spans from the external macros to their corresponding use site.
433
435
fn fix_multispan_in_extern_macros (
434
436
& self ,
435
437
source_map : & Option < Lrc < SourceMap > > ,
@@ -440,14 +442,14 @@ pub trait Emitter {
440
442
None => return ,
441
443
} ;
442
444
443
- // First, find all the spans in <* macros> and point instead at their use site
445
+ // First, find all the spans in external macros and point instead at their use site.
444
446
let replacements: Vec < ( Span , Span ) > = span
445
447
. primary_spans ( )
446
448
. iter ( )
447
449
. copied ( )
448
450
. chain ( span. span_labels ( ) . iter ( ) . map ( |sp_label| sp_label. span ) )
449
451
. filter_map ( |sp| {
450
- if !sp. is_dummy ( ) && sm. span_to_filename ( sp) . is_macros ( ) {
452
+ if !sp. is_dummy ( ) && sm. is_imported ( sp) {
451
453
let maybe_callsite = sp. source_callsite ( ) ;
452
454
if sp != maybe_callsite {
453
455
return Some ( ( sp, maybe_callsite) ) ;
@@ -457,7 +459,7 @@ pub trait Emitter {
457
459
} )
458
460
. collect ( ) ;
459
461
460
- // After we have them, make sure we replace these 'bad' def sites with their use sites
462
+ // After we have them, make sure we replace these 'bad' def sites with their use sites.
461
463
for ( from, to) in replacements {
462
464
span. replace ( from, to) ;
463
465
}
@@ -472,6 +474,7 @@ impl Emitter for EmitterWriter {
472
474
fn emit_diagnostic ( & mut self , diag : & Diagnostic ) {
473
475
let mut children = diag. children . clone ( ) ;
474
476
let ( mut primary_span, suggestions) = self . primary_span_formatted ( & diag) ;
477
+ debug ! ( "emit_diagnostic: suggestions={:?}" , suggestions) ;
475
478
476
479
self . fix_multispans_in_extern_macros_and_render_macro_backtrace (
477
480
& self . sm ,
@@ -1533,6 +1536,7 @@ impl EmitterWriter {
1533
1536
1534
1537
// Render the replacements for each suggestion
1535
1538
let suggestions = suggestion. splice_lines ( & * * sm) ;
1539
+ debug ! ( "emit_suggestion_default: suggestions={:?}" , suggestions) ;
1536
1540
1537
1541
if suggestions. is_empty ( ) {
1538
1542
// Suggestions coming from macros can have malformed spans. This is a heavy handed
0 commit comments