@@ -237,15 +237,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
237237 }
238238 }
239239 InlineAsmOperand :: Label { block } => {
240- if !self . tcx . features ( ) . asm_goto ( ) {
241- feature_err (
242- sess,
243- sym:: asm_goto,
244- * op_sp,
245- fluent:: ast_lowering_unstable_inline_assembly_label_operands,
246- )
247- . emit ( ) ;
248- }
249240 hir:: InlineAsmOperand :: Label { block : self . lower_block ( block, false ) }
250241 }
251242 } ;
@@ -464,6 +455,41 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
464455 }
465456 }
466457
458+ // Feature gate checking for asm goto.
459+ if let Some ( ( _, op_sp) ) =
460+ operands. iter ( ) . find ( |( op, _) | matches ! ( op, hir:: InlineAsmOperand :: Label { .. } ) )
461+ {
462+ if !self . tcx . features ( ) . asm_goto ( ) {
463+ feature_err (
464+ sess,
465+ sym:: asm_goto,
466+ * op_sp,
467+ fluent:: ast_lowering_unstable_inline_assembly_label_operands,
468+ )
469+ . emit ( ) ;
470+ }
471+
472+ // In addition, check if an output operand is used.
473+ // This is gated behind an additional feature.
474+ let output_operand_used = operands. iter ( ) . any ( |( op, _) | {
475+ matches ! (
476+ op,
477+ hir:: InlineAsmOperand :: Out { expr: Some ( _) , .. }
478+ | hir:: InlineAsmOperand :: InOut { .. }
479+ | hir:: InlineAsmOperand :: SplitInOut { out_expr: Some ( _) , .. }
480+ )
481+ } ) ;
482+ if output_operand_used && !self . tcx . features ( ) . asm_goto_with_outputs ( ) {
483+ feature_err (
484+ sess,
485+ sym:: asm_goto_with_outputs,
486+ * op_sp,
487+ fluent:: ast_lowering_unstable_inline_assembly_label_operand_with_outputs,
488+ )
489+ . emit ( ) ;
490+ }
491+ }
492+
467493 let operands = self . arena . alloc_from_iter ( operands) ;
468494 let template = self . arena . alloc_from_iter ( asm. template . iter ( ) . cloned ( ) ) ;
469495 let template_strs = self . arena . alloc_from_iter (
0 commit comments