]> git.lizzy.rs Git - rust.git/commitdiff
Add comments about the checks for recursive variant definition, as requested by ...
authorSean Patrick Santos <SeanPatrickSantos@gmail.com>
Thu, 9 Jul 2015 02:51:47 +0000 (20:51 -0600)
committerSean Patrick Santos <SeanPatrickSantos@gmail.com>
Thu, 9 Jul 2015 02:51:47 +0000 (20:51 -0600)
src/librustc/middle/check_static_recursion.rs
src/test/compile-fail/issue-23302.rs

index 1d0cfe508c7c2e552ef793690dd37f334fed2e4a..312a4708e8dde8959ce77d5e2edee92d17c1cb1c 100644 (file)
@@ -27,6 +27,10 @@ struct CheckCrateVisitor<'a, 'ast: 'a> {
     sess: &'a Session,
     def_map: &'a DefMap,
     ast_map: &'a ast_map::Map<'ast>,
+    // `discriminant_map` is a cache that associates the `NodeId`s of local
+    // variant definitions with the discriminant expression that applies to
+    // each one. If the variant uses the default values (starting from `0`),
+    // then `None` is stored.
     discriminant_map: RefCell<NodeMap<Option<&'ast ast::Expr>>>,
 }
 
index 62f82ecae4409290e9ea42bf8c6b00ca108cac4a..7ac8cf45edbefe8d443d7336666f7db41ca0421a 100644 (file)
@@ -8,10 +8,14 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// Check that an enum with recursion in the discriminant throws
+// the appropriate error (rather than, say, blowing the stack).
 enum X {
     A = X::A as isize, //~ ERROR E0265
 }
 
+// Since `Y::B` here defaults to `Y::A+1`, this is also a
+// recursive definition.
 enum Y {
     A = Y::B as isize, //~ ERROR E0265
     B,