11use crate :: session:: { self , DataTypeKind } ;
2- use crate :: ty:: { self , Ty , TyCtxt , TypeFoldable , ReprOptions } ;
2+ use crate :: ty:: { self , Ty , TyCtxt , TypeFoldable , ReprOptions , subst :: SubstsRef } ;
33
44use syntax:: ast:: { self , Ident , IntTy , UintTy } ;
55use syntax:: attr;
@@ -15,7 +15,6 @@ use std::ops::Bound;
1515use crate :: hir;
1616use crate :: ich:: StableHashingContext ;
1717use crate :: mir:: { GeneratorLayout , GeneratorSavedLocal } ;
18- use crate :: ty:: GeneratorSubsts ;
1918use crate :: ty:: subst:: Subst ;
2019use rustc_index:: bit_set:: BitSet ;
2120use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ;
@@ -671,7 +670,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
671670 tcx. intern_layout ( unit)
672671 }
673672
674- ty:: Generator ( def_id, substs, _) => self . generator_layout ( ty, def_id, & substs) ?,
673+ ty:: Generator ( def_id, substs, _) => self . generator_layout ( ty, def_id, substs) ?,
675674
676675 ty:: Closure ( def_id, ref substs) => {
677676 let tys = substs. as_closure ( ) . upvar_tys ( def_id, tcx) ;
@@ -1406,7 +1405,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
14061405 & self ,
14071406 ty : Ty < ' tcx > ,
14081407 def_id : hir:: def_id:: DefId ,
1409- substs : & GeneratorSubsts < ' tcx > ,
1408+ substs : SubstsRef < ' tcx > ,
14101409 ) -> Result < & ' tcx LayoutDetails , LayoutError < ' tcx > > {
14111410 use SavedLocalEligibility :: * ;
14121411 let tcx = self . tcx ;
@@ -1419,9 +1418,9 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
14191418 // Build a prefix layout, including "promoting" all ineligible
14201419 // locals as part of the prefix. We compute the layout of all of
14211420 // these fields at once to get optimal packing.
1422- let discr_index = substs. prefix_tys ( def_id, tcx) . count ( ) ;
1421+ let discr_index = substs. as_generator ( ) . prefix_tys ( def_id, tcx) . count ( ) ;
14231422 // FIXME(eddyb) set the correct vaidity range for the discriminant.
1424- let discr_layout = self . layout_of ( substs. discr_ty ( tcx) ) ?;
1423+ let discr_layout = self . layout_of ( substs. as_generator ( ) . discr_ty ( tcx) ) ?;
14251424 let discr = match & discr_layout. abi {
14261425 Abi :: Scalar ( s) => s. clone ( ) ,
14271426 _ => bug ! ( ) ,
@@ -2153,15 +2152,15 @@ where
21532152 ty:: Generator ( def_id, ref substs, _) => {
21542153 match this. variants {
21552154 Variants :: Single { index } => {
2156- substs. state_tys ( def_id, tcx)
2155+ substs. as_generator ( ) . state_tys ( def_id, tcx)
21572156 . nth ( index. as_usize ( ) ) . unwrap ( )
21582157 . nth ( i) . unwrap ( )
21592158 }
21602159 Variants :: Multiple { ref discr, discr_index, .. } => {
21612160 if i == discr_index {
21622161 return discr_layout ( discr) ;
21632162 }
2164- substs. prefix_tys ( def_id, tcx) . nth ( i) . unwrap ( )
2163+ substs. as_generator ( ) . prefix_tys ( def_id, tcx) . nth ( i) . unwrap ( )
21652164 }
21662165 }
21672166 }
0 commit comments