1
Fork 0

match scrutinee need necessary parentheses for structs

This commit is contained in:
yukang 2023-07-14 08:20:29 +08:00
parent 3071e0aef6
commit c44b35e1c3
3 changed files with 68 additions and 0 deletions

View file

@ -666,6 +666,24 @@ trait UnusedDelimLint {
if !followed_by_block {
return false;
}
// Check if we need parens for `match &( Struct { feild: }) {}`.
{
let mut innermost = inner;
loop {
innermost = match &innermost.kind {
ExprKind::AddrOf(_, _, expr) => expr,
_ => {
if parser::contains_exterior_struct_lit(&innermost) {
return true;
} else {
break;
}
}
}
}
}
let mut innermost = inner;
loop {
innermost = match &innermost.kind {