diff options
| author | bors <bors@rust-lang.org> | 2023-06-21 17:41:00 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-06-21 17:41:00 +0000 |
| commit | 85493dfdb045ce78db78c6d50e8015bdb442cc62 (patch) | |
| tree | 5fba16d45087fcd80f83bc5420903e59efb242c6 | |
| parent | ae22869e36e04c8b791990c800e35230c2dc772f (diff) | |
| parent | d8b970f1fc759a912f6a28264ff87d8a86a52bb7 (diff) | |
| download | rust-85493dfdb045ce78db78c6d50e8015bdb442cc62.tar.gz rust-85493dfdb045ce78db78c6d50e8015bdb442cc62.zip | |
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
| -rw-r--r-- | crates/hir/src/lib.rs | 8 | ||||
| -rw-r--r-- | crates/ide-diagnostics/src/handlers/mutability_errors.rs | 13 |
2 files changed, 21 insertions, 0 deletions
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index 6df625380ff..1699c3dba77 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -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)) { diff --git a/crates/ide-diagnostics/src/handlers/mutability_errors.rs b/crates/ide-diagnostics/src/handlers/mutability_errors.rs index f61460e317f..c52d8042c75 100644 --- a/crates/ide-diagnostics/src/handlers/mutability_errors.rs +++ b/crates/ide-diagnostics/src/handlers/mutability_errors.rs @@ -1094,4 +1094,17 @@ fn main() { "#, ); } + + #[test] + fn regression_15099() { + check_diagnostics( + r#" +//- minicore: iterator, range +fn f() { + loop {} + for _ in 0..2 {} +} +"#, + ); + } } |
