diff options
| author | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2017-01-25 22:01:11 +0200 |
|---|---|---|
| committer | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2017-02-25 17:07:59 +0200 |
| commit | e8d01ea4c76f6f3cb4f71dbff261355f825d12bb (patch) | |
| tree | bd71bb08ce70f9e7e9eebcddd20d084b12dbf96c /src/libsyntax | |
| parent | 1572bf104dbf65d58bd6b889fa46229c9b92d6f9 (diff) | |
| download | rust-e8d01ea4c76f6f3cb4f71dbff261355f825d12bb.tar.gz rust-e8d01ea4c76f6f3cb4f71dbff261355f825d12bb.zip | |
rustc: store type parameter defaults outside of ty::Generics.
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/visit.rs | 49 |
1 files changed, 27 insertions, 22 deletions
diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index bfab7a250c6..013632141de 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -68,6 +68,9 @@ pub trait Visitor<'ast>: Sized { fn visit_expr_post(&mut self, _ex: &'ast Expr) { } fn visit_ty(&mut self, t: &'ast Ty) { walk_ty(self, t) } fn visit_generics(&mut self, g: &'ast Generics) { walk_generics(self, g) } + fn visit_where_predicate(&mut self, p: &'ast WherePredicate) { + walk_where_predicate(self, p) + } fn visit_fn(&mut self, fk: FnKind<'ast>, fd: &'ast FnDecl, s: Span, _: NodeId) { walk_fn(self, fk, fd, s) } @@ -488,28 +491,30 @@ pub fn walk_generics<'a, V: Visitor<'a>>(visitor: &mut V, generics: &'a Generics walk_list!(visitor, visit_attribute, &*param.attrs); } walk_list!(visitor, visit_lifetime_def, &generics.lifetimes); - for predicate in &generics.where_clause.predicates { - match *predicate { - WherePredicate::BoundPredicate(WhereBoundPredicate{ref bounded_ty, - ref bounds, - ref bound_lifetimes, - ..}) => { - visitor.visit_ty(bounded_ty); - walk_list!(visitor, visit_ty_param_bound, bounds); - walk_list!(visitor, visit_lifetime_def, bound_lifetimes); - } - WherePredicate::RegionPredicate(WhereRegionPredicate{ref lifetime, - ref bounds, - ..}) => { - visitor.visit_lifetime(lifetime); - walk_list!(visitor, visit_lifetime, bounds); - } - WherePredicate::EqPredicate(WhereEqPredicate{ref lhs_ty, - ref rhs_ty, - ..}) => { - visitor.visit_ty(lhs_ty); - visitor.visit_ty(rhs_ty); - } + walk_list!(visitor, visit_where_predicate, &generics.where_clause.predicates); +} + +pub fn walk_where_predicate<'a, V: Visitor<'a>>(visitor: &mut V, predicate: &'a WherePredicate) { + match *predicate { + WherePredicate::BoundPredicate(WhereBoundPredicate{ref bounded_ty, + ref bounds, + ref bound_lifetimes, + ..}) => { + visitor.visit_ty(bounded_ty); + walk_list!(visitor, visit_ty_param_bound, bounds); + walk_list!(visitor, visit_lifetime_def, bound_lifetimes); + } + WherePredicate::RegionPredicate(WhereRegionPredicate{ref lifetime, + ref bounds, + ..}) => { + visitor.visit_lifetime(lifetime); + walk_list!(visitor, visit_lifetime, bounds); + } + WherePredicate::EqPredicate(WhereEqPredicate{ref lhs_ty, + ref rhs_ty, + ..}) => { + visitor.visit_ty(lhs_ty); + visitor.visit_ty(rhs_ty); } } } |
