mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 21:43:37 +00:00
Auto merge of #15104 - Veykril:mir-borrow-synthetic, r=Veykril
Skip mutable diagnostics on synthetic bindings Fixes https://github.com/rust-lang/rust-analyzer/issues/15099 We probabnly need to look into this in a more general manner in the future now that we desugar more things
This commit is contained in:
commit
85493dfdb0
2 changed files with 21 additions and 0 deletions
|
@ -1661,6 +1661,14 @@ impl DefWithBody {
|
|||
let Some(&local) = mir_body.binding_locals.get(binding_id) else {
|
||||
continue;
|
||||
};
|
||||
if body[binding_id]
|
||||
.definitions
|
||||
.iter()
|
||||
.any(|&pat| source_map.pat_syntax(pat).is_err())
|
||||
{
|
||||
// Skip synthetic bindings
|
||||
continue;
|
||||
}
|
||||
let need_mut = &mol[local];
|
||||
let local = Local { parent: self.into(), binding_id };
|
||||
match (need_mut, local.is_mut(db)) {
|
||||
|
|
|
@ -1091,6 +1091,19 @@ fn main() {
|
|||
//^^^^^ 💡 weak: variable does not need to be mutable
|
||||
f(x);
|
||||
}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn regression_15099() {
|
||||
check_diagnostics(
|
||||
r#"
|
||||
//- minicore: iterator, range
|
||||
fn f() {
|
||||
loop {}
|
||||
for _ in 0..2 {}
|
||||
}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue