@@ -5,7 +5,7 @@ use crate::infer::canonical::Canonical;
55use crate :: ty:: { self , Lift , List , Ty , TyCtxt , InferConst , ParamConst } ;
66use crate :: ty:: fold:: { TypeFoldable , TypeFolder , TypeVisitor } ;
77use crate :: mir:: interpret:: ConstValue ;
8- use crate :: ty:: sty:: ClosureSubsts ;
8+ use crate :: ty:: sty:: { ClosureSubsts , GeneratorSubsts } ;
99
1010use rustc_serialize:: { self , Encodable , Encoder , Decodable , Decoder } ;
1111use syntax_pos:: { Span , DUMMY_SP } ;
@@ -194,6 +194,14 @@ impl<'a, 'tcx> InternalSubsts<'tcx> {
194194 }
195195 }
196196
197+ /// Interpret these substitutions as the substitutions of a generator type.
198+ /// Closure substitutions have a particular structure controlled by the
199+ /// compiler that encodes information like the signature and generator kind;
200+ /// see `ty::GeneratorSubsts` struct for more comments.
201+ pub fn as_generator ( & ' a self ) -> GeneratorSubsts < ' a > {
202+ GeneratorSubsts { substs : self }
203+ }
204+
197205 /// Creates a `InternalSubsts` that maps each generic parameter to itself.
198206 pub fn identity_for_item ( tcx : TyCtxt < ' tcx > , def_id : DefId ) -> SubstsRef < ' tcx > {
199207 Self :: for_item ( tcx, def_id, |param, _| {
0 commit comments