Skip to content

Commit 2d87bac

Browse files
committed
replace GeneratorSubsts with SubstsRef
1 parent 9e35a28 commit 2d87bac

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/librustc/ty/sty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ pub enum TyKind<'tcx> {
163163

164164
/// The anonymous type of a generator. Used to represent the type of
165165
/// `|a| yield a`.
166-
Generator(DefId, GeneratorSubsts<'tcx>, hir::GeneratorMovability),
166+
Generator(DefId, SubstsRef<'tcx>, hir::GeneratorMovability),
167167

168168
/// A type representin the types stored inside a generator.
169169
/// This should only appear in GeneratorInteriors.

src/librustc/ty/subst.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::infer::canonical::Canonical;
55
use crate::ty::{self, Lift, List, Ty, TyCtxt, InferConst, ParamConst};
66
use crate::ty::fold::{TypeFoldable, TypeFolder, TypeVisitor};
77
use crate::mir::interpret::ConstValue;
8-
use crate::ty::sty::ClosureSubsts;
8+
use crate::ty::sty::{ClosureSubsts, GeneratorSubsts};
99

1010
use rustc_serialize::{self, Encodable, Encoder, Decodable, Decoder};
1111
use 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

Comments
 (0)