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

@ -620,6 +620,19 @@ fn f((x, y): (i32, i32)) {
);
}
#[test]
fn no_diagnostics_in_case_of_multiple_bounds() {
check_diagnostics(
r#"
fn f() {
let (b, a, b) = (2, 3, 5);
a = 8;
//^^^^^ 💡 error: cannot mutate immutable variable `a`
}
"#,
);
}
#[test]
fn for_loop() {
check_diagnostics(