summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-07-09 03:41:22 +0000
committerbors <bors@rust-lang.org>2015-07-09 03:41:22 +0000
commitafe25a2d6aaa308cce861fab50014f6a9f57a269 (patch)
treeb5dd91309e3ed292722faa5e4ea8295cd0df293e /src/libsyntax
parent3198e1acf3301fdcfe527feb327ccd02d0e4434b (diff)
parentb952c0e4e9f3c169c6647fd05fef68ae1119865a (diff)
downloadrust-afe25a2d6aaa308cce861fab50014f6a9f57a269.tar.gz
rust-afe25a2d6aaa308cce861fab50014f6a9f57a269.zip
Auto merge of #26515 - quantheory:check_enum_recursion, r=nrc
Fixes #23302.

Note that there's an odd situation regarding the following, most likely due to some inadequacy in `const_eval`:

```rust
enum Y {
    A = 1usize,
    B,
}
```

In this case, `Y::B as usize` might be considered a constant expression in some cases, but not others.  (See #23513, for a related problem where there is only one variant, with no discriminant, and it doesn't behave nicely as a constant expression either.)

Most of the complexity in this PR is basically future-proofing, to ensure that when `Y::B as usize` is fully made to be a constant expression, it can't be used to set `Y::A`, and thus indirectly itself.
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/visit.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs
index 710928a00c1..649052d123c 100644
--- a/src/libsyntax/visit.rs
+++ b/src/libsyntax/visit.rs
@@ -90,6 +90,11 @@ pub trait Visitor<'v> : Sized {
         walk_struct_def(self, s)
     }
     fn visit_struct_field(&mut self, s: &'v StructField) { walk_struct_field(self, s) }
+    fn visit_enum_def(&mut self, enum_definition: &'v EnumDef,
+                      generics: &'v Generics) {
+        walk_enum_def(self, enum_definition, generics)
+    }
+
     fn visit_variant(&mut self, v: &'v Variant, g: &'v Generics) { walk_variant(self, v, g) }
 
     /// Visits an optional reference to a lifetime. The `span` is the span of some surrounding
@@ -268,7 +273,7 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) {
         }
         ItemEnum(ref enum_definition, ref type_parameters) => {
             visitor.visit_generics(type_parameters);
-            walk_enum_def(visitor, enum_definition, type_parameters)
+            visitor.visit_enum_def(enum_definition, type_parameters)
         }
         ItemDefaultImpl(_, ref trait_ref) => {
             visitor.visit_trait_ref(trait_ref)