mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
Add storage dead for let bindings without initializer
This commit is contained in:
parent
4cbb940cc4
commit
d7da9e64d1
4 changed files with 79 additions and 44 deletions
|
@ -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(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue