From 87856c4461c29eb8c8ef7e3fb28ccfcbd41e4120 Mon Sep 17 00:00:00 2001 From: asquared31415 <34665709+asquared31415@users.noreply.github.com> Date: Mon, 24 Jun 2024 22:37:44 +0000 Subject: [PATCH] add lint for inline asm labels that look like binary --- compiler/rustc_lint/messages.ftl | 17 +- compiler/rustc_lint/src/builtin.rs | 131 +++++++++++---- compiler/rustc_lint/src/lib.rs | 2 +- compiler/rustc_lint/src/lints.rs | 30 +++- tests/ui/asm/binary_asm_labels.rs | 17 ++ tests/ui/asm/binary_asm_labels.stderr | 43 +++++ tests/ui/asm/named-asm-labels.rs | 24 ++- tests/ui/asm/named-asm-labels.stderr | 224 ++++++++++++++++++++------ 8 files changed, 397 insertions(+), 91 deletions(-) create mode 100644 tests/ui/asm/binary_asm_labels.rs create mode 100644 tests/ui/asm/binary_asm_labels.stderr diff --git a/compiler/rustc_lint/messages.ftl b/compiler/rustc_lint/messages.ftl index 3e952558d29d3..9d8271a6acb36 100644 --- a/compiler/rustc_lint/messages.ftl +++ b/compiler/rustc_lint/messages.ftl @@ -52,10 +52,6 @@ lint_builtin_allow_internal_unsafe = lint_builtin_anonymous_params = anonymous parameters are deprecated and will be removed in the next edition .suggestion = try naming the parameter or explicitly ignoring it -lint_builtin_asm_labels = avoid using named labels in inline assembly - .help = only local labels of the form `:` should be used in inline asm - .note = see the asm section of Rust By Example for more information - lint_builtin_clashing_extern_diff_name = `{$this}` redeclares `{$orig}` with a different signature .previous_decl_label = `{$orig}` previously declared here .mismatch_label = this signature doesn't match the previous declaration @@ -399,6 +395,19 @@ lint_incomplete_include = lint_inner_macro_attribute_unstable = inner macro attributes are unstable +lint_invalid_asm_label_binary = avoid using labels containing only the digits `0` and `1` in inline assembly + .label = use a different label that doesn't start with `0` or `1` + .note = an LLVM bug makes these labels ambiguous with a binary literal number + .note = see for more information + +lint_invalid_asm_label_format_arg = avoid using named labels in inline assembly + .help = only local labels of the form `:` should be used in inline asm + .note1 = format arguments may expand to a non-numeric value + .note2 = see the asm section of Rust By Example for more information +lint_invalid_asm_label_named = avoid using named labels in inline assembly + .help = only local labels of the form `:` should be used in inline asm + .note = see the asm section of Rust By Example for more information +lint_invalid_asm_label_no_span = the label may be declared in the expansion of a macro lint_invalid_crate_type_value = invalid `crate_type` value .suggestion = did you mean diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs index 79c8046f9b741..a661c74cf91d9 100644 --- a/compiler/rustc_lint/src/builtin.rs +++ b/compiler/rustc_lint/src/builtin.rs @@ -30,13 +30,13 @@ use crate::{ BuiltinExplicitOutlivesSuggestion, BuiltinFeatureIssueNote, BuiltinIncompleteFeatures, BuiltinIncompleteFeaturesHelp, BuiltinInternalFeatures, BuiltinKeywordIdents, BuiltinMissingCopyImpl, BuiltinMissingDebugImpl, BuiltinMissingDoc, - BuiltinMutablesTransmutes, BuiltinNamedAsmLabel, BuiltinNoMangleGeneric, - BuiltinNonShorthandFieldPatterns, BuiltinSpecialModuleNameUsed, BuiltinTrivialBounds, - BuiltinTypeAliasGenericBounds, BuiltinTypeAliasGenericBoundsSuggestion, - BuiltinTypeAliasWhereClause, BuiltinUngatedAsyncFnTrackCaller, BuiltinUnpermittedTypeInit, + BuiltinMutablesTransmutes, BuiltinNoMangleGeneric, BuiltinNonShorthandFieldPatterns, + BuiltinSpecialModuleNameUsed, BuiltinTrivialBounds, BuiltinTypeAliasGenericBounds, + BuiltinTypeAliasGenericBoundsSuggestion, BuiltinTypeAliasWhereClause, + BuiltinUngatedAsyncFnTrackCaller, BuiltinUnpermittedTypeInit, BuiltinUnpermittedTypeInitSub, BuiltinUnreachablePub, BuiltinUnsafe, BuiltinUnstableFeatures, BuiltinUnusedDocComment, BuiltinUnusedDocCommentSub, - BuiltinWhileTrue, SuggestChangingAssocTypes, + BuiltinWhileTrue, InvalidAsmLabel, SuggestChangingAssocTypes, }, EarlyContext, EarlyLintPass, LateContext, LateLintPass, Level, LintContext, }; @@ -45,7 +45,7 @@ use rustc_ast::tokenstream::{TokenStream, TokenTree}; use rustc_ast::visit::{FnCtxt, FnKind}; use rustc_ast::{self as ast, *}; use rustc_ast_pretty::pprust::{self, expr_to_string}; -use rustc_errors::{Applicability, LintDiagnostic, MultiSpan}; +use rustc_errors::{Applicability, LintDiagnostic}; use rustc_feature::{deprecated_attributes, AttributeGate, BuiltinAttribute, GateIssue, Stability}; use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; @@ -69,7 +69,6 @@ use rustc_target::abi::Abi; use rustc_trait_selection::infer::{InferCtxtExt, TyCtxtInferExt}; use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt as _; use rustc_trait_selection::traits::{self, misc::type_allowed_to_implement_copy}; -use tracing::debug; use crate::nonstandard_style::{method_context, MethodLateContext}; @@ -2728,10 +2727,52 @@ declare_lint! { "named labels in inline assembly", } -declare_lint_pass!(NamedAsmLabels => [NAMED_ASM_LABELS]); +declare_lint! { + /// The `binary_asm_labels` lint detects the use of numeric labels containing only binary + /// digits in the inline `asm!` macro. + /// + /// ### Example + /// + /// ```rust,compile_fail + /// # #![feature(asm_experimental_arch)] + /// use std::arch::asm; + /// + /// fn main() { + /// unsafe { + /// asm!("0: jmp 0b"); + /// } + /// } + /// ``` + /// + /// {{produces}} + /// + /// ### Explanation + /// + /// A [LLVM bug] causes this code to fail to compile because it interprets the `0b` as a binary + /// literal instead of a reference to the previous local label `0`. Note that even though the + /// bug is marked as fixed, it only fixes a specific usage of intel syntax within standalone + /// files, not inline assembly. To work around this bug, don't use labels that could be + /// confused with a binary literal. + /// + /// See the explanation in [Rust By Example] for more details. + /// + /// [LLVM bug]: https://bugs.llvm.org/show_bug.cgi?id=36144 + /// [Rust By Example]: https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels + pub BINARY_ASM_LABELS, + Deny, + "labels in inline assembly containing only 0 or 1 digits", +} -impl<'tcx> LateLintPass<'tcx> for NamedAsmLabels { - #[allow(rustc::diagnostic_outside_of_impl)] +declare_lint_pass!(AsmLabels => [NAMED_ASM_LABELS, BINARY_ASM_LABELS]); + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +enum AsmLabelKind { + Named, + FormatArg, + Binary, +} + +impl<'tcx> LateLintPass<'tcx> for AsmLabels { fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'tcx>) { if let hir::Expr { kind: hir::ExprKind::InlineAsm(hir::InlineAsm { template_strs, options, .. }), @@ -2759,7 +2800,8 @@ impl<'tcx> LateLintPass<'tcx> for NamedAsmLabels { None }; - let mut found_labels = Vec::new(); + // diagnostics are emitted per-template, so this is created here as opposed to the outer loop + let mut spans = Vec::new(); // A semicolon might not actually be specified as a separator for all targets, but // it seems like LLVM accepts it always. @@ -2782,16 +2824,21 @@ impl<'tcx> LateLintPass<'tcx> for NamedAsmLabels { // Whether a { bracket has been seen and its } hasn't been found yet. let mut in_bracket = false; + let mut label_kind = AsmLabelKind::Named; - // A label starts with an ASCII alphabetic character or . or _ // A label can also start with a format arg, if it's not a raw asm block. if !raw && start == '{' { in_bracket = true; + label_kind = AsmLabelKind::FormatArg; + } else if matches!(start, '0' | '1') { + // Binary labels have only the characters `0` or `1`. + label_kind = AsmLabelKind::Binary; } else if !(start.is_ascii_alphabetic() || matches!(start, '.' | '_')) { + // Named labels start with ASCII letters, `.` or `_`. + // anything else is not a label break 'label_loop; } - // Labels continue with ASCII alphanumeric characters, _, or $ for c in chars { // Inside a template format arg, any character is permitted for the // puproses of label detection because we assume that it can be @@ -2812,8 +2859,18 @@ impl<'tcx> LateLintPass<'tcx> for NamedAsmLabels { } else if !raw && c == '{' { // Start of a format arg. in_bracket = true; + label_kind = AsmLabelKind::FormatArg; } else { - if !(c.is_ascii_alphanumeric() || matches!(c, '_' | '$')) { + let can_continue = match label_kind { + // Format arg labels are considered to be named labels for the purposes + // of continuing outside of their {} pair. + AsmLabelKind::Named | AsmLabelKind::FormatArg => { + c.is_ascii_alphanumeric() || matches!(c, '_' | '$') + } + AsmLabelKind::Binary => matches!(c, '0' | '1'), + }; + + if !can_continue { // The potential label had an invalid character inside it, it // cannot be a label. break 'label_loop; @@ -2821,25 +2878,41 @@ impl<'tcx> LateLintPass<'tcx> for NamedAsmLabels { } } - // If all characters passed the label checks, this is likely a label. - found_labels.push(possible_label); + // If all characters passed the label checks, this is a label. + spans.push((find_label_span(possible_label), label_kind)); start_idx = idx + 1; } } - debug!("NamedAsmLabels::check_expr(): found_labels: {:#?}", &found_labels); - - if found_labels.len() > 0 { - let spans = found_labels - .into_iter() - .filter_map(|label| find_label_span(label)) - .collect::>(); - // If there were labels but we couldn't find a span, combine the warnings and - // use the template span. - let target_spans: MultiSpan = - if spans.len() > 0 { spans.into() } else { (*template_span).into() }; - - cx.emit_span_lint(NAMED_ASM_LABELS, target_spans, BuiltinNamedAsmLabel); + for (span, label_kind) in spans { + let missing_precise_span = span.is_none(); + let span = span.unwrap_or(*template_span); + match label_kind { + AsmLabelKind::Named => { + cx.emit_span_lint( + NAMED_ASM_LABELS, + span, + InvalidAsmLabel::Named { missing_precise_span }, + ); + } + AsmLabelKind::FormatArg => { + cx.emit_span_lint( + NAMED_ASM_LABELS, + span, + InvalidAsmLabel::FormatArg { missing_precise_span }, + ); + } + AsmLabelKind::Binary => { + // the binary asm issue only occurs when using intel syntax + if !options.contains(InlineAsmOptions::ATT_SYNTAX) { + cx.emit_span_lint( + BINARY_ASM_LABELS, + span, + InvalidAsmLabel::Binary { missing_precise_span, span }, + ) + } + } + }; } } } diff --git a/compiler/rustc_lint/src/lib.rs b/compiler/rustc_lint/src/lib.rs index 17f9d4421aef2..31b76b7c6ff82 100644 --- a/compiler/rustc_lint/src/lib.rs +++ b/compiler/rustc_lint/src/lib.rs @@ -220,7 +220,7 @@ late_lint_methods!( NoopMethodCall: NoopMethodCall, EnumIntrinsicsNonEnums: EnumIntrinsicsNonEnums, InvalidAtomicOrdering: InvalidAtomicOrdering, - NamedAsmLabels: NamedAsmLabels, + AsmLabels: AsmLabels, OpaqueHiddenInferredBound: OpaqueHiddenInferredBound, MultipleSupertraitUpcastable: MultipleSupertraitUpcastable, MapUnitFn: MapUnitFn, diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs index 7c5640f5959a0..b3f715c217475 100644 --- a/compiler/rustc_lint/src/lints.rs +++ b/compiler/rustc_lint/src/lints.rs @@ -2040,10 +2040,32 @@ pub struct UnitBindingsDiag { } #[derive(LintDiagnostic)] -#[diag(lint_builtin_asm_labels)] -#[help] -#[note] -pub struct BuiltinNamedAsmLabel; +pub enum InvalidAsmLabel { + #[diag(lint_invalid_asm_label_named)] + #[help] + #[note] + Named { + #[note(lint_invalid_asm_label_no_span)] + missing_precise_span: bool, + }, + #[diag(lint_invalid_asm_label_format_arg)] + #[help] + #[note(lint_note1)] + #[note(lint_note2)] + FormatArg { + #[note(lint_invalid_asm_label_no_span)] + missing_precise_span: bool, + }, + #[diag(lint_invalid_asm_label_binary)] + #[note] + Binary { + #[note(lint_invalid_asm_label_no_span)] + missing_precise_span: bool, + // hack to get a label on the whole span, must match the emitted span + #[label] + span: Span, + }, +} #[derive(Subdiagnostic)] pub enum UnexpectedCfgCargoHelp { diff --git a/tests/ui/asm/binary_asm_labels.rs b/tests/ui/asm/binary_asm_labels.rs new file mode 100644 index 0000000000000..3f545880254c2 --- /dev/null +++ b/tests/ui/asm/binary_asm_labels.rs @@ -0,0 +1,17 @@ +//@ needs-asm-support +//@ only-x86_64 + +// tests that labels containing only the digits 0 and 1 are rejected +// uses of such labels can sometimes be interpreted as a binary literal + +use std::arch::{asm, global_asm}; + +fn main() { + unsafe { + asm!("0: jmp 0b"); //~ ERROR avoid using labels containing only the digits + asm!("1: jmp 1b"); //~ ERROR avoid using labels containing only the digits + asm!("10: jmp 10b"); //~ ERROR avoid using labels containing only the digits + asm!("01: jmp 01b"); //~ ERROR avoid using labels containing only the digits + asm!("1001101: jmp 1001101b"); //~ ERROR avoid using labels containing only the digits + } +} diff --git a/tests/ui/asm/binary_asm_labels.stderr b/tests/ui/asm/binary_asm_labels.stderr new file mode 100644 index 0000000000000..1f2943084f1eb --- /dev/null +++ b/tests/ui/asm/binary_asm_labels.stderr @@ -0,0 +1,43 @@ +error: avoid using labels containing only the digits `0` and `1` in inline assembly + --> $DIR/binary_asm_labels.rs:11:15 + | +LL | asm!("0: jmp 0b"); + | ^ use a different label that doesn't start with `0` or `1` + | + = note: an LLVM bug makes these labels ambiguous with a binary literal number + = note: `#[deny(binary_asm_labels)]` on by default + +error: avoid using labels containing only the digits `0` and `1` in inline assembly + --> $DIR/binary_asm_labels.rs:12:15 + | +LL | asm!("1: jmp 1b"); + | ^ use a different label that doesn't start with `0` or `1` + | + = note: an LLVM bug makes these labels ambiguous with a binary literal number + +error: avoid using labels containing only the digits `0` and `1` in inline assembly + --> $DIR/binary_asm_labels.rs:13:15 + | +LL | asm!("10: jmp 10b"); + | ^^ use a different label that doesn't start with `0` or `1` + | + = note: an LLVM bug makes these labels ambiguous with a binary literal number + +error: avoid using labels containing only the digits `0` and `1` in inline assembly + --> $DIR/binary_asm_labels.rs:14:15 + | +LL | asm!("01: jmp 01b"); + | ^^ use a different label that doesn't start with `0` or `1` + | + = note: an LLVM bug makes these labels ambiguous with a binary literal number + +error: avoid using labels containing only the digits `0` and `1` in inline assembly + --> $DIR/binary_asm_labels.rs:15:15 + | +LL | asm!("1001101: jmp 1001101b"); + | ^^^^^^^ use a different label that doesn't start with `0` or `1` + | + = note: an LLVM bug makes these labels ambiguous with a binary literal number + +error: aborting due to 5 previous errors + diff --git a/tests/ui/asm/named-asm-labels.rs b/tests/ui/asm/named-asm-labels.rs index 96ccdef75b0ce..d2ca6fe8808bc 100644 --- a/tests/ui/asm/named-asm-labels.rs +++ b/tests/ui/asm/named-asm-labels.rs @@ -28,11 +28,13 @@ fn main() { // Multiple labels on one line asm!("foo: bar1: nop"); //~^ ERROR avoid using named labels + //~^^ ERROR avoid using named labels // Multiple lines asm!("foo1: nop", "nop"); //~ ERROR avoid using named labels asm!("foo2: foo3: nop", "nop"); //~^ ERROR avoid using named labels + //~^^ ERROR avoid using named labels asm!("nop", "foo4: nop"); //~ ERROR avoid using named labels asm!("foo5: nop", "foo6: nop"); //~^ ERROR avoid using named labels @@ -41,16 +43,19 @@ fn main() { // Statement separator asm!("foo7: nop; foo8: nop"); //~^ ERROR avoid using named labels + //~^^ ERROR avoid using named labels asm!("foo9: nop; nop"); //~ ERROR avoid using named labels asm!("nop; foo10: nop"); //~ ERROR avoid using named labels // Escaped newline asm!("bar2: nop\n bar3: nop"); //~^ ERROR avoid using named labels + //~^^ ERROR avoid using named labels asm!("bar4: nop\n nop"); //~ ERROR avoid using named labels asm!("nop\n bar5: nop"); //~ ERROR avoid using named labels asm!("nop\n bar6: bar7: nop"); //~^ ERROR avoid using named labels + //~^^ ERROR avoid using named labels // Raw strings asm!( @@ -60,6 +65,7 @@ fn main() { " ); //~^^^^ ERROR avoid using named labels + //~^^^^ ERROR avoid using named labels asm!( r###" @@ -81,9 +87,15 @@ fn main() { asm!("blah1: 2bar: nop"); //~ ERROR avoid using named labels // Duplicate labels - asm!("def: def: nop"); //~ ERROR avoid using named labels - asm!("def: nop\ndef: nop"); //~ ERROR avoid using named labels - asm!("def: nop; def: nop"); //~ ERROR avoid using named labels + asm!("def: def: nop"); + //~^ ERROR avoid using named labels + //~^^ ERROR avoid using named labels + asm!("def: nop\ndef: nop"); + //~^ ERROR avoid using named labels + //~^^ ERROR avoid using named labels + asm!("def: nop; def: nop"); + //~^ ERROR avoid using named labels + //~^^ ERROR avoid using named labels // Trying to break parsing asm!(":"); @@ -141,7 +153,11 @@ fn main() { asm!("{1}: nop", "/* {0} */", const 10, const 20); //~ ERROR avoid using named labels // Test include_str in asm - asm!(include_str!("named-asm-labels.s")); //~ ERROR avoid using named labels + asm!(include_str!("named-asm-labels.s")); + //~^ ERROR avoid using named labels + //~^^ ERROR avoid using named labels + //~^^^ ERROR avoid using named labels + //~^^^^ ERROR avoid using named labels // Test allowing or warning on the lint instead #[allow(named_asm_labels)] diff --git a/tests/ui/asm/named-asm-labels.stderr b/tests/ui/asm/named-asm-labels.stderr index 36fd69839518f..20b7d64f9e752 100644 --- a/tests/ui/asm/named-asm-labels.stderr +++ b/tests/ui/asm/named-asm-labels.stderr @@ -21,13 +21,22 @@ error: avoid using named labels in inline assembly --> $DIR/named-asm-labels.rs:29:15 | LL | asm!("foo: bar1: nop"); - | ^^^ ^^^^ + | ^^^ | = help: only local labels of the form `:` should be used in inline asm = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:33:15 + --> $DIR/named-asm-labels.rs:29:20 + | +LL | asm!("foo: bar1: nop"); + | ^^^^ + | + = help: only local labels of the form `:` should be used in inline asm + = note: see the asm section of Rust By Example for more information + +error: avoid using named labels in inline assembly + --> $DIR/named-asm-labels.rs:34:15 | LL | asm!("foo1: nop", "nop"); | ^^^^ @@ -36,16 +45,25 @@ LL | asm!("foo1: nop", "nop"); = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:34:15 + --> $DIR/named-asm-labels.rs:35:15 | LL | asm!("foo2: foo3: nop", "nop"); - | ^^^^ ^^^^ + | ^^^^ | = help: only local labels of the form `:` should be used in inline asm = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:36:22 + --> $DIR/named-asm-labels.rs:35:21 + | +LL | asm!("foo2: foo3: nop", "nop"); + | ^^^^ + | + = help: only local labels of the form `:` should be used in inline asm + = note: see the asm section of Rust By Example for more information + +error: avoid using named labels in inline assembly + --> $DIR/named-asm-labels.rs:38:22 | LL | asm!("nop", "foo4: nop"); | ^^^^ @@ -54,7 +72,7 @@ LL | asm!("nop", "foo4: nop"); = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:37:15 + --> $DIR/named-asm-labels.rs:39:15 | LL | asm!("foo5: nop", "foo6: nop"); | ^^^^ @@ -63,7 +81,7 @@ LL | asm!("foo5: nop", "foo6: nop"); = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:37:28 + --> $DIR/named-asm-labels.rs:39:28 | LL | asm!("foo5: nop", "foo6: nop"); | ^^^^ @@ -72,16 +90,25 @@ LL | asm!("foo5: nop", "foo6: nop"); = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:42:15 + --> $DIR/named-asm-labels.rs:44:15 | LL | asm!("foo7: nop; foo8: nop"); - | ^^^^ ^^^^ + | ^^^^ | = help: only local labels of the form `:` should be used in inline asm = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:44:15 + --> $DIR/named-asm-labels.rs:44:26 + | +LL | asm!("foo7: nop; foo8: nop"); + | ^^^^ + | + = help: only local labels of the form `:` should be used in inline asm + = note: see the asm section of Rust By Example for more information + +error: avoid using named labels in inline assembly + --> $DIR/named-asm-labels.rs:47:15 | LL | asm!("foo9: nop; nop"); | ^^^^ @@ -90,7 +117,7 @@ LL | asm!("foo9: nop; nop"); = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:45:20 + --> $DIR/named-asm-labels.rs:48:20 | LL | asm!("nop; foo10: nop"); | ^^^^^ @@ -99,16 +126,25 @@ LL | asm!("nop; foo10: nop"); = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:48:15 + --> $DIR/named-asm-labels.rs:51:15 | LL | asm!("bar2: nop\n bar3: nop"); - | ^^^^ ^^^^ + | ^^^^ | = help: only local labels of the form `:` should be used in inline asm = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:50:15 + --> $DIR/named-asm-labels.rs:51:27 + | +LL | asm!("bar2: nop\n bar3: nop"); + | ^^^^ + | + = help: only local labels of the form `:` should be used in inline asm + = note: see the asm section of Rust By Example for more information + +error: avoid using named labels in inline assembly + --> $DIR/named-asm-labels.rs:54:15 | LL | asm!("bar4: nop\n nop"); | ^^^^ @@ -117,7 +153,7 @@ LL | asm!("bar4: nop\n nop"); = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:51:21 + --> $DIR/named-asm-labels.rs:55:21 | LL | asm!("nop\n bar5: nop"); | ^^^^ @@ -126,19 +162,35 @@ LL | asm!("nop\n bar5: nop"); = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:52:21 + --> $DIR/named-asm-labels.rs:56:21 | LL | asm!("nop\n bar6: bar7: nop"); - | ^^^^ ^^^^ + | ^^^^ | = help: only local labels of the form `:` should be used in inline asm = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:58:13 + --> $DIR/named-asm-labels.rs:56:27 + | +LL | asm!("nop\n bar6: bar7: nop"); + | ^^^^ + | + = help: only local labels of the form `:` should be used in inline asm + = note: see the asm section of Rust By Example for more information + +error: avoid using named labels in inline assembly + --> $DIR/named-asm-labels.rs:63:13 | LL | blah2: nop | ^^^^^ + | + = help: only local labels of the form `:` should be used in inline asm + = note: see the asm section of Rust By Example for more information + +error: avoid using named labels in inline assembly + --> $DIR/named-asm-labels.rs:64:13 + | LL | blah3: nop | ^^^^^ | @@ -146,7 +198,7 @@ LL | blah3: nop = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:67:19 + --> $DIR/named-asm-labels.rs:73:19 | LL | nop ; blah4: nop | ^^^^^ @@ -155,7 +207,7 @@ LL | nop ; blah4: nop = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:81:15 + --> $DIR/named-asm-labels.rs:87:15 | LL | asm!("blah1: 2bar: nop"); | ^^^^^ @@ -164,7 +216,7 @@ LL | asm!("blah1: 2bar: nop"); = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:84:15 + --> $DIR/named-asm-labels.rs:90:15 | LL | asm!("def: def: nop"); | ^^^ @@ -173,7 +225,17 @@ LL | asm!("def: def: nop"); = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:85:15 + --> $DIR/named-asm-labels.rs:90:15 + | +LL | asm!("def: def: nop"); + | ^^^ + | + = help: only local labels of the form `:` should be used in inline asm + = note: see the asm section of Rust By Example for more information + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: avoid using named labels in inline assembly + --> $DIR/named-asm-labels.rs:93:15 | LL | asm!("def: nop\ndef: nop"); | ^^^ @@ -182,16 +244,36 @@ LL | asm!("def: nop\ndef: nop"); = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:86:15 + --> $DIR/named-asm-labels.rs:93:15 + | +LL | asm!("def: nop\ndef: nop"); + | ^^^ + | + = help: only local labels of the form `:` should be used in inline asm + = note: see the asm section of Rust By Example for more information + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: avoid using named labels in inline assembly + --> $DIR/named-asm-labels.rs:96:15 + | +LL | asm!("def: nop; def: nop"); + | ^^^ + | + = help: only local labels of the form `:` should be used in inline asm + = note: see the asm section of Rust By Example for more information + +error: avoid using named labels in inline assembly + --> $DIR/named-asm-labels.rs:96:15 | LL | asm!("def: nop; def: nop"); | ^^^ | = help: only local labels of the form `:` should be used in inline asm = note: see the asm section of Rust By Example for more information + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:94:15 + --> $DIR/named-asm-labels.rs:106:15 | LL | asm!("fooo\u{003A} nop"); | ^^^^^^^^^^^^^^^^ @@ -200,7 +282,7 @@ LL | asm!("fooo\u{003A} nop"); = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:95:15 + --> $DIR/named-asm-labels.rs:107:15 | LL | asm!("foooo\x3A nop"); | ^^^^^^^^^^^^^ @@ -209,7 +291,7 @@ LL | asm!("foooo\x3A nop"); = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:98:15 + --> $DIR/named-asm-labels.rs:110:15 | LL | asm!("fooooo:\u{000A} nop"); | ^^^^^^ @@ -218,7 +300,7 @@ LL | asm!("fooooo:\u{000A} nop"); = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:99:15 + --> $DIR/named-asm-labels.rs:111:15 | LL | asm!("foooooo:\x0A nop"); | ^^^^^^^ @@ -227,16 +309,17 @@ LL | asm!("foooooo:\x0A nop"); = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:103:14 + --> $DIR/named-asm-labels.rs:115:14 | LL | asm!("\x41\x42\x43\x3A\x20\x6E\x6F\x70"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: only local labels of the form `:` should be used in inline asm = note: see the asm section of Rust By Example for more information + = note: the label may be declared in the expansion of a macro error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:111:13 + --> $DIR/named-asm-labels.rs:123:13 | LL | ab: nop // ab: does foo | ^^ @@ -245,97 +328,140 @@ LL | ab: nop // ab: does foo = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:131:19 + --> $DIR/named-asm-labels.rs:143:19 | LL | asm!("test_{}: nop", in(reg) 10); | ^^^^^^^ | = help: only local labels of the form `:` should be used in inline asm + = note: format arguments may expand to a non-numeric value = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:133:15 + --> $DIR/named-asm-labels.rs:145:15 | LL | asm!("test_{}: nop", const 10); | ^^^^^^^ | = help: only local labels of the form `:` should be used in inline asm + = note: format arguments may expand to a non-numeric value = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:134:15 + --> $DIR/named-asm-labels.rs:146:15 | LL | asm!("test_{}: nop", sym main); | ^^^^^^^ | = help: only local labels of the form `:` should be used in inline asm + = note: format arguments may expand to a non-numeric value = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:135:15 + --> $DIR/named-asm-labels.rs:147:15 | LL | asm!("{}_test: nop", const 10); | ^^^^^^^ | = help: only local labels of the form `:` should be used in inline asm + = note: format arguments may expand to a non-numeric value = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:136:15 + --> $DIR/named-asm-labels.rs:148:15 | LL | asm!("test_{}_test: nop", const 10); | ^^^^^^^^^^^^ | = help: only local labels of the form `:` should be used in inline asm + = note: format arguments may expand to a non-numeric value = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:137:15 + --> $DIR/named-asm-labels.rs:149:15 | LL | asm!("{}: nop", const 10); | ^^ | = help: only local labels of the form `:` should be used in inline asm + = note: format arguments may expand to a non-numeric value = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:139:15 + --> $DIR/named-asm-labels.rs:151:15 | LL | asm!("{uwu}: nop", uwu = const 10); | ^^^^^ | = help: only local labels of the form `:` should be used in inline asm + = note: format arguments may expand to a non-numeric value = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:140:15 + --> $DIR/named-asm-labels.rs:152:15 | LL | asm!("{0}: nop", const 10); | ^^^ | = help: only local labels of the form `:` should be used in inline asm + = note: format arguments may expand to a non-numeric value = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:141:15 + --> $DIR/named-asm-labels.rs:153:15 | LL | asm!("{1}: nop", "/* {0} */", const 10, const 20); | ^^^ | = help: only local labels of the form `:` should be used in inline asm + = note: format arguments may expand to a non-numeric value + = note: see the asm section of Rust By Example for more information + +error: avoid using named labels in inline assembly + --> $DIR/named-asm-labels.rs:156:14 + | +LL | asm!(include_str!("named-asm-labels.s")); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: only local labels of the form `:` should be used in inline asm + = note: see the asm section of Rust By Example for more information + = note: the label may be declared in the expansion of a macro + +error: avoid using named labels in inline assembly + --> $DIR/named-asm-labels.rs:156:14 + | +LL | asm!(include_str!("named-asm-labels.s")); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: only local labels of the form `:` should be used in inline asm + = note: see the asm section of Rust By Example for more information + = note: the label may be declared in the expansion of a macro + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: avoid using named labels in inline assembly + --> $DIR/named-asm-labels.rs:156:14 + | +LL | asm!(include_str!("named-asm-labels.s")); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: only local labels of the form `:` should be used in inline asm = note: see the asm section of Rust By Example for more information + = note: the label may be declared in the expansion of a macro + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:144:14 + --> $DIR/named-asm-labels.rs:156:14 | LL | asm!(include_str!("named-asm-labels.s")); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: only local labels of the form `:` should be used in inline asm = note: see the asm section of Rust By Example for more information + = note: the label may be declared in the expansion of a macro + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` warning: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:154:19 + --> $DIR/named-asm-labels.rs:170:19 | LL | asm!("warned: nop"); | ^^^^^^ @@ -343,13 +469,13 @@ LL | asm!("warned: nop"); = help: only local labels of the form `:` should be used in inline asm = note: see the asm section of Rust By Example for more information note: the lint level is defined here - --> $DIR/named-asm-labels.rs:152:16 + --> $DIR/named-asm-labels.rs:168:16 | LL | #[warn(named_asm_labels)] | ^^^^^^^^^^^^^^^^ error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:163:20 + --> $DIR/named-asm-labels.rs:179:20 | LL | unsafe { asm!(".Lfoo: mov rax, {}; ret;", "nop", const 1, options(noreturn)) } | ^^^^^ @@ -358,7 +484,7 @@ LL | unsafe { asm!(".Lfoo: mov rax, {}; ret;", "nop", const 1, options(noret = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:169:20 + --> $DIR/named-asm-labels.rs:185:20 | LL | unsafe { asm!(".Lbar: mov rax, {}; ret;", "nop", const 1, options(noreturn)) } | ^^^^^ @@ -367,7 +493,7 @@ LL | unsafe { asm!(".Lbar: mov rax, {}; ret;", "nop", const 1, options(noret = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:177:20 + --> $DIR/named-asm-labels.rs:193:20 | LL | unsafe { asm!(".Laaa: nop; ret;", options(noreturn)) } | ^^^^^ @@ -376,7 +502,7 @@ LL | unsafe { asm!(".Laaa: nop; ret;", options(noreturn)) } = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:187:24 + --> $DIR/named-asm-labels.rs:203:24 | LL | unsafe { asm!(".Lbbb: nop; ret;", options(noreturn)) } | ^^^^^ @@ -385,7 +511,7 @@ LL | unsafe { asm!(".Lbbb: nop; ret;", options(noreturn)) } = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:196:15 + --> $DIR/named-asm-labels.rs:212:15 | LL | asm!("closure1: nop"); | ^^^^^^^^ @@ -394,7 +520,7 @@ LL | asm!("closure1: nop"); = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:200:15 + --> $DIR/named-asm-labels.rs:216:15 | LL | asm!("closure2: nop"); | ^^^^^^^^ @@ -403,7 +529,7 @@ LL | asm!("closure2: nop"); = note: see the asm section of Rust By Example for more information error: avoid using named labels in inline assembly - --> $DIR/named-asm-labels.rs:210:19 + --> $DIR/named-asm-labels.rs:226:19 | LL | asm!("closure3: nop"); | ^^^^^^^^ @@ -411,5 +537,5 @@ LL | asm!("closure3: nop"); = help: only local labels of the form `:` should be used in inline asm = note: see the asm section of Rust By Example for more information -error: aborting due to 44 previous errors; 1 warning emitted +error: aborting due to 56 previous errors; 1 warning emitted