@@ -1390,7 +1390,6 @@ pub(crate) fn mir_generator_witnesses<'tcx>(
1390
1390
tcx : TyCtxt < ' tcx > ,
1391
1391
def_id : DefId ,
1392
1392
) -> GeneratorLayout < ' tcx > {
1393
- assert ! ( tcx. sess. opts. unstable_opts. drop_tracking_mir) ;
1394
1393
let def_id = def_id. expect_local ( ) ;
1395
1394
1396
1395
let ( body, _) = tcx. mir_promoted ( ty:: WithOptConstParam :: unknown ( def_id) ) ;
@@ -1401,8 +1400,15 @@ pub(crate) fn mir_generator_witnesses<'tcx>(
1401
1400
let gen_ty = body. local_decls [ ty:: CAPTURE_STRUCT_LOCAL ] . ty ;
1402
1401
1403
1402
// Get the interior types and substs which typeck computed
1404
- let movable = match * gen_ty. kind ( ) {
1405
- ty:: Generator ( _, _, movability) => movability == hir:: Movability :: Movable ,
1403
+ let ( upvars, interior, movable) = match * gen_ty. kind ( ) {
1404
+ ty:: Generator ( _, substs, movability) => {
1405
+ let substs = substs. as_generator ( ) ;
1406
+ (
1407
+ substs. upvar_tys ( ) . collect :: < Vec < _ > > ( ) ,
1408
+ substs. witness ( ) ,
1409
+ movability == hir:: Movability :: Movable ,
1410
+ )
1411
+ }
1406
1412
_ => span_bug ! ( body. span, "unexpected generator type {}" , gen_ty) ,
1407
1413
} ;
1408
1414
@@ -1416,7 +1422,11 @@ pub(crate) fn mir_generator_witnesses<'tcx>(
1416
1422
// `storage_liveness` tells us which locals have live storage at suspension points
1417
1423
let ( _, generator_layout, _) = compute_layout ( tcx, liveness_info, body) ;
1418
1424
1419
- check_suspend_tys ( tcx, & generator_layout, & body) ;
1425
+ if tcx. sess . opts . unstable_opts . drop_tracking_mir {
1426
+ check_suspend_tys ( tcx, & generator_layout, & body) ;
1427
+ } else {
1428
+ sanitize_witness ( tcx, body, interior, upvars, & generator_layout) ;
1429
+ }
1420
1430
1421
1431
generator_layout
1422
1432
}
@@ -1434,15 +1444,10 @@ impl<'tcx> MirPass<'tcx> for StateTransform {
1434
1444
let gen_ty = body. local_decls . raw [ 1 ] . ty ;
1435
1445
1436
1446
// Get the discriminant type and substs which typeck computed
1437
- let ( discr_ty, upvars , interior , movable) = match * gen_ty. kind ( ) {
1447
+ let ( discr_ty, movable) = match * gen_ty. kind ( ) {
1438
1448
ty:: Generator ( _, substs, movability) => {
1439
1449
let substs = substs. as_generator ( ) ;
1440
- (
1441
- substs. discr_ty ( tcx) ,
1442
- substs. upvar_tys ( ) . collect :: < Vec < _ > > ( ) ,
1443
- substs. witness ( ) ,
1444
- movability == hir:: Movability :: Movable ,
1445
- )
1450
+ ( substs. discr_ty ( tcx) , movability == hir:: Movability :: Movable )
1446
1451
}
1447
1452
_ => {
1448
1453
tcx. sess
@@ -1519,12 +1524,6 @@ impl<'tcx> MirPass<'tcx> for StateTransform {
1519
1524
// `storage_liveness` tells us which locals have live storage at suspension points
1520
1525
let ( remap, layout, storage_liveness) = compute_layout ( tcx, liveness_info, body) ;
1521
1526
1522
- if tcx. sess . opts . unstable_opts . validate_mir
1523
- && !tcx. sess . opts . unstable_opts . drop_tracking_mir
1524
- {
1525
- sanitize_witness ( tcx, body, interior, upvars, & layout) ;
1526
- }
1527
-
1528
1527
let can_return = can_return ( tcx, body, tcx. param_env ( body. source . def_id ( ) ) ) ;
1529
1528
1530
1529
// Run the transformation which converts Places from Local to generator struct
0 commit comments