@@ -44,9 +44,9 @@ use crate::errors::{
44
44
AddressOfTemporaryTaken , BaseExpressionDoubleDot , BaseExpressionDoubleDotAddExpr ,
45
45
BaseExpressionDoubleDotEnableDefaultFieldValues , BaseExpressionDoubleDotRemove ,
46
46
CantDereference , FieldMultiplySpecifiedInInitializer , FunctionalRecordUpdateOnNonStruct ,
47
- HelpUseLatestEdition , NoFieldOnType , NoFieldOnVariant , ReturnLikeStatementKind ,
48
- ReturnStmtOutsideOfFnBody , StructExprNonExhaustive , TypeMismatchFruTypo ,
49
- YieldExprOutsideOfCoroutine ,
47
+ HelpUseLatestEdition , NakedAsmOutsideNakedFn , NoFieldOnType , NoFieldOnVariant ,
48
+ ReturnLikeStatementKind , ReturnStmtOutsideOfFnBody , StructExprNonExhaustive ,
49
+ TypeMismatchFruTypo , YieldExprOutsideOfCoroutine ,
50
50
} ;
51
51
use crate :: {
52
52
BreakableCtxt , CoroutineTypes , Diverges , FnCtxt , GatherLocalsVisitor , Needs ,
@@ -524,7 +524,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
524
524
ExprKind :: InlineAsm ( asm) => {
525
525
// We defer some asm checks as we may not have resolved the input and output types yet (they may still be infer vars).
526
526
self . deferred_asm_checks . borrow_mut ( ) . push ( ( asm, expr. hir_id ) ) ;
527
- self . check_expr_asm ( asm)
527
+ self . check_expr_asm ( asm, expr . span )
528
528
}
529
529
ExprKind :: OffsetOf ( container, fields) => {
530
530
self . check_expr_offset_of ( container, fields, expr)
@@ -3761,7 +3761,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
3761
3761
}
3762
3762
}
3763
3763
3764
- fn check_expr_asm ( & self , asm : & ' tcx hir:: InlineAsm < ' tcx > ) -> Ty < ' tcx > {
3764
+ fn check_expr_asm ( & self , asm : & ' tcx hir:: InlineAsm < ' tcx > , span : Span ) -> Ty < ' tcx > {
3765
+ if let rustc_ast:: AsmMacro :: NakedAsm = asm. asm_macro {
3766
+ if !self . tcx . has_attr ( self . body_id , sym:: naked) {
3767
+ self . tcx . dcx ( ) . emit_err ( NakedAsmOutsideNakedFn { span } ) ;
3768
+ }
3769
+ }
3770
+
3765
3771
let mut diverge = asm. asm_macro . diverges ( asm. options ) ;
3766
3772
3767
3773
for ( op, _op_sp) in asm. operands {
0 commit comments