File tree Expand file tree Collapse file tree 7 files changed +148
-104
lines changed Expand file tree Collapse file tree 7 files changed +148
-104
lines changed Original file line number Diff line number Diff line change @@ -530,17 +530,17 @@ fn expand_preparsed_asm(
530530 span,
531531 ecx. current_expansion . lint_node_id ,
532532 "do not use named labels in inline assembly" ,
533- BuiltinLintDiagnostics :: NamedAsmLabel ( "Only GAS local labels of the form `N:` where N is a number may be used in inline asm" . to_string ( ) ) ,
533+ BuiltinLintDiagnostics :: NamedAsmLabel ( "only GAS local labels of the form `N:` where N is a number may be used in inline asm" . to_string ( ) ) ,
534534 ) ;
535535 }
536536 } else {
537537 // If there were labels but we couldn't find a span, combine the warnings and use the template span
538538 ecx. parse_sess ( ) . buffer_lint_with_diagnostic (
539539 lint:: builtin:: NAMED_ASM_LABELS ,
540- template_span ,
540+ template_sp ,
541541 ecx. current_expansion . lint_node_id ,
542542 "do not use named labels in inline assembly" ,
543- BuiltinLintDiagnostics :: NamedAsmLabel ( "Only GAS local labels of the form `N:` where N is a number may be used in inline asm" . to_string ( ) ) ,
543+ BuiltinLintDiagnostics :: NamedAsmLabel ( "only GAS local labels of the form `N:` where N is a number may be used in inline asm" . to_string ( ) ) ,
544544 ) ;
545545 }
546546 }
Original file line number Diff line number Diff line change @@ -760,7 +760,7 @@ pub trait LintContext: Sized {
760760 }
761761 BuiltinLintDiagnostics :: NamedAsmLabel ( help) => {
762762 db. help ( & help) ;
763- db. note ( "See the asm section of the unstable book <https://doc.rust-lang.org/nightly/unstable-book/library-features/asm.html#labels> for more information" ) ;
763+ db. note ( "see the asm section of the unstable book <https://doc.rust-lang.org/nightly/unstable-book/library-features/asm.html#labels> for more information" ) ;
764764 }
765765 }
766766 // Rewrap `db`, and pass control to the user.
Original file line number Diff line number Diff line change @@ -2990,6 +2990,7 @@ declare_lint_pass! {
29902990 INLINE_NO_SANITIZE ,
29912991 BAD_ASM_STYLE ,
29922992 ASM_SUB_REGISTER ,
2993+ NAMED_ASM_LABELS ,
29932994 UNSAFE_OP_IN_UNSAFE_FN ,
29942995 INCOMPLETE_INCLUDE ,
29952996 CENUM_IMPL_DROP_CAST ,
Original file line number Diff line number Diff line change 77#![ no_core]
88#![ feature( no_core, lang_items, rustc_attrs) ]
99#![ crate_type = "rlib" ]
10+ #![ allow( named_asm_labels) ]
1011
1112#[ rustc_builtin_macro]
1213macro_rules! asm {
Original file line number Diff line number Diff line change @@ -114,6 +114,20 @@ fn main() {
114114 asm ! ( ":lo12:FOO" ) ; // this is apparently valid aarch64
115115 // is there an example that is valid x86 for this test?
116116 asm ! ( ":bbb nop" ) ;
117+
118+ // Test include_str in asm
119+ asm ! ( include_str!( "named-asm-labels.s" ) ) ; //~ ERROR do not use named labels
120+
121+ // Test allowing or warning on the lint instead
122+ #[ allow( named_asm_labels) ]
123+ {
124+ asm ! ( "allowed: nop" ) ; // Should not emit anything
125+ }
126+
127+ #[ warn( named_asm_labels) ]
128+ {
129+ asm ! ( "warned: nop" ) ; //~ WARNING do not use named labels
130+ }
117131 }
118132}
119133
Original file line number Diff line number Diff line change 1+ lab1: nop
2+ // do more things
3+ lab2: nop // does bar
4+ // a: b
5+ lab3: nop ; lab4: nop
Load Diff Large diffs are not rendered by default.
You can’t perform that action at this time.
0 commit comments