Rollup merge of #88196 - asquared31415:named-asm-labels-refactor, r=Amanieu
Refactor `named_asm_labels` to a HIR lint As discussed on #88169, the `named_asm_labels` lint could be moved to a HIR lint. That allows future lints or custom plugins or clippy lints to more easily access the `asm!` macro's data and create better error messages with the lints.
This commit is contained in:
commit
891fa3c555
10 changed files with 304 additions and 147 deletions
|
@ -2028,6 +2028,7 @@ pub enum InlineAsmOperand {
|
|||
#[derive(Clone, Encodable, Decodable, Debug)]
|
||||
pub struct InlineAsm {
|
||||
pub template: Vec<InlineAsmTemplatePiece>,
|
||||
pub template_strs: Box<[(Symbol, Option<Symbol>, Span)]>,
|
||||
pub operands: Vec<(InlineAsmOperand, Span)>,
|
||||
pub clobber_abi: Option<(Symbol, Span)>,
|
||||
pub options: InlineAsmOptions,
|
||||
|
|
|
@ -19,20 +19,20 @@ use crate::token;
|
|||
use rustc_span::symbol::{Ident, Symbol};
|
||||
use rustc_span::Span;
|
||||
|
||||
#[derive(Copy, Clone, PartialEq)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||
pub enum AssocCtxt {
|
||||
Trait,
|
||||
Impl,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, PartialEq)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||
pub enum FnCtxt {
|
||||
Free,
|
||||
Foreign,
|
||||
Assoc(AssocCtxt),
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub enum FnKind<'a> {
|
||||
/// E.g., `fn foo()`, `fn foo(&self)`, or `extern "Abi" fn foo()`.
|
||||
Fn(FnCtxt, Ident, &'a FnSig, &'a Visibility, Option<&'a Block>),
|
||||
|
|
|
@ -392,8 +392,10 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||
|
||||
let operands = self.arena.alloc_from_iter(operands);
|
||||
let template = self.arena.alloc_from_iter(asm.template.iter().cloned());
|
||||
let template_strs = self.arena.alloc_from_iter(asm.template_strs.iter().cloned());
|
||||
let line_spans = self.arena.alloc_slice(&asm.line_spans[..]);
|
||||
let hir_asm = hir::InlineAsm { template, operands, options: asm.options, line_spans };
|
||||
let hir_asm =
|
||||
hir::InlineAsm { template, template_strs, operands, options: asm.options, line_spans };
|
||||
self.arena.alloc(hir_asm)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,10 +7,10 @@ use rustc_errors::{Applicability, DiagnosticBuilder};
|
|||
use rustc_expand::base::{self, *};
|
||||
use rustc_parse::parser::Parser;
|
||||
use rustc_parse_format as parse;
|
||||
use rustc_session::lint::{self, BuiltinLintDiagnostics};
|
||||
use rustc_session::lint;
|
||||
use rustc_span::symbol::Ident;
|
||||
use rustc_span::symbol::{kw, sym, Symbol};
|
||||
use rustc_span::{InnerSpan, MultiSpan, Span};
|
||||
use rustc_span::{InnerSpan, Span};
|
||||
use rustc_target::asm::InlineAsmArch;
|
||||
use smallvec::smallvec;
|
||||
|
||||
|
@ -484,11 +484,7 @@ fn parse_reg<'a>(
|
|||
Ok(result)
|
||||
}
|
||||
|
||||
fn expand_preparsed_asm(
|
||||
ecx: &mut ExtCtxt<'_>,
|
||||
args: AsmArgs,
|
||||
is_local_asm: bool,
|
||||
) -> Option<ast::InlineAsm> {
|
||||
fn expand_preparsed_asm(ecx: &mut ExtCtxt<'_>, args: AsmArgs) -> Option<ast::InlineAsm> {
|
||||
let mut template = vec![];
|
||||
// Register operands are implicitly used since they are not allowed to be
|
||||
// referenced in the template string.
|
||||
|
@ -501,6 +497,8 @@ fn expand_preparsed_asm(
|
|||
let mut line_spans = Vec::with_capacity(args.templates.len());
|
||||
let mut curarg = 0;
|
||||
|
||||
let mut template_strs = Vec::with_capacity(args.templates.len());
|
||||
|
||||
for template_expr in args.templates.into_iter() {
|
||||
if !template.is_empty() {
|
||||
template.push(ast::InlineAsmTemplatePiece::String("\n".to_string()));
|
||||
|
@ -524,8 +522,13 @@ fn expand_preparsed_asm(
|
|||
ast::StrStyle::Raw(raw) => Some(raw as usize),
|
||||
};
|
||||
|
||||
let template_str = &template_str.as_str();
|
||||
let template_snippet = ecx.source_map().span_to_snippet(template_sp).ok();
|
||||
template_strs.push((
|
||||
template_str,
|
||||
template_snippet.as_ref().map(|s| Symbol::intern(s)),
|
||||
template_sp,
|
||||
));
|
||||
let template_str = &template_str.as_str();
|
||||
|
||||
if let Some(InlineAsmArch::X86 | InlineAsmArch::X86_64) = ecx.sess.asm_arch {
|
||||
let find_span = |needle: &str| -> Span {
|
||||
|
@ -560,72 +563,6 @@ fn expand_preparsed_asm(
|
|||
}
|
||||
}
|
||||
|
||||
// Lint against the use of named labels in inline `asm!` but not `global_asm!`
|
||||
if is_local_asm {
|
||||
let find_label_span = |needle: &str| -> Option<Span> {
|
||||
if let Some(snippet) = &template_snippet {
|
||||
if let Some(pos) = snippet.find(needle) {
|
||||
let end = pos
|
||||
+ &snippet[pos..]
|
||||
.find(|c| c == ':')
|
||||
.unwrap_or(snippet[pos..].len() - 1);
|
||||
let inner = InnerSpan::new(pos, end);
|
||||
return Some(template_sp.from_inner(inner));
|
||||
}
|
||||
}
|
||||
|
||||
None
|
||||
};
|
||||
|
||||
let mut found_labels = Vec::new();
|
||||
|
||||
// A semicolon might not actually be specified as a separator for all targets, but it seems like LLVM accepts it always
|
||||
let statements = template_str.split(|c| matches!(c, '\n' | ';'));
|
||||
for statement in statements {
|
||||
// If there's a comment, trim it from the statement
|
||||
let statement = statement.find("//").map_or(statement, |idx| &statement[..idx]);
|
||||
let mut start_idx = 0;
|
||||
for (idx, _) in statement.match_indices(':') {
|
||||
let possible_label = statement[start_idx..idx].trim();
|
||||
let mut chars = possible_label.chars();
|
||||
if let Some(c) = chars.next() {
|
||||
// A label starts with an alphabetic character or . or _ and continues with alphanumeric characters, _, or $
|
||||
if (c.is_alphabetic() || matches!(c, '.' | '_'))
|
||||
&& chars.all(|c| c.is_alphanumeric() || matches!(c, '_' | '$'))
|
||||
{
|
||||
found_labels.push(possible_label);
|
||||
} else {
|
||||
// If we encounter a non-label, there cannot be any further labels, so stop checking
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// Empty string means a leading ':' in this section, which is not a label
|
||||
break;
|
||||
}
|
||||
|
||||
start_idx = idx + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if found_labels.len() > 0 {
|
||||
let spans =
|
||||
found_labels.into_iter().filter_map(find_label_span).collect::<Vec<Span>>();
|
||||
// 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_sp.into() };
|
||||
ecx.parse_sess().buffer_lint_with_diagnostic(
|
||||
lint::builtin::NAMED_ASM_LABELS,
|
||||
target_spans,
|
||||
ecx.current_expansion.lint_node_id,
|
||||
"avoid using named labels in inline assembly",
|
||||
BuiltinLintDiagnostics::NamedAsmLabel(
|
||||
"only local labels of the form `<number>:` should be used in inline asm"
|
||||
.to_string(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Don't treat raw asm as a format string.
|
||||
if args.options.contains(ast::InlineAsmOptions::RAW) {
|
||||
template.push(ast::InlineAsmTemplatePiece::String(template_str.to_string()));
|
||||
|
@ -819,6 +756,7 @@ fn expand_preparsed_asm(
|
|||
|
||||
Some(ast::InlineAsm {
|
||||
template,
|
||||
template_strs: template_strs.into_boxed_slice(),
|
||||
operands: args.operands,
|
||||
clobber_abi: args.clobber_abi,
|
||||
options: args.options,
|
||||
|
@ -833,7 +771,7 @@ pub fn expand_asm<'cx>(
|
|||
) -> Box<dyn base::MacResult + 'cx> {
|
||||
match parse_args(ecx, sp, tts, false) {
|
||||
Ok(args) => {
|
||||
let expr = if let Some(inline_asm) = expand_preparsed_asm(ecx, args, true) {
|
||||
let expr = if let Some(inline_asm) = expand_preparsed_asm(ecx, args) {
|
||||
P(ast::Expr {
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
kind: ast::ExprKind::InlineAsm(P(inline_asm)),
|
||||
|
@ -860,7 +798,7 @@ pub fn expand_global_asm<'cx>(
|
|||
) -> Box<dyn base::MacResult + 'cx> {
|
||||
match parse_args(ecx, sp, tts, true) {
|
||||
Ok(args) => {
|
||||
if let Some(inline_asm) = expand_preparsed_asm(ecx, args, false) {
|
||||
if let Some(inline_asm) = expand_preparsed_asm(ecx, args) {
|
||||
MacEager::items(smallvec![P(ast::Item {
|
||||
ident: Ident::invalid(),
|
||||
attrs: Vec::new(),
|
||||
|
|
|
@ -2386,6 +2386,7 @@ impl<'hir> InlineAsmOperand<'hir> {
|
|||
#[derive(Debug, HashStable_Generic)]
|
||||
pub struct InlineAsm<'hir> {
|
||||
pub template: &'hir [InlineAsmTemplatePiece],
|
||||
pub template_strs: &'hir [(Symbol, Option<Symbol>, Span)],
|
||||
pub operands: &'hir [(InlineAsmOperand<'hir>, Span)],
|
||||
pub options: InlineAsmOptions,
|
||||
pub line_spans: &'hir [Span],
|
||||
|
|
|
@ -45,11 +45,11 @@ use rustc_middle::ty::print::with_no_trimmed_paths;
|
|||
use rustc_middle::ty::subst::{GenericArgKind, Subst};
|
||||
use rustc_middle::ty::Instance;
|
||||
use rustc_middle::ty::{self, layout::LayoutError, Ty, TyCtxt};
|
||||
use rustc_session::lint::FutureIncompatibilityReason;
|
||||
use rustc_session::lint::{BuiltinLintDiagnostics, FutureIncompatibilityReason};
|
||||
use rustc_span::edition::Edition;
|
||||
use rustc_span::source_map::Spanned;
|
||||
use rustc_span::symbol::{kw, sym, Ident, Symbol};
|
||||
use rustc_span::{BytePos, Span};
|
||||
use rustc_span::{BytePos, InnerSpan, MultiSpan, Span};
|
||||
use rustc_target::abi::{LayoutOf, VariantIdx};
|
||||
use rustc_trait_selection::traits::misc::can_type_implement_copy;
|
||||
|
||||
|
@ -3140,3 +3140,123 @@ impl<'tcx> LateLintPass<'tcx> for DerefNullPtr {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
declare_lint! {
|
||||
/// The `named_asm_labels` lint detects the use of named labels in the
|
||||
/// inline `asm!` macro.
|
||||
///
|
||||
/// ### Example
|
||||
///
|
||||
/// ```rust,compile_fail
|
||||
/// #![feature(asm)]
|
||||
/// fn main() {
|
||||
/// unsafe {
|
||||
/// asm!("foo: bar");
|
||||
/// }
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// {{produces}}
|
||||
///
|
||||
/// ### Explanation
|
||||
///
|
||||
/// LLVM is allowed to duplicate inline assembly blocks for any
|
||||
/// reason, for example when it is in a function that gets inlined. Because
|
||||
/// of this, GNU assembler [local labels] *must* be used instead of labels
|
||||
/// with a name. Using named labels might cause assembler or linker errors.
|
||||
///
|
||||
/// See the [unstable book] for more details.
|
||||
///
|
||||
/// [local labels]: https://sourceware.org/binutils/docs/as/Symbol-Names.html#Local-Labels
|
||||
/// [unstable book]: https://doc.rust-lang.org/nightly/unstable-book/library-features/asm.html#labels
|
||||
pub NAMED_ASM_LABELS,
|
||||
Deny,
|
||||
"named labels in inline assembly",
|
||||
}
|
||||
|
||||
declare_lint_pass!(NamedAsmLabels => [NAMED_ASM_LABELS]);
|
||||
|
||||
impl<'tcx> LateLintPass<'tcx> for NamedAsmLabels {
|
||||
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, .. }),
|
||||
..
|
||||
} = expr
|
||||
{
|
||||
for (template_sym, template_snippet, template_span) in template_strs.iter() {
|
||||
let template_str = &template_sym.as_str();
|
||||
let find_label_span = |needle: &str| -> Option<Span> {
|
||||
if let Some(template_snippet) = template_snippet {
|
||||
let snippet = template_snippet.as_str();
|
||||
if let Some(pos) = snippet.find(needle) {
|
||||
let end = pos
|
||||
+ &snippet[pos..]
|
||||
.find(|c| c == ':')
|
||||
.unwrap_or(snippet[pos..].len() - 1);
|
||||
let inner = InnerSpan::new(pos, end);
|
||||
return Some(template_span.from_inner(inner));
|
||||
}
|
||||
}
|
||||
|
||||
None
|
||||
};
|
||||
|
||||
let mut found_labels = Vec::new();
|
||||
|
||||
// A semicolon might not actually be specified as a separator for all targets, but it seems like LLVM accepts it always
|
||||
let statements = template_str.split(|c| matches!(c, '\n' | ';'));
|
||||
for statement in statements {
|
||||
// If there's a comment, trim it from the statement
|
||||
let statement = statement.find("//").map_or(statement, |idx| &statement[..idx]);
|
||||
let mut start_idx = 0;
|
||||
for (idx, _) in statement.match_indices(':') {
|
||||
let possible_label = statement[start_idx..idx].trim();
|
||||
let mut chars = possible_label.chars();
|
||||
if let Some(c) = chars.next() {
|
||||
// A label starts with an alphabetic character or . or _ and continues with alphanumeric characters, _, or $
|
||||
if (c.is_alphabetic() || matches!(c, '.' | '_'))
|
||||
&& chars.all(|c| c.is_alphanumeric() || matches!(c, '_' | '$'))
|
||||
{
|
||||
found_labels.push(possible_label);
|
||||
} else {
|
||||
// If we encounter a non-label, there cannot be any further labels, so stop checking
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// Empty string means a leading ':' in this section, which is not a label
|
||||
break;
|
||||
}
|
||||
|
||||
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::<Vec<Span>>();
|
||||
// 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.lookup_with_diagnostics(
|
||||
NAMED_ASM_LABELS,
|
||||
Some(target_spans),
|
||||
|diag| {
|
||||
let mut err =
|
||||
diag.build("avoid using named labels in inline assembly");
|
||||
err.emit();
|
||||
},
|
||||
BuiltinLintDiagnostics::NamedAsmLabel(
|
||||
"only local labels of the form `<number>:` should be used in inline asm"
|
||||
.to_string(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -168,6 +168,7 @@ macro_rules! late_lint_passes {
|
|||
NonPanicFmt: NonPanicFmt,
|
||||
NoopMethodCall: NoopMethodCall,
|
||||
InvalidAtomicOrdering: InvalidAtomicOrdering,
|
||||
NamedAsmLabels: NamedAsmLabels,
|
||||
]
|
||||
);
|
||||
};
|
||||
|
|
|
@ -2468,38 +2468,6 @@ declare_lint! {
|
|||
"incorrect use of inline assembly",
|
||||
}
|
||||
|
||||
declare_lint! {
|
||||
/// The `named_asm_labels` lint detects the use of named labels in the
|
||||
/// inline `asm!` macro.
|
||||
///
|
||||
/// ### Example
|
||||
///
|
||||
/// ```rust,compile_fail
|
||||
/// fn main() {
|
||||
/// unsafe {
|
||||
/// asm!("foo: bar");
|
||||
/// }
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// {{produces}}
|
||||
///
|
||||
/// ### Explanation
|
||||
///
|
||||
/// LLVM is allowed to duplicate inline assembly blocks for any
|
||||
/// reason, for example when it is in a function that gets inlined. Because
|
||||
/// of this, GNU assembler [local labels] *must* be used instead of labels
|
||||
/// with a name. Using named labels might cause assembler or linker errors.
|
||||
///
|
||||
/// See the [unstable book] for more details.
|
||||
///
|
||||
/// [local labels]: https://sourceware.org/binutils/docs/as/Symbol-Names.html#Local-Labels
|
||||
/// [unstable book]: https://doc.rust-lang.org/nightly/unstable-book/library-features/asm.html#labels
|
||||
pub NAMED_ASM_LABELS,
|
||||
Deny,
|
||||
"named labels in inline assembly",
|
||||
}
|
||||
|
||||
declare_lint! {
|
||||
/// The `unsafe_op_in_unsafe_fn` lint detects unsafe operations in unsafe
|
||||
/// functions without an explicit unsafe block.
|
||||
|
@ -3020,7 +2988,6 @@ declare_lint_pass! {
|
|||
INLINE_NO_SANITIZE,
|
||||
BAD_ASM_STYLE,
|
||||
ASM_SUB_REGISTER,
|
||||
NAMED_ASM_LABELS,
|
||||
UNSAFE_OP_IN_UNSAFE_FN,
|
||||
INCOMPLETE_INCLUDE,
|
||||
CENUM_IMPL_DROP_CAST,
|
||||
|
|
|
@ -1,6 +1,14 @@
|
|||
// only-x86_64
|
||||
|
||||
#![feature(asm, global_asm)]
|
||||
// Tests that the use of named labels in the `asm!` macro are linted against
|
||||
// except for in `#[naked]` fns.
|
||||
// Using a named label is incorrect as per the RFC because for most cases
|
||||
// the compiler cannot ensure that inline asm is emitted exactly once per
|
||||
// codegen unit (except for naked fns) and so the label could be duplicated
|
||||
// which causes less readable LLVM errors and in the worst cases causes ICEs
|
||||
// or segfaults based on system dependent behavior and codegen flags.
|
||||
|
||||
#![feature(asm, global_asm, naked_functions)]
|
||||
|
||||
#[no_mangle]
|
||||
pub static FOO: usize = 42;
|
||||
|
@ -126,5 +134,61 @@ fn main() {
|
|||
}
|
||||
}
|
||||
|
||||
// Trigger on naked fns too, even though they can't be inlined, reusing a
|
||||
// label or LTO can cause labels to break
|
||||
#[naked]
|
||||
pub extern "C" fn foo() -> i32 {
|
||||
unsafe { asm!(".Lfoo: mov rax, {}; ret;", "nop", const 1, options(noreturn)) } //~ ERROR avoid using named labels
|
||||
}
|
||||
|
||||
// Make sure that non-naked attributes *do* still let the lint happen
|
||||
#[no_mangle]
|
||||
pub extern "C" fn bar() {
|
||||
unsafe { asm!(".Lbar: mov rax, {}; ret;", "nop", const 1, options(noreturn)) }
|
||||
//~^ ERROR avoid using named labels
|
||||
}
|
||||
|
||||
#[naked]
|
||||
pub extern "C" fn aaa() {
|
||||
fn _local() {}
|
||||
|
||||
unsafe { asm!(".Laaa: nop; ret;", options(noreturn)) } //~ ERROR avoid using named labels
|
||||
}
|
||||
|
||||
pub fn normal() {
|
||||
fn _local1() {}
|
||||
|
||||
#[naked]
|
||||
pub extern "C" fn bbb() {
|
||||
fn _very_local() {}
|
||||
|
||||
unsafe { asm!(".Lbbb: nop; ret;", options(noreturn)) } //~ ERROR avoid using named labels
|
||||
}
|
||||
|
||||
fn _local2() {}
|
||||
}
|
||||
|
||||
// Make sure that the lint happens within closures
|
||||
fn closures() {
|
||||
|| unsafe {
|
||||
asm!("closure1: nop"); //~ ERROR avoid using named labels
|
||||
};
|
||||
|
||||
move || unsafe {
|
||||
asm!("closure2: nop"); //~ ERROR avoid using named labels
|
||||
};
|
||||
|
||||
|| {
|
||||
#[naked]
|
||||
unsafe extern "C" fn _nested() {
|
||||
asm!("ret;", options(noreturn));
|
||||
}
|
||||
|
||||
unsafe {
|
||||
asm!("closure3: nop"); //~ ERROR avoid using named labels
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Don't trigger on global asm
|
||||
global_asm!("aaaaaaaa: nop");
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error: avoid using named labels in inline assembly
|
||||
--> $DIR/named-asm-labels.rs:11:15
|
||||
--> $DIR/named-asm-labels.rs:19:15
|
||||
|
|
||||
LL | asm!("bar: nop");
|
||||
| ^^^
|
||||
|
@ -9,7 +9,7 @@ LL | asm!("bar: nop");
|
|||
= 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
|
||||
|
||||
error: avoid using named labels in inline assembly
|
||||
--> $DIR/named-asm-labels.rs:14:15
|
||||
--> $DIR/named-asm-labels.rs:22:15
|
||||
|
|
||||
LL | asm!("abcd:");
|
||||
| ^^^^
|
||||
|
@ -18,7 +18,7 @@ LL | asm!("abcd:");
|
|||
= 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
|
||||
|
||||
error: avoid using named labels in inline assembly
|
||||
--> $DIR/named-asm-labels.rs:17:15
|
||||
--> $DIR/named-asm-labels.rs:25:15
|
||||
|
|
||||
LL | asm!("foo: bar1: nop");
|
||||
| ^^^ ^^^^
|
||||
|
@ -27,7 +27,7 @@ LL | asm!("foo: bar1: nop");
|
|||
= 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
|
||||
|
||||
error: avoid using named labels in inline assembly
|
||||
--> $DIR/named-asm-labels.rs:21:15
|
||||
--> $DIR/named-asm-labels.rs:29:15
|
||||
|
|
||||
LL | asm!("foo1: nop", "nop");
|
||||
| ^^^^
|
||||
|
@ -36,7 +36,7 @@ LL | asm!("foo1: nop", "nop");
|
|||
= 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
|
||||
|
||||
error: avoid using named labels in inline assembly
|
||||
--> $DIR/named-asm-labels.rs:22:15
|
||||
--> $DIR/named-asm-labels.rs:30:15
|
||||
|
|
||||
LL | asm!("foo2: foo3: nop", "nop");
|
||||
| ^^^^ ^^^^
|
||||
|
@ -45,7 +45,7 @@ LL | asm!("foo2: foo3: nop", "nop");
|
|||
= 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
|
||||
|
||||
error: avoid using named labels in inline assembly
|
||||
--> $DIR/named-asm-labels.rs:24:22
|
||||
--> $DIR/named-asm-labels.rs:32:22
|
||||
|
|
||||
LL | asm!("nop", "foo4: nop");
|
||||
| ^^^^
|
||||
|
@ -54,7 +54,7 @@ LL | asm!("nop", "foo4: nop");
|
|||
= 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
|
||||
|
||||
error: avoid using named labels in inline assembly
|
||||
--> $DIR/named-asm-labels.rs:25:15
|
||||
--> $DIR/named-asm-labels.rs:33:15
|
||||
|
|
||||
LL | asm!("foo5: nop", "foo6: nop");
|
||||
| ^^^^
|
||||
|
@ -63,7 +63,7 @@ LL | asm!("foo5: nop", "foo6: nop");
|
|||
= 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
|
||||
|
||||
error: avoid using named labels in inline assembly
|
||||
--> $DIR/named-asm-labels.rs:25:28
|
||||
--> $DIR/named-asm-labels.rs:33:28
|
||||
|
|
||||
LL | asm!("foo5: nop", "foo6: nop");
|
||||
| ^^^^
|
||||
|
@ -72,7 +72,7 @@ LL | asm!("foo5: nop", "foo6: nop");
|
|||
= 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
|
||||
|
||||
error: avoid using named labels in inline assembly
|
||||
--> $DIR/named-asm-labels.rs:30:15
|
||||
--> $DIR/named-asm-labels.rs:38:15
|
||||
|
|
||||
LL | asm!("foo7: nop; foo8: nop");
|
||||
| ^^^^ ^^^^
|
||||
|
@ -81,7 +81,7 @@ LL | asm!("foo7: nop; foo8: nop");
|
|||
= 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
|
||||
|
||||
error: avoid using named labels in inline assembly
|
||||
--> $DIR/named-asm-labels.rs:32:15
|
||||
--> $DIR/named-asm-labels.rs:40:15
|
||||
|
|
||||
LL | asm!("foo9: nop; nop");
|
||||
| ^^^^
|
||||
|
@ -90,7 +90,7 @@ LL | asm!("foo9: nop; nop");
|
|||
= 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
|
||||
|
||||
error: avoid using named labels in inline assembly
|
||||
--> $DIR/named-asm-labels.rs:33:20
|
||||
--> $DIR/named-asm-labels.rs:41:20
|
||||
|
|
||||
LL | asm!("nop; foo10: nop");
|
||||
| ^^^^^
|
||||
|
@ -99,7 +99,7 @@ LL | asm!("nop; foo10: nop");
|
|||
= 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
|
||||
|
||||
error: avoid using named labels in inline assembly
|
||||
--> $DIR/named-asm-labels.rs:36:15
|
||||
--> $DIR/named-asm-labels.rs:44:15
|
||||
|
|
||||
LL | asm!("bar2: nop\n bar3: nop");
|
||||
| ^^^^ ^^^^
|
||||
|
@ -108,7 +108,7 @@ LL | asm!("bar2: nop\n bar3: nop");
|
|||
= 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
|
||||
|
||||
error: avoid using named labels in inline assembly
|
||||
--> $DIR/named-asm-labels.rs:38:15
|
||||
--> $DIR/named-asm-labels.rs:46:15
|
||||
|
|
||||
LL | asm!("bar4: nop\n nop");
|
||||
| ^^^^
|
||||
|
@ -117,7 +117,7 @@ LL | asm!("bar4: nop\n nop");
|
|||
= 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
|
||||
|
||||
error: avoid using named labels in inline assembly
|
||||
--> $DIR/named-asm-labels.rs:39:21
|
||||
--> $DIR/named-asm-labels.rs:47:21
|
||||
|
|
||||
LL | asm!("nop\n bar5: nop");
|
||||
| ^^^^
|
||||
|
@ -126,7 +126,7 @@ LL | asm!("nop\n bar5: nop");
|
|||
= 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
|
||||
|
||||
error: avoid using named labels in inline assembly
|
||||
--> $DIR/named-asm-labels.rs:40:21
|
||||
--> $DIR/named-asm-labels.rs:48:21
|
||||
|
|
||||
LL | asm!("nop\n bar6: bar7: nop");
|
||||
| ^^^^ ^^^^
|
||||
|
@ -135,7 +135,7 @@ LL | asm!("nop\n bar6: bar7: nop");
|
|||
= 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
|
||||
|
||||
error: avoid using named labels in inline assembly
|
||||
--> $DIR/named-asm-labels.rs:46:13
|
||||
--> $DIR/named-asm-labels.rs:54:13
|
||||
|
|
||||
LL | blah2: nop
|
||||
| ^^^^^
|
||||
|
@ -146,7 +146,7 @@ LL | blah3: nop
|
|||
= 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
|
||||
|
||||
error: avoid using named labels in inline assembly
|
||||
--> $DIR/named-asm-labels.rs:55:19
|
||||
--> $DIR/named-asm-labels.rs:63:19
|
||||
|
|
||||
LL | nop ; blah4: nop
|
||||
| ^^^^^
|
||||
|
@ -155,7 +155,7 @@ LL | nop ; blah4: nop
|
|||
= 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
|
||||
|
||||
error: avoid using named labels in inline assembly
|
||||
--> $DIR/named-asm-labels.rs:69:15
|
||||
--> $DIR/named-asm-labels.rs:77:15
|
||||
|
|
||||
LL | asm!("blah1: 2bar: nop");
|
||||
| ^^^^^
|
||||
|
@ -164,7 +164,7 @@ LL | asm!("blah1: 2bar: nop");
|
|||
= 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
|
||||
|
||||
error: avoid using named labels in inline assembly
|
||||
--> $DIR/named-asm-labels.rs:72:15
|
||||
--> $DIR/named-asm-labels.rs:80:15
|
||||
|
|
||||
LL | asm!("def: def: nop");
|
||||
| ^^^
|
||||
|
@ -173,7 +173,7 @@ LL | asm!("def: def: nop");
|
|||
= 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
|
||||
|
||||
error: avoid using named labels in inline assembly
|
||||
--> $DIR/named-asm-labels.rs:73:15
|
||||
--> $DIR/named-asm-labels.rs:81:15
|
||||
|
|
||||
LL | asm!("def: nop\ndef: nop");
|
||||
| ^^^
|
||||
|
@ -182,7 +182,7 @@ LL | asm!("def: nop\ndef: nop");
|
|||
= 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
|
||||
|
||||
error: avoid using named labels in inline assembly
|
||||
--> $DIR/named-asm-labels.rs:74:15
|
||||
--> $DIR/named-asm-labels.rs:82:15
|
||||
|
|
||||
LL | asm!("def: nop; def: nop");
|
||||
| ^^^
|
||||
|
@ -191,7 +191,7 @@ LL | asm!("def: nop; def: nop");
|
|||
= 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
|
||||
|
||||
error: avoid using named labels in inline assembly
|
||||
--> $DIR/named-asm-labels.rs:82:15
|
||||
--> $DIR/named-asm-labels.rs:90:15
|
||||
|
|
||||
LL | asm!("fooo\u{003A} nop");
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
@ -200,7 +200,7 @@ LL | asm!("fooo\u{003A} nop");
|
|||
= 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
|
||||
|
||||
error: avoid using named labels in inline assembly
|
||||
--> $DIR/named-asm-labels.rs:83:15
|
||||
--> $DIR/named-asm-labels.rs:91:15
|
||||
|
|
||||
LL | asm!("foooo\x3A nop");
|
||||
| ^^^^^^^^^^^^^
|
||||
|
@ -209,7 +209,7 @@ LL | asm!("foooo\x3A nop");
|
|||
= 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
|
||||
|
||||
error: avoid using named labels in inline assembly
|
||||
--> $DIR/named-asm-labels.rs:86:15
|
||||
--> $DIR/named-asm-labels.rs:94:15
|
||||
|
|
||||
LL | asm!("fooooo:\u{000A} nop");
|
||||
| ^^^^^^
|
||||
|
@ -218,7 +218,7 @@ LL | asm!("fooooo:\u{000A} nop");
|
|||
= 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
|
||||
|
||||
error: avoid using named labels in inline assembly
|
||||
--> $DIR/named-asm-labels.rs:87:15
|
||||
--> $DIR/named-asm-labels.rs:95:15
|
||||
|
|
||||
LL | asm!("foooooo:\x0A nop");
|
||||
| ^^^^^^^
|
||||
|
@ -227,7 +227,7 @@ LL | asm!("foooooo:\x0A nop");
|
|||
= 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
|
||||
|
||||
error: avoid using named labels in inline assembly
|
||||
--> $DIR/named-asm-labels.rs:91:14
|
||||
--> $DIR/named-asm-labels.rs:99:14
|
||||
|
|
||||
LL | asm!("\x41\x42\x43\x3A\x20\x6E\x6F\x70");
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -236,7 +236,7 @@ LL | asm!("\x41\x42\x43\x3A\x20\x6E\x6F\x70");
|
|||
= 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
|
||||
|
||||
error: avoid using named labels in inline assembly
|
||||
--> $DIR/named-asm-labels.rs:102:13
|
||||
--> $DIR/named-asm-labels.rs:110:13
|
||||
|
|
||||
LL | ab: nop // ab: does foo
|
||||
| ^^
|
||||
|
@ -245,7 +245,7 @@ LL | ab: nop // ab: does foo
|
|||
= 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
|
||||
|
||||
error: avoid using named labels in inline assembly
|
||||
--> $DIR/named-asm-labels.rs:114:14
|
||||
--> $DIR/named-asm-labels.rs:122:14
|
||||
|
|
||||
LL | asm!(include_str!("named-asm-labels.s"));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -254,18 +254,81 @@ LL | asm!(include_str!("named-asm-labels.s"));
|
|||
= 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
|
||||
|
||||
warning: avoid using named labels in inline assembly
|
||||
--> $DIR/named-asm-labels.rs:124:19
|
||||
--> $DIR/named-asm-labels.rs:132:19
|
||||
|
|
||||
LL | asm!("warned: nop");
|
||||
| ^^^^^^
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/named-asm-labels.rs:122:16
|
||||
--> $DIR/named-asm-labels.rs:130:16
|
||||
|
|
||||
LL | #[warn(named_asm_labels)]
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
= help: only local labels of the form `<number>:` should be used in inline asm
|
||||
= 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
|
||||
|
||||
error: aborting due to 28 previous errors; 1 warning emitted
|
||||
error: avoid using named labels in inline assembly
|
||||
--> $DIR/named-asm-labels.rs:141:20
|
||||
|
|
||||
LL | unsafe { asm!(".Lfoo: mov rax, {}; ret;", "nop", const 1, options(noreturn)) }
|
||||
| ^^^^^
|
||||
|
|
||||
= help: only local labels of the form `<number>:` should be used in inline asm
|
||||
= 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
|
||||
|
||||
error: avoid using named labels in inline assembly
|
||||
--> $DIR/named-asm-labels.rs:147:20
|
||||
|
|
||||
LL | unsafe { asm!(".Lbar: mov rax, {}; ret;", "nop", const 1, options(noreturn)) }
|
||||
| ^^^^^
|
||||
|
|
||||
= help: only local labels of the form `<number>:` should be used in inline asm
|
||||
= 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
|
||||
|
||||
error: avoid using named labels in inline assembly
|
||||
--> $DIR/named-asm-labels.rs:155:20
|
||||
|
|
||||
LL | unsafe { asm!(".Laaa: nop; ret;", options(noreturn)) }
|
||||
| ^^^^^
|
||||
|
|
||||
= help: only local labels of the form `<number>:` should be used in inline asm
|
||||
= 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
|
||||
|
||||
error: avoid using named labels in inline assembly
|
||||
--> $DIR/named-asm-labels.rs:165:24
|
||||
|
|
||||
LL | unsafe { asm!(".Lbbb: nop; ret;", options(noreturn)) }
|
||||
| ^^^^^
|
||||
|
|
||||
= help: only local labels of the form `<number>:` should be used in inline asm
|
||||
= 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
|
||||
|
||||
error: avoid using named labels in inline assembly
|
||||
--> $DIR/named-asm-labels.rs:174:15
|
||||
|
|
||||
LL | asm!("closure1: nop");
|
||||
| ^^^^^^^^
|
||||
|
|
||||
= help: only local labels of the form `<number>:` should be used in inline asm
|
||||
= 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
|
||||
|
||||
error: avoid using named labels in inline assembly
|
||||
--> $DIR/named-asm-labels.rs:178:15
|
||||
|
|
||||
LL | asm!("closure2: nop");
|
||||
| ^^^^^^^^
|
||||
|
|
||||
= help: only local labels of the form `<number>:` should be used in inline asm
|
||||
= 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
|
||||
|
||||
error: avoid using named labels in inline assembly
|
||||
--> $DIR/named-asm-labels.rs:188:19
|
||||
|
|
||||
LL | asm!("closure3: nop");
|
||||
| ^^^^^^^^
|
||||
|
|
||||
= help: only local labels of the form `<number>:` should be used in inline asm
|
||||
= 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
|
||||
|
||||
error: aborting due to 35 previous errors; 1 warning emitted
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue