@@ -406,6 +406,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
406
406
vec ! [ destination_block]
407
407
} ;
408
408
409
+ let mut has_type_error = false ;
410
+
409
411
let operands = operands
410
412
. into_iter ( )
411
413
. map ( |op| match * op {
@@ -441,6 +443,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
441
443
}
442
444
}
443
445
thir:: InlineAsmOperand :: Const { value, span } => {
446
+ has_type_error |=
447
+ matches ! ( value. ty( ) . kind( ) , rustc_middle:: ty:: Error ( _) ) ;
448
+
444
449
mir:: InlineAsmOperand :: Const {
445
450
value : Box :: new ( ConstOperand {
446
451
span,
@@ -484,26 +489,31 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
484
489
this. cfg . push_assign_unit ( block, source_info, destination, this. tcx ) ;
485
490
}
486
491
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
+ } ,
500
510
} ,
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 ( )
505
516
}
506
- destination_block. unit ( )
507
517
}
508
518
509
519
// These cases don't actually need a destination
0 commit comments