Skip to content

Commit 1566e8a

Browse files
committed
Add some comments
1 parent 422667a commit 1566e8a

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/librustc/hir/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1023,6 +1023,8 @@ pub enum Expr_ {
10231023
/// A closure (for example, `move |a, b, c| {a + b + c}`).
10241024
///
10251025
/// The final span is the span of the argument block `|...|`
1026+
///
1027+
/// This may also be a generator literal, in that case there is an GeneratorClause.
10261028
ExprClosure(CaptureClause, P<FnDecl>, BodyId, Span, Option<GeneratorClause>),
10271029
/// A block (`{ ... }`)
10281030
ExprBlock(P<Block>),

src/librustc/ty/sty.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ pub enum TypeVariants<'tcx> {
150150
/// `|a| a`.
151151
TyClosure(DefId, ClosureSubsts<'tcx>),
152152

153-
/// The anonymous type of a generator. Pairs with a TyClosure for closure generators.
153+
/// The anonymous type of a generator. Used to represent the type of
154+
/// `|a| yield a`.
154155
TyGenerator(DefId, ClosureSubsts<'tcx>, GeneratorInterior<'tcx>),
155156

156157
/// The never type `!`
@@ -280,6 +281,9 @@ impl<'a, 'gcx, 'acx, 'tcx> ClosureSubsts<'tcx> {
280281
}
281282

282283
impl<'a, 'gcx, 'tcx> ClosureSubsts<'tcx> {
284+
/// This returns the types of the MIR locals which had to be stored across suspension points.
285+
/// It is calculated in rustc_mir::transform::generator::StateTransform.
286+
/// All the types here must be in the tuple in GeneratorInterior.
283287
pub fn state_tys(self, def_id: DefId, tcx: TyCtxt<'a, 'gcx, 'tcx>) ->
284288
impl Iterator<Item=Ty<'tcx>> + 'tcx
285289
{
@@ -288,6 +292,8 @@ impl<'a, 'gcx, 'tcx> ClosureSubsts<'tcx> {
288292
state.into_iter()
289293
}
290294

295+
/// This is the types of all the fields stored in a generator.
296+
/// It includes the upvars, state types and the state discriminant which is u32.
291297
pub fn field_tys(self, def_id: DefId, tcx: TyCtxt<'a, 'gcx, 'tcx>) ->
292298
impl Iterator<Item=Ty<'tcx>> + 'tcx
293299
{

0 commit comments

Comments
 (0)