Don't lint against named labels in naked_asm!
Naked functions are allowed to define global labels, just like `global_asm!`.
This commit is contained in:
@@ -2870,7 +2870,7 @@ impl<'tcx> LateLintPass<'tcx> for AsmLabels {
|
||||
if let hir::Expr {
|
||||
kind:
|
||||
hir::ExprKind::InlineAsm(hir::InlineAsm {
|
||||
asm_macro: AsmMacro::Asm | AsmMacro::NakedAsm,
|
||||
asm_macro: asm_macro @ (AsmMacro::Asm | AsmMacro::NakedAsm),
|
||||
template_strs,
|
||||
options,
|
||||
..
|
||||
@@ -2878,6 +2878,15 @@ impl<'tcx> LateLintPass<'tcx> for AsmLabels {
|
||||
..
|
||||
} = expr
|
||||
{
|
||||
// Non-generic naked functions are allowed to define arbitrary
|
||||
// labels.
|
||||
if *asm_macro == AsmMacro::NakedAsm {
|
||||
let def_id = expr.hir_id.owner.def_id;
|
||||
if !cx.tcx.generics_of(def_id).requires_monomorphization(cx.tcx) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// asm with `options(raw)` does not do replacement with `{` and `}`.
|
||||
let raw = options.contains(InlineAsmOptions::RAW);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user