Skip to content

Commit 1ae19b6

Browse files
committed
Fix lint capitalization and ignoring, test with include_str
1 parent 8e7bbc9 commit 1ae19b6

File tree

7 files changed

+148
-104
lines changed

7 files changed

+148
-104
lines changed

compiler/rustc_builtin_macros/src/asm.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff 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
}

compiler/rustc_lint/src/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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.

compiler/rustc_lint_defs/src/builtin.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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,

src/test/codegen/asm-sanitize-llvm.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
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]
1213
macro_rules! asm {

src/test/ui/asm/named_asm_labels.rs renamed to src/test/ui/asm/named-asm-labels.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff 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

src/test/ui/asm/named-asm-labels.s

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
lab1: nop
2+
// do more things
3+
lab2: nop // does bar
4+
// a: b
5+
lab3: nop; lab4: nop

src/test/ui/asm/named_asm_labels.stderr renamed to src/test/ui/asm/named-asm-labels.stderr

Lines changed: 123 additions & 100 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)