From 1b487a890695e7d6dfbfe5dcd7d4fa0e8ca8003f Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Wed, 27 Aug 2014 21:46:52 -0400 Subject: Implement generalized object and type parameter bounds (Fixes #16462) --- src/libsyntax/visit.rs | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-) (limited to 'src/libsyntax/visit.rs') 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>(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>(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>(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>(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>(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>(visitor: &mut V, visitor.visit_ty(&*function_declaration.decl.output, env.clone()); } - OtherRegionTyParamBound(..) => {} + RegionTyParamBound(ref lifetime) => { + visitor.visit_lifetime_ref(lifetime, env.clone()); + } } } } -- cgit 1.4.1-3-g733a5