Always pass the visitor as the first argument to walk* functions
This commit is contained in:
parent
3149037b57
commit
221ac86e09
@ -121,7 +121,7 @@ fn remove_all_parens(pat: &mut P<Pat>) {
|
||||
struct Visitor;
|
||||
impl MutVisitor for Visitor {
|
||||
fn visit_pat(&mut self, pat: &mut P<Pat>) {
|
||||
walk_pat(pat, self);
|
||||
walk_pat(self, pat);
|
||||
let inner = match &mut pat.kind {
|
||||
Paren(i) => mem::replace(&mut i.kind, Wild),
|
||||
_ => return,
|
||||
@ -138,7 +138,7 @@ fn insert_necessary_parens(pat: &mut P<Pat>) {
|
||||
impl MutVisitor for Visitor {
|
||||
fn visit_pat(&mut self, pat: &mut P<Pat>) {
|
||||
use ast::BindingMode;
|
||||
walk_pat(pat, self);
|
||||
walk_pat(self, pat);
|
||||
let target = match &mut pat.kind {
|
||||
// `i @ a | b`, `box a | b`, and `& mut? a | b`.
|
||||
Ident(.., Some(p)) | Box(p) | Ref(p, _) if matches!(&p.kind, Or(ps) if ps.len() > 1) => p,
|
||||
@ -160,7 +160,7 @@ struct Visitor {
|
||||
impl MutVisitor for Visitor {
|
||||
fn visit_pat(&mut self, p: &mut P<Pat>) {
|
||||
// This is a bottom up transformation, so recurse first.
|
||||
walk_pat(p, self);
|
||||
walk_pat(self, p);
|
||||
|
||||
// Don't have an or-pattern? Just quit early on.
|
||||
let Or(alternatives) = &mut p.kind else { return };
|
||||
@ -189,7 +189,7 @@ fn visit_pat(&mut self, p: &mut P<Pat>) {
|
||||
|
||||
// Deal with `Some(Some(0)) | Some(Some(1))`.
|
||||
if this_level_changed {
|
||||
walk_pat(p, self);
|
||||
walk_pat(self, p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user