about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJohn Kåre Alsaker <john.kare.alsaker@gmail.com>2017-07-10 21:24:22 +0200
committerJohn Kåre Alsaker <john.kare.alsaker@gmail.com>2017-07-28 15:46:24 +0200
commit2afd04c009c53d221d244c82a54daeb4c5d656f5 (patch)
tree768332e4e32968f5131caa416e84775e4a1d2b3b
parent8cd0595602feedb123abbed03714a56a43bcbbec (diff)
downloadrust-2afd04c009c53d221d244c82a54daeb4c5d656f5.tar.gz
rust-2afd04c009c53d221d244c82a54daeb4c5d656f5.zip
Add some comments
-rw-r--r--src/librustc/hir/mod.rs2
-rw-r--r--src/librustc/ty/sty.rs8
2 files changed, 9 insertions, 1 deletions
diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs
index 40a745bcebf..39e17434fa1 100644
--- a/src/librustc/hir/mod.rs
+++ b/src/librustc/hir/mod.rs
@@ -1023,6 +1023,8 @@ pub enum Expr_ {
     /// A closure (for example, `move |a, b, c| {a + b + c}`).
     ///
     /// The final span is the span of the argument block `|...|`
+    /// 
+    /// This may also be a generator literal, in that case there is an GeneratorClause.
     ExprClosure(CaptureClause, P<FnDecl>, BodyId, Span, Option<GeneratorClause>),
     /// A block (`{ ... }`)
     ExprBlock(P<Block>),
diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs
index bd5f6a8e262..0f0bcdb78b8 100644
--- a/src/librustc/ty/sty.rs
+++ b/src/librustc/ty/sty.rs
@@ -149,7 +149,8 @@ pub enum TypeVariants<'tcx> {
     /// `|a| a`.
     TyClosure(DefId, ClosureSubsts<'tcx>),
 
-    /// The anonymous type of a generator. Pairs with a TyClosure for closure generators.
+    /// The anonymous type of a generator. Used to represent the type of
+    /// `|a| yield a`.
     TyGenerator(DefId, ClosureSubsts<'tcx>, GeneratorInterior<'tcx>),
 
     /// The never type `!`
@@ -279,6 +280,9 @@ impl<'a, 'gcx, 'acx, 'tcx> ClosureSubsts<'tcx> {
 }
 
 impl<'a, 'gcx, 'tcx> ClosureSubsts<'tcx> {
+    /// This returns the types of the MIR locals which had to be stored across suspension points.
+    /// It is calculated in rustc_mir::transform::generator::StateTransform.
+    /// All the types here must be in the tuple in GeneratorInterior.
     pub fn state_tys(self, def_id: DefId, tcx: TyCtxt<'a, 'gcx, 'tcx>) ->
         impl Iterator<Item=Ty<'tcx>> + 'tcx
     {
@@ -287,6 +291,8 @@ impl<'a, 'gcx, 'tcx> ClosureSubsts<'tcx> {
         state.into_iter()
     }
 
+    /// This is the types of all the fields stored in a generator.
+    /// It includes the upvars, state types and the state discriminant which is u32.
     pub fn field_tys(self, def_id: DefId, tcx: TyCtxt<'a, 'gcx, 'tcx>) ->
         impl Iterator<Item=Ty<'tcx>> + 'tcx
     {