about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorSunjay Varma <varma.sunjay@gmail.com>2017-11-19 00:00:15 -0500
committerSunjay Varma <varma.sunjay@gmail.com>2017-12-01 01:26:29 -0500
commitc2aaba9b4455290ecc8b4cbfb96077fe056ba8b0 (patch)
treee0679ac65209160350ad660f18c1d81f464ee64a /src/libsyntax
parente565b5bbdd93b2b2bf9b5b7867320201c6a0cb81 (diff)
downloadrust-c2aaba9b4455290ecc8b4cbfb96077fe056ba8b0.tar.gz
rust-c2aaba9b4455290ecc8b4cbfb96077fe056ba8b0.zip
Specifically gating generic_associated_types feature on associated Type declarations
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/feature_gate.rs20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs
index 161967c3f3d..09cbd3d591c 100644
--- a/src/libsyntax/feature_gate.rs
+++ b/src/libsyntax/feature_gate.rs
@@ -1617,13 +1617,17 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
                     gate_feature_post!(&self, const_fn, ti.span, "const fn is unstable");
                 }
             }
-            ast::TraitItemKind::Type(_, Some(_)) => {
-                gate_feature_post!(&self, associated_type_defaults, ti.span,
-                                  "associated type defaults are unstable");
-            }
-            _ if ti.generics.is_parameterized() => {
-                gate_feature_post!(&self, generic_associated_types, ti.span,
-                                   "generic associated types are unstable");
+            ast::TraitItemKind::Type(_, default) => {
+                // We use two if statements instead of something like match guards so that both
+                // of these errors can be emitted if both cases apply.
+                if default.is_some() {
+                    gate_feature_post!(&self, associated_type_defaults, ti.span,
+                                       "associated type defaults are unstable");
+                }
+                if ti.generics.is_parameterized() {
+                    gate_feature_post!(&self, generic_associated_types, ti.span,
+                                       "generic associated types are unstable");
+                }
             }
             _ => {}
         }
@@ -1643,7 +1647,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
                     gate_feature_post!(&self, const_fn, ii.span, "const fn is unstable");
                 }
             }
-            _ if ii.generics.is_parameterized() => {
+            ast::ImplItemKind::Type(_) if ii.generics.is_parameterized() => {
                 gate_feature_post!(&self, generic_associated_types, ii.span,
                                    "generic associated types are unstable");
             }