mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-10 07:04:18 +00:00
Auto merge of #127524 - oli-obk:feed_item_attrs2, r=petrochenkov
Make ast `MutVisitor` have the same method name and style as `Visitor` It doesn't map 100% because some `MutVisitor` methods can filter or even expand to multiple items, but consistency seems nicer. tracking issue: https://github.com/rust-lang/rust/issues/127615
This commit is contained in:
commit
6d674685ae
1 changed files with 4 additions and 4 deletions
|
@ -121,7 +121,7 @@ fn remove_all_parens(pat: &mut P<Pat>) {
|
||||||
struct Visitor;
|
struct Visitor;
|
||||||
impl MutVisitor for Visitor {
|
impl MutVisitor for Visitor {
|
||||||
fn visit_pat(&mut self, pat: &mut P<Pat>) {
|
fn visit_pat(&mut self, pat: &mut P<Pat>) {
|
||||||
noop_visit_pat(pat, self);
|
walk_pat(self, pat);
|
||||||
let inner = match &mut pat.kind {
|
let inner = match &mut pat.kind {
|
||||||
Paren(i) => mem::replace(&mut i.kind, Wild),
|
Paren(i) => mem::replace(&mut i.kind, Wild),
|
||||||
_ => return,
|
_ => return,
|
||||||
|
@ -138,7 +138,7 @@ fn insert_necessary_parens(pat: &mut P<Pat>) {
|
||||||
impl MutVisitor for Visitor {
|
impl MutVisitor for Visitor {
|
||||||
fn visit_pat(&mut self, pat: &mut P<Pat>) {
|
fn visit_pat(&mut self, pat: &mut P<Pat>) {
|
||||||
use ast::BindingMode;
|
use ast::BindingMode;
|
||||||
noop_visit_pat(pat, self);
|
walk_pat(self, pat);
|
||||||
let target = match &mut pat.kind {
|
let target = match &mut pat.kind {
|
||||||
// `i @ a | b`, `box a | b`, and `& mut? a | b`.
|
// `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,
|
Ident(.., Some(p)) | Box(p) | Ref(p, _) if matches!(&p.kind, Or(ps) if ps.len() > 1) => p,
|
||||||
|
@ -160,7 +160,7 @@ fn unnest_or_patterns(pat: &mut P<Pat>) -> bool {
|
||||||
impl MutVisitor for Visitor {
|
impl MutVisitor for Visitor {
|
||||||
fn visit_pat(&mut self, p: &mut P<Pat>) {
|
fn visit_pat(&mut self, p: &mut P<Pat>) {
|
||||||
// This is a bottom up transformation, so recurse first.
|
// This is a bottom up transformation, so recurse first.
|
||||||
noop_visit_pat(p, self);
|
walk_pat(self, p);
|
||||||
|
|
||||||
// Don't have an or-pattern? Just quit early on.
|
// Don't have an or-pattern? Just quit early on.
|
||||||
let Or(alternatives) = &mut p.kind else { return };
|
let Or(alternatives) = &mut p.kind else { return };
|
||||||
|
@ -189,7 +189,7 @@ fn unnest_or_patterns(pat: &mut P<Pat>) -> bool {
|
||||||
|
|
||||||
// Deal with `Some(Some(0)) | Some(Some(1))`.
|
// Deal with `Some(Some(0)) | Some(Some(1))`.
|
||||||
if this_level_changed {
|
if this_level_changed {
|
||||||
noop_visit_pat(p, self);
|
walk_pat(self, p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue