Fix explicit deref problems in closure capture

This commit is contained in:
hkalbasi 2023-04-14 15:32:40 +03:30
parent 1ee88db412
commit 7cb4318331
4 changed files with 90 additions and 4 deletions

View file

@ -1564,7 +1564,10 @@ impl DefWithBody {
}
(mir::MutabilityReason::Not, true) => {
if !infer.mutated_bindings_in_closure.contains(&binding_id) {
acc.push(UnusedMut { local }.into())
let should_ignore = matches!(body[binding_id].name.as_str(), Some(x) if x.starts_with("_"));
if !should_ignore {
acc.push(UnusedMut { local }.into())
}
}
}
}