Detect "bound more than once" error and suppress need-mut for it.

This commit is contained in:
hkalbasi 2023-06-04 12:39:36 +03:30
parent 08f89193b5
commit 71f3e4b08c
4 changed files with 84 additions and 8 deletions

View file

@ -1643,7 +1643,11 @@ impl DefWithBody {
)
}
let mol = &borrowck_result.mutability_of_locals;
for (binding_id, _) in hir_body.bindings.iter() {
for (binding_id, binding_data) in hir_body.bindings.iter() {
if binding_data.problems.is_some() {
// We should report specific diagnostics for these problems, not `need-mut` and `unused-mut`.
continue;
}
let Some(&local) = mir_body.binding_locals.get(binding_id) else {
continue;
};