about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-12-01 10:25:45 +0100
committerMazdak Farrokhzad <twingoow@gmail.com>2019-12-12 17:54:48 +0100
commit39073767a483d10f8b4b2ac2f32bc9573d9dabbf (patch)
tree2245c770ed979e31ff9ea4bd76094a3eead89898 /src/libsyntax
parentc02fd3130284921f7077f78271b5501b402ec469 (diff)
downloadrust-39073767a483d10f8b4b2ac2f32bc9573d9dabbf.tar.gz
rust-39073767a483d10f8b4b2ac2f32bc9573d9dabbf.zip
Unify `{Trait,Impl}ItemKind::TyAlias` structures.
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/ast.rs2
-rw-r--r--src/libsyntax/feature_gate/check.rs6
-rw-r--r--src/libsyntax/mut_visit.rs5
-rw-r--r--src/libsyntax/print/pprust.rs22
-rw-r--r--src/libsyntax/visit.rs5
5 files changed, 22 insertions, 18 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs
index 4e2f78e8ab8..89868a9cd29 100644
--- a/src/libsyntax/ast.rs
+++ b/src/libsyntax/ast.rs
@@ -1638,7 +1638,7 @@ pub struct ImplItem<K = ImplItemKind> {
 pub enum ImplItemKind  {
     Const(P<Ty>, Option<P<Expr>>),
     Method(FnSig, Option<P<Block>>),
-    TyAlias(P<Ty>),
+    TyAlias(GenericBounds, Option<P<Ty>>),
     Macro(Mac),
 }
 
diff --git a/src/libsyntax/feature_gate/check.rs b/src/libsyntax/feature_gate/check.rs
index 10f6bbb5949..f786de6401a 100644
--- a/src/libsyntax/feature_gate/check.rs
+++ b/src/libsyntax/feature_gate/check.rs
@@ -612,8 +612,10 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
                                        "C-variadic functions are unstable");
                 }
             }
-            ast::ImplItemKind::TyAlias(ref ty) => {
-                self.check_impl_trait(ty);
+            ast::ImplItemKind::TyAlias(_, ref ty) => {
+                if let Some(ty) = ty {
+                    self.check_impl_trait(ty);
+                }
                 self.check_gat(&ii.generics, ii.span);
             }
             _ => {}
diff --git a/src/libsyntax/mut_visit.rs b/src/libsyntax/mut_visit.rs
index 66cac0f917d..bb0462c19cd 100644
--- a/src/libsyntax/mut_visit.rs
+++ b/src/libsyntax/mut_visit.rs
@@ -987,7 +987,10 @@ pub fn noop_flat_map_impl_item<T: MutVisitor>(mut item: ImplItem, visitor: &mut
             visit_fn_sig(sig, visitor);
             visit_opt(body, |body| visitor.visit_block(body));
         }
-        ImplItemKind::TyAlias(ty) => visitor.visit_ty(ty),
+        ImplItemKind::TyAlias(bounds, ty) => {
+            visit_bounds(bounds, visitor);
+            visit_opt(ty, |ty| visitor.visit_ty(ty));
+        }
         ImplItemKind::Macro(mac) => visitor.visit_mac(mac),
     }
     visitor.visit_span(span);
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs
index 00dcd7e8d0b..03e394b8c7e 100644
--- a/src/libsyntax/print/pprust.rs
+++ b/src/libsyntax/print/pprust.rs
@@ -1128,16 +1128,15 @@ impl<'a> State<'a> {
         self.s.word(";")
     }
 
-    fn print_associated_type(&mut self,
-                             ident: ast::Ident,
-                             bounds: Option<&ast::GenericBounds>,
-                             ty: Option<&ast::Ty>)
-                             {
+    fn print_associated_type(
+        &mut self,
+        ident: ast::Ident,
+        bounds: &ast::GenericBounds,
+        ty: Option<&ast::Ty>,
+    ) {
         self.word_space("type");
         self.print_ident(ident);
-        if let Some(bounds) = bounds {
-            self.print_type_bounds(":", bounds);
-        }
+        self.print_type_bounds(":", bounds);
         if let Some(ty) = ty {
             self.s.space();
             self.word_space("=");
@@ -1568,8 +1567,7 @@ impl<'a> State<'a> {
                 }
             }
             ast::TraitItemKind::TyAlias(ref bounds, ref default) => {
-                self.print_associated_type(ti.ident, Some(bounds),
-                                           default.as_ref().map(|ty| &**ty));
+                self.print_associated_type(ti.ident, bounds, default.as_deref());
             }
             ast::TraitItemKind::Macro(ref mac) => {
                 self.print_mac(mac);
@@ -1603,8 +1601,8 @@ impl<'a> State<'a> {
                     self.s.word(";");
                 }
             }
-            ast::ImplItemKind::TyAlias(ref ty) => {
-                self.print_associated_type(ii.ident, None, Some(ty));
+            ast::ImplItemKind::TyAlias(ref bounds, ref ty) => {
+                self.print_associated_type(ii.ident, bounds, ty.as_deref());
             }
             ast::ImplItemKind::Macro(ref mac) => {
                 self.print_mac(mac);
diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs
index f96290ec4f8..7cc1a769e52 100644
--- a/src/libsyntax/visit.rs
+++ b/src/libsyntax/visit.rs
@@ -627,8 +627,9 @@ pub fn walk_impl_item<'a, V: Visitor<'a>>(visitor: &mut V, impl_item: &'a ImplIt
             visitor.visit_fn(FnKind::Method(impl_item.ident, sig, &impl_item.vis, body),
                              &sig.decl, impl_item.span, impl_item.id);
         }
-        ImplItemKind::TyAlias(ref ty) => {
-            visitor.visit_ty(ty);
+        ImplItemKind::TyAlias(ref bounds, ref ty) => {
+            walk_list!(visitor, visit_param_bound, bounds);
+            walk_list!(visitor, visit_ty, ty);
         }
         ImplItemKind::Macro(ref mac) => {
             visitor.visit_mac(mac);