@@ -406,6 +406,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
406406 vec ! [ destination_block]
407407 } ;
408408
409+ let mut has_type_error = false ;
410+
409411 let operands = operands
410412 . into_iter ( )
411413 . map ( |op| match * op {
@@ -441,6 +443,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
441443 }
442444 }
443445 thir:: InlineAsmOperand :: Const { value, span } => {
446+ has_type_error |=
447+ matches ! ( value. ty( ) . kind( ) , rustc_middle:: ty:: Error ( _) ) ;
448+
444449 mir:: InlineAsmOperand :: Const {
445450 value : Box :: new ( ConstOperand {
446451 span,
@@ -484,26 +489,31 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
484489 this. cfg . push_assign_unit ( block, source_info, destination, this. tcx ) ;
485490 }
486491
487- this. cfg . terminate (
488- block,
489- source_info,
490- TerminatorKind :: InlineAsm {
491- template,
492- operands,
493- options,
494- line_spans,
495- targets : targets. into_boxed_slice ( ) ,
496- unwind : if options. contains ( InlineAsmOptions :: MAY_UNWIND ) {
497- UnwindAction :: Continue
498- } else {
499- UnwindAction :: Unreachable
492+ if has_type_error {
493+ this. cfg . terminate ( block, source_info, TerminatorKind :: Unreachable ) ;
494+ destination_block. unit ( )
495+ } else {
496+ this. cfg . terminate (
497+ block,
498+ source_info,
499+ TerminatorKind :: InlineAsm {
500+ template,
501+ operands,
502+ options,
503+ line_spans,
504+ targets : targets. into_boxed_slice ( ) ,
505+ unwind : if options. contains ( InlineAsmOptions :: MAY_UNWIND ) {
506+ UnwindAction :: Continue
507+ } else {
508+ UnwindAction :: Unreachable
509+ } ,
500510 } ,
501- } ,
502- ) ;
503- if options. contains ( InlineAsmOptions :: MAY_UNWIND ) {
504- this. diverge_from ( block) ;
511+ ) ;
512+ if options. contains ( InlineAsmOptions :: MAY_UNWIND ) {
513+ this. diverge_from ( block) ;
514+ }
515+ destination_block. unit ( )
505516 }
506- destination_block. unit ( )
507517 }
508518
509519 // These cases don't actually need a destination
0 commit comments