Support "for loop" MIR lowering

This commit is contained in:
hkalbasi 2023-03-02 11:18:50 +03:30
parent ac04bfd7a7
commit 6377d50bd1
8 changed files with 292 additions and 79 deletions

View file

@ -507,6 +507,22 @@ fn f(x: i32) {
x = 5;
//^^^^^ 💡 error: cannot mutate immutable variable `x`
}
"#,
);
}
#[test]
fn for_loop() {
check_diagnostics(
r#"
//- minicore: iterators
fn f(x: [(i32, u8); 10]) {
for (a, mut b) in x {
//^^^^^ 💡 weak: remove this `mut`
a = 2;
//^^^^^ 💡 error: cannot mutate immutable variable `a`
}
}
"#,
);
}