Implement macro-based deref!() syntax for deref patterns

Stop using `box PAT` syntax for deref patterns, as it's misleading and
also causes their semantics being tangled up.
This commit is contained in:
Michael Goulet 2024-03-20 16:53:50 -04:00
parent 2627e9f301
commit 2d633317f3
31 changed files with 123 additions and 35 deletions

View file

@ -1183,7 +1183,7 @@ impl EarlyLintPass for UnusedParens {
self.check_unused_parens_pat(cx, &f.pat, false, false, keep_space);
},
// Avoid linting on `i @ (p0 | .. | pn)` and `box (p0 | .. | pn)`, #64106.
Ident(.., Some(p)) | Box(p) => self.check_unused_parens_pat(cx, p, true, false, keep_space),
Ident(.., Some(p)) | Box(p) | Deref(p) => self.check_unused_parens_pat(cx, p, true, false, keep_space),
// Avoid linting on `&(mut x)` as `&mut x` has a different meaning, #55342.
// Also avoid linting on `& mut? (p0 | .. | pn)`, #64106.
Ref(p, m) => self.check_unused_parens_pat(cx, p, true, *m == Mutability::Not, keep_space),