Open
Description
Summary
The fix in #15017 is incomplete and only handles the particular issue that was reported. The problem is that brackets are needed in the general case to create a scope which will restrict the lifetime of created values.
Reproducer
I tried this code:
fn main() {
let a = 10;
match 11 {
a => { println!("a = {a}"); }
}
println!("a = {a}");
}
Before autofix, this code prints:
a = 11
a = 10
After autofix, the code prints:
a = 11
a = 11
because the autofix, even with #15017 applied, reads:
fn main() {
let a = 10;
let a = 11;
{ println!("a = {a}"); }
println!("a = {a}");
}
Version
Clippy master as of 9e7782b8
Additional Labels
@rustbot label +I-suggestion-causes-bug