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