File tree 7 files changed +148
-104
lines changed
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(
530
530
span,
531
531
ecx. current_expansion . lint_node_id ,
532
532
"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 ( ) ) ,
534
534
) ;
535
535
}
536
536
} else {
537
537
// If there were labels but we couldn't find a span, combine the warnings and use the template span
538
538
ecx. parse_sess ( ) . buffer_lint_with_diagnostic (
539
539
lint:: builtin:: NAMED_ASM_LABELS ,
540
- template_span ,
540
+ template_sp ,
541
541
ecx. current_expansion . lint_node_id ,
542
542
"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 ( ) ) ,
544
544
) ;
545
545
}
546
546
}
Original file line number Diff line number Diff line change @@ -760,7 +760,7 @@ pub trait LintContext: Sized {
760
760
}
761
761
BuiltinLintDiagnostics :: NamedAsmLabel ( help) => {
762
762
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" ) ;
764
764
}
765
765
}
766
766
// 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! {
2990
2990
INLINE_NO_SANITIZE ,
2991
2991
BAD_ASM_STYLE ,
2992
2992
ASM_SUB_REGISTER ,
2993
+ NAMED_ASM_LABELS ,
2993
2994
UNSAFE_OP_IN_UNSAFE_FN ,
2994
2995
INCOMPLETE_INCLUDE ,
2995
2996
CENUM_IMPL_DROP_CAST ,
Original file line number Diff line number Diff line change 7
7
#![ no_core]
8
8
#![ feature( no_core, lang_items, rustc_attrs) ]
9
9
#![ crate_type = "rlib" ]
10
+ #![ allow( named_asm_labels) ]
10
11
11
12
#[ rustc_builtin_macro]
12
13
macro_rules! asm {
Original file line number Diff line number Diff line change @@ -114,6 +114,20 @@ fn main() {
114
114
asm ! ( ":lo12:FOO" ) ; // this is apparently valid aarch64
115
115
// is there an example that is valid x86 for this test?
116
116
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
+ }
117
131
}
118
132
}
119
133
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