about summary refs log tree commit diff
path: root/src/libsyntax/visit.rs
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2014-08-27 21:46:52 -0400
committerNiko Matsakis <niko@alum.mit.edu>2014-08-27 21:46:52 -0400
commit1b487a890695e7d6dfbfe5dcd7d4fa0e8ca8003f (patch)
tree552fabade603ab0d148a49ae3cf1abd3f399740a /src/libsyntax/visit.rs
parent3ee047ae1ffab454270bc1859b3beef3556ef8f9 (diff)
downloadrust-1b487a890695e7d6dfbfe5dcd7d4fa0e8ca8003f.tar.gz
rust-1b487a890695e7d6dfbfe5dcd7d4fa0e8ca8003f.zip
Implement generalized object and type parameter bounds (Fixes #16462)
Diffstat (limited to 'src/libsyntax/visit.rs')
-rw-r--r--src/libsyntax/visit.rs38
1 files changed, 16 insertions, 22 deletions
diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs
index 6c6f59f0df6..7a35d82b0e4 100644
--- a/src/libsyntax/visit.rs
+++ b/src/libsyntax/visit.rs
@@ -298,13 +298,9 @@ pub fn walk_item<E: Clone, V: Visitor<E>>(visitor: &mut V, item: &Item, env: E)
                                      item.id,
                                      env.clone())
         }
-        ItemTrait(ref generics, _, ref trait_paths, ref methods) => {
+        ItemTrait(ref generics, _, ref bounds, ref methods) => {
             visitor.visit_generics(generics, env.clone());
-            for trait_path in trait_paths.iter() {
-                visitor.visit_path(&trait_path.path,
-                                   trait_path.ref_id,
-                                   env.clone())
-            }
+            walk_ty_param_bounds(visitor, bounds, env.clone());
             for method in methods.iter() {
                 visitor.visit_trait_item(method, env.clone())
             }
@@ -375,18 +371,13 @@ pub fn walk_ty<E: Clone, V: Visitor<E>>(visitor: &mut V, typ: &Ty, env: E) {
                 visitor.visit_ty(&*tuple_element_type, env.clone())
             }
         }
-        TyClosure(ref function_declaration, ref region) => {
+        TyClosure(ref function_declaration) => {
             for argument in function_declaration.decl.inputs.iter() {
                 visitor.visit_ty(&*argument.ty, env.clone())
             }
             visitor.visit_ty(&*function_declaration.decl.output, env.clone());
-            for bounds in function_declaration.bounds.iter() {
-                walk_ty_param_bounds(visitor, bounds, env.clone())
-            }
-            visitor.visit_opt_lifetime_ref(
-                typ.span,
-                region,
-                env.clone());
+            walk_ty_param_bounds(visitor, &function_declaration.bounds,
+                                 env.clone());
             walk_lifetime_decls(visitor, &function_declaration.lifetimes,
                                 env.clone());
         }
@@ -395,9 +386,8 @@ pub fn walk_ty<E: Clone, V: Visitor<E>>(visitor: &mut V, typ: &Ty, env: E) {
                 visitor.visit_ty(&*argument.ty, env.clone())
             }
             visitor.visit_ty(&*function_declaration.decl.output, env.clone());
-            for bounds in function_declaration.bounds.iter() {
-                walk_ty_param_bounds(visitor, bounds, env.clone())
-            }
+            walk_ty_param_bounds(visitor, &function_declaration.bounds,
+                                 env.clone());
             walk_lifetime_decls(visitor, &function_declaration.lifetimes,
                                 env.clone());
         }
@@ -415,10 +405,13 @@ pub fn walk_ty<E: Clone, V: Visitor<E>>(visitor: &mut V, typ: &Ty, env: E) {
             }
             visitor.visit_ty(&*function_declaration.decl.output, env.clone());
         }
-        TyPath(ref path, ref bounds, id) => {
+        TyPath(ref path, ref opt_bounds, id) => {
             visitor.visit_path(path, id, env.clone());
-            for bounds in bounds.iter() {
-                walk_ty_param_bounds(visitor, bounds, env.clone())
+            match *opt_bounds {
+                Some(ref bounds) => {
+                    walk_ty_param_bounds(visitor, bounds, env.clone());
+                }
+                None => { }
             }
         }
         TyFixedLengthVec(ref ty, ref expression) => {
@@ -532,7 +525,6 @@ pub fn walk_ty_param_bounds<E: Clone, V: Visitor<E>>(visitor: &mut V,
             TraitTyParamBound(ref typ) => {
                 walk_trait_ref_helper(visitor, typ, env.clone())
             }
-            StaticRegionTyParamBound => {}
             UnboxedFnTyParamBound(ref function_declaration) => {
                 for argument in function_declaration.decl.inputs.iter() {
                     visitor.visit_ty(&*argument.ty, env.clone())
@@ -540,7 +532,9 @@ pub fn walk_ty_param_bounds<E: Clone, V: Visitor<E>>(visitor: &mut V,
                 visitor.visit_ty(&*function_declaration.decl.output,
                                  env.clone());
             }
-            OtherRegionTyParamBound(..) => {}
+            RegionTyParamBound(ref lifetime) => {
+                visitor.visit_lifetime_ref(lifetime, env.clone());
+            }
         }
     }
 }