1
Fork 0

Auto merge of #113679 - chenyukang:yukang-fix-lint-113459, r=cjgillot

Match scrutinee need necessary parentheses for structs

Fixes #113459
This commit is contained in:
bors 2023-08-15 03:21:47 +00:00
commit d7e751006c
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 {