@@ -252,8 +252,11 @@ fn mir_promoted<'tcx>(
252
252
// Ensure that we compute the `mir_const_qualif` for constants at
253
253
// this point, before we steal the mir-const result.
254
254
// Also this means promotion can rely on all const checks having been done.
255
- let _ = tcx. mir_const_qualif_opt_const_arg ( def) ;
255
+ let const_qualifs = tcx. mir_const_qualif_opt_const_arg ( def) ;
256
256
let mut body = tcx. mir_const ( def) . steal ( ) ;
257
+ if let Some ( error_reported) = const_qualifs. tainted_by_errors {
258
+ body. tainted_by_errors = Some ( error_reported) ;
259
+ }
257
260
258
261
let mut required_consts = Vec :: new ( ) ;
259
262
let mut required_consts_visitor = RequiredConstsVisitor :: new ( & mut required_consts) ;
@@ -358,13 +361,7 @@ fn mir_drops_elaborated_and_const_checked<'tcx>(
358
361
return tcx. mir_drops_elaborated_and_const_checked ( def) ;
359
362
}
360
363
361
- // (Mir-)Borrowck uses `mir_promoted`, so we have to force it to
362
- // execute before we can steal.
363
- if let Some ( param_did) = def. const_param_did {
364
- tcx. ensure ( ) . mir_borrowck_const_arg ( ( def. did , param_did) ) ;
365
- } else {
366
- tcx. ensure ( ) . mir_borrowck ( def. did ) ;
367
- }
364
+ let mir_borrowck = tcx. mir_borrowck_opt_const_arg ( def) ;
368
365
369
366
let is_fn_like = tcx. hir ( ) . get_by_def_id ( def. did ) . fn_kind ( ) . is_some ( ) ;
370
367
if is_fn_like {
@@ -379,6 +376,9 @@ fn mir_drops_elaborated_and_const_checked<'tcx>(
379
376
380
377
let ( body, _) = tcx. mir_promoted ( def) ;
381
378
let mut body = body. steal ( ) ;
379
+ if let Some ( error_reported) = mir_borrowck. tainted_by_errors {
380
+ body. tainted_by_errors = Some ( error_reported) ;
381
+ }
382
382
383
383
// IMPORTANT
384
384
pm:: run_passes ( tcx, & mut body, & [ & remove_false_edges:: RemoveFalseEdges ] ) ;
@@ -544,15 +544,13 @@ fn promoted_mir<'tcx>(
544
544
return tcx. arena . alloc ( IndexVec :: new ( ) ) ;
545
545
}
546
546
547
- if let Some ( param_did) = def. const_param_did {
548
- tcx. ensure ( ) . mir_borrowck_const_arg ( ( def. did , param_did) ) ;
549
- } else {
550
- tcx. ensure ( ) . mir_borrowck ( def. did ) ;
551
- }
552
- let ( _, promoted) = tcx. mir_promoted ( def) ;
553
- let mut promoted = promoted. steal ( ) ;
547
+ let tainted_by_errors = tcx. mir_borrowck_opt_const_arg ( def) . tainted_by_errors ;
548
+ let mut promoted = tcx. mir_promoted ( def) . 1 . steal ( ) ;
554
549
555
550
for body in & mut promoted {
551
+ if let Some ( error_reported) = tainted_by_errors {
552
+ body. tainted_by_errors = Some ( error_reported) ;
553
+ }
556
554
run_post_borrowck_cleanup_passes ( tcx, body) ;
557
555
}
558
556
0 commit comments