mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-29 18:23:49 +00:00
or-patterns: syntax: adjust visit
and mut_visit
.
This commit is contained in:
parent
ca968a10d8
commit
998060ba3f
@ -402,14 +402,11 @@ pub fn noop_visit_use_tree<T: MutVisitor>(use_tree: &mut UseTree, vis: &mut T) {
|
||||
vis.visit_span(span);
|
||||
}
|
||||
|
||||
pub fn noop_flat_map_arm<T: MutVisitor>(
|
||||
mut arm: Arm,
|
||||
vis: &mut T,
|
||||
) -> SmallVec<[Arm; 1]> {
|
||||
let Arm { attrs, pats, guard, body, span, id } = &mut arm;
|
||||
pub fn noop_flat_map_arm<T: MutVisitor>(mut arm: Arm, vis: &mut T) -> SmallVec<[Arm; 1]> {
|
||||
let Arm { attrs, pat, guard, body, span, id } = &mut arm;
|
||||
visit_attrs(attrs, vis);
|
||||
vis.visit_id(id);
|
||||
visit_vec(pats, |pat| vis.visit_pat(pat));
|
||||
vis.visit_pat(pat);
|
||||
visit_opt(guard, |guard| vis.visit_expr(guard));
|
||||
vis.visit_expr(body);
|
||||
vis.visit_span(span);
|
||||
@ -1132,8 +1129,8 @@ pub fn noop_visit_expr<T: MutVisitor>(Expr { node, id, span, attrs }: &mut Expr,
|
||||
vis.visit_ty(ty);
|
||||
}
|
||||
ExprKind::AddrOf(_m, ohs) => vis.visit_expr(ohs),
|
||||
ExprKind::Let(pats, scrutinee) => {
|
||||
visit_vec(pats, |pat| vis.visit_pat(pat));
|
||||
ExprKind::Let(pat, scrutinee) => {
|
||||
vis.visit_pat(pat);
|
||||
vis.visit_expr(scrutinee);
|
||||
}
|
||||
ExprKind::If(cond, tr, fl) => {
|
||||
|
@ -678,9 +678,8 @@ pub fn walk_anon_const<'a, V: Visitor<'a>>(visitor: &mut V, constant: &'a AnonCo
|
||||
}
|
||||
|
||||
pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) {
|
||||
for attr in expression.attrs.iter() {
|
||||
visitor.visit_attribute(attr);
|
||||
}
|
||||
walk_list!(visitor, visit_attribute, expression.attrs.iter());
|
||||
|
||||
match expression.node {
|
||||
ExprKind::Box(ref subexpression) => {
|
||||
visitor.visit_expr(subexpression)
|
||||
@ -719,8 +718,8 @@ pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) {
|
||||
visitor.visit_expr(subexpression);
|
||||
visitor.visit_ty(typ)
|
||||
}
|
||||
ExprKind::Let(ref pats, ref scrutinee) => {
|
||||
walk_list!(visitor, visit_pat, pats);
|
||||
ExprKind::Let(ref pat, ref scrutinee) => {
|
||||
visitor.visit_pat(pat);
|
||||
visitor.visit_expr(scrutinee);
|
||||
}
|
||||
ExprKind::If(ref head_expression, ref if_block, ref optional_else) => {
|
||||
@ -831,10 +830,10 @@ pub fn walk_param<'a, V: Visitor<'a>>(visitor: &mut V, param: &'a Param) {
|
||||
}
|
||||
|
||||
pub fn walk_arm<'a, V: Visitor<'a>>(visitor: &mut V, arm: &'a Arm) {
|
||||
walk_list!(visitor, visit_pat, &arm.pats);
|
||||
if let Some(ref e) = &arm.guard {
|
||||
visitor.visit_expr(e);
|
||||
}
|
||||
visitor.visit_pat(&arm.pat);
|
||||
// HACK(or_patterns; Centril | dlrobertson):
|
||||
// If you change this, also change the hack in `lowering.rs`.
|
||||
walk_list!(visitor, visit_expr, &arm.guard);
|
||||
visitor.visit_expr(&arm.body);
|
||||
walk_list!(visitor, visit_attribute, &arm.attrs);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user