Add storage dead for let bindings without initializer

This commit is contained in:
hkalbasi 2023-03-14 12:15:16 +03:30
parent 4cbb940cc4
commit d7da9e64d1
4 changed files with 79 additions and 44 deletions

View file

@ -505,6 +505,30 @@ fn main() {
);
}
#[test]
fn initialization_is_not_mutation_in_loop() {
check_diagnostics(
r#"
fn main() {
let a;
loop {
let c @ (
mut b,
//^^^^^ 💡 weak: variable does not need to be mutable
mut d
//^^^^^ 💡 weak: variable does not need to be mutable
);
a = 1;
//^^^^^ 💡 error: cannot mutate immutable variable `a`
b = 1;
c = (2, 3);
d = 3;
}
}
"#,
);
}
#[test]
fn function_arguments_are_initialized() {
check_diagnostics(