@@ -5,7 +5,7 @@ use crate::infer::canonical::Canonical;
5
5
use crate :: ty:: { self , Lift , List , Ty , TyCtxt , InferConst , ParamConst } ;
6
6
use crate :: ty:: fold:: { TypeFoldable , TypeFolder , TypeVisitor } ;
7
7
use crate :: mir:: interpret:: ConstValue ;
8
- use crate :: ty:: sty:: ClosureSubsts ;
8
+ use crate :: ty:: sty:: { ClosureSubsts , GeneratorSubsts } ;
9
9
10
10
use rustc_serialize:: { self , Encodable , Encoder , Decodable , Decoder } ;
11
11
use syntax_pos:: { Span , DUMMY_SP } ;
@@ -194,6 +194,14 @@ impl<'a, 'tcx> InternalSubsts<'tcx> {
194
194
}
195
195
}
196
196
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
+
197
205
/// Creates a `InternalSubsts` that maps each generic parameter to itself.
198
206
pub fn identity_for_item ( tcx : TyCtxt < ' tcx > , def_id : DefId ) -> SubstsRef < ' tcx > {
199
207
Self :: for_item ( tcx, def_id, |param, _| {
0 commit comments