@@ -10,7 +10,7 @@ use rustc_parse_format as parse;
1010use rustc_session:: lint:: { self , BuiltinLintDiagnostics } ;
1111use rustc_span:: symbol:: Ident ;
1212use rustc_span:: symbol:: { kw, sym, Symbol } ;
13- use rustc_span:: { InnerSpan , Span } ;
13+ use rustc_span:: { InnerSpan , MultiSpan , Span } ;
1414use rustc_target:: asm:: InlineAsmArch ;
1515use smallvec:: smallvec;
1616
@@ -523,26 +523,19 @@ fn expand_preparsed_asm(
523523 if found_labels. len ( ) > 0 {
524524 let spans =
525525 found_labels. into_iter ( ) . filter_map ( find_label_span) . collect :: < Vec < Span > > ( ) ;
526- if spans. len ( ) > 0 {
527- for span in spans. into_iter ( ) {
528- ecx. parse_sess ( ) . buffer_lint_with_diagnostic (
529- lint:: builtin:: NAMED_ASM_LABELS ,
530- span,
531- ecx. current_expansion . lint_node_id ,
532- "avoid using named labels in inline assembly" ,
533- BuiltinLintDiagnostics :: NamedAsmLabel ( "only local labels of the form `<number>:` should be used in inline asm" . to_string ( ) ) ,
534- ) ;
535- }
536- } else {
537- // If there were labels but we couldn't find a span, combine the warnings and use the template span
538- ecx. parse_sess ( ) . buffer_lint_with_diagnostic (
539- lint:: builtin:: NAMED_ASM_LABELS ,
540- template_sp,
541- ecx. current_expansion . lint_node_id ,
542- "avoid using named labels in inline assembly" ,
543- BuiltinLintDiagnostics :: NamedAsmLabel ( "only local labels of the form `<number>:` should be used in inline asm" . to_string ( ) ) ,
544- ) ;
545- }
526+ // If there were labels but we couldn't find a span, combine the warnings and use the template span
527+ let target_spans: MultiSpan =
528+ if spans. len ( ) > 0 { spans. into ( ) } else { template_sp. into ( ) } ;
529+ ecx. parse_sess ( ) . buffer_lint_with_diagnostic (
530+ lint:: builtin:: NAMED_ASM_LABELS ,
531+ target_spans,
532+ ecx. current_expansion . lint_node_id ,
533+ "avoid using named labels in inline assembly" ,
534+ BuiltinLintDiagnostics :: NamedAsmLabel (
535+ "only local labels of the form `<number>:` should be used in inline asm"
536+ . to_string ( ) ,
537+ ) ,
538+ ) ;
546539 }
547540 }
548541
0 commit comments