@@ -509,26 +509,18 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
509509 instance : ty:: InstanceDef < ' tcx > ,
510510 promoted : Option < mir:: Promoted > ,
511511 ) -> InterpResult < ' tcx , & ' tcx mir:: Body < ' tcx > > {
512- // do not continue if typeck errors occurred (can only occur in local crate)
513512 let def = instance. with_opt_param ( ) ;
514- if let Some ( def) = def. as_local ( ) {
515- if self . tcx . has_typeck_results ( def. did ) {
516- if let Some ( error_reported) = self . tcx . typeck_opt_const_arg ( def) . tainted_by_errors {
517- throw_inval ! ( AlreadyReported ( error_reported) ) ;
518- }
519- if let Some ( error_reported) =
520- self . tcx . mir_borrowck_opt_const_arg ( def) . tainted_by_errors
521- {
522- throw_inval ! ( AlreadyReported ( error_reported) ) ;
523- }
524- }
525- }
526-
527513 trace ! ( "load mir(instance={:?}, promoted={:?})" , instance, promoted) ;
528- if let Some ( promoted) = promoted {
529- return Ok ( & self . tcx . promoted_mir_opt_const_arg ( def) [ promoted] ) ;
514+ let body = if let Some ( promoted) = promoted {
515+ & self . tcx . promoted_mir_opt_const_arg ( def) [ promoted]
516+ } else {
517+ M :: load_mir ( self , instance) ?
518+ } ;
519+ // do not continue if typeck errors occurred (can only occur in local crate)
520+ if let Some ( err) = body. tainted_by_errors {
521+ throw_inval ! ( AlreadyReported ( err) ) ;
530522 }
531- M :: load_mir ( self , instance )
523+ Ok ( body )
532524 }
533525
534526 /// Call this on things you got out of the MIR (so it is as generic as the current
0 commit comments