fix #105028, Only suggest removing struct field from destructive binding in shorthand scenario
This commit is contained in:
parent
41e0363055
commit
0e24cee063
3 changed files with 37 additions and 2 deletions
|
@ -1548,7 +1548,13 @@ impl<'tcx> Liveness<'_, 'tcx> {
|
|||
.or_insert_with(|| (ln, var, vec![id_and_sp]));
|
||||
});
|
||||
|
||||
let can_remove = matches!(&pat.kind, hir::PatKind::Struct(_, _, true));
|
||||
let can_remove = match pat.kind {
|
||||
hir::PatKind::Struct(_, fields, true) => {
|
||||
// if all fields are shorthand, remove the struct field, otherwise, mark with _ as prefix
|
||||
fields.iter().all(|f| f.is_shorthand)
|
||||
}
|
||||
_ => false,
|
||||
};
|
||||
|
||||
for (_, (ln, var, hir_ids_and_spans)) in vars {
|
||||
if self.used_on_entry(ln, var) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue