]> git.lizzy.rs Git - rust.git/commitdiff
Specifically gating generic_associated_types feature on associated Type declarations
authorSunjay Varma <varma.sunjay@gmail.com>
Sun, 19 Nov 2017 05:00:15 +0000 (00:00 -0500)
committerSunjay Varma <varma.sunjay@gmail.com>
Fri, 1 Dec 2017 06:26:29 +0000 (01:26 -0500)
src/libsyntax/feature_gate.rs

index 161967c3f3d6c7f06741a81ba1071f6b7447c703..09cbd3d591c3711f26998b60d4886ff74bdf212f 100644 (file)
@@ -1617,13 +1617,17 @@ fn visit_trait_item(&mut self, ti: &'a ast::TraitItem) {
                     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 @@ fn visit_impl_item(&mut self, ii: &'a ast::ImplItem) {
                     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");
             }