@@ -44,9 +44,9 @@ use crate::errors::{
4444 AddressOfTemporaryTaken , BaseExpressionDoubleDot , BaseExpressionDoubleDotAddExpr ,
4545 BaseExpressionDoubleDotEnableDefaultFieldValues , BaseExpressionDoubleDotRemove ,
4646 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 ,
5050} ;
5151use crate :: {
5252 BreakableCtxt , CoroutineTypes , Diverges , FnCtxt , GatherLocalsVisitor , Needs ,
@@ -524,7 +524,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
524524 ExprKind :: InlineAsm ( asm) => {
525525 // We defer some asm checks as we may not have resolved the input and output types yet (they may still be infer vars).
526526 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 )
528528 }
529529 ExprKind :: OffsetOf ( container, fields) => {
530530 self . check_expr_offset_of ( container, fields, expr)
@@ -3761,7 +3761,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
37613761 }
37623762 }
37633763
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+
37653771 let mut diverge = asm. asm_macro . diverges ( asm. options ) ;
37663772
37673773 for ( op, _op_sp) in asm. operands {
0 commit comments