diff options
| author | Sean Patrick Santos <SeanPatrickSantos@gmail.com> | 2015-07-08 20:51:47 -0600 |
|---|---|---|
| committer | Sean Patrick Santos <SeanPatrickSantos@gmail.com> | 2015-07-08 20:51:47 -0600 |
| commit | b952c0e4e9f3c169c6647fd05fef68ae1119865a (patch) | |
| tree | 643cbec2862b4af644605bd0157bf3c0b87ae960 | |
| parent | faf73028c9afe5790e9b4d83a348d93e4a098852 (diff) | |
| download | rust-b952c0e4e9f3c169c6647fd05fef68ae1119865a.tar.gz rust-b952c0e4e9f3c169c6647fd05fef68ae1119865a.zip | |
Add comments about the checks for recursive variant definition, as requested by @nrc.
| -rw-r--r-- | src/librustc/middle/check_static_recursion.rs | 4 | ||||
| -rw-r--r-- | src/test/compile-fail/issue-23302.rs | 4 |
2 files changed, 8 insertions, 0 deletions
diff --git a/src/librustc/middle/check_static_recursion.rs b/src/librustc/middle/check_static_recursion.rs index 1d0cfe508c7..312a4708e8d 100644 --- a/src/librustc/middle/check_static_recursion.rs +++ b/src/librustc/middle/check_static_recursion.rs @@ -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>>>, } diff --git a/src/test/compile-fail/issue-23302.rs b/src/test/compile-fail/issue-23302.rs index 62f82ecae44..7ac8cf45edb 100644 --- a/src/test/compile-fail/issue-23302.rs +++ b/src/test/compile-fail/issue-23302.rs @@ -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, |
