Open
Description
code like this causes a proper warning
fn main() {
let mut a;
let b = 4;
let c = 5;
a = b;
a = c;
println!("{}", a);
}
=>
warning: value assigned to `a` is never read
--> src/main.rs:6:5
|
6 | a = b;
| ^
|
= note: #[warn(unused_assignments)] on by default
however if a is a struct field, I get no warning at all.
struct Foo {
x: i32,
}
fn main() {
let mut strct = Foo {
x: 0, // maybe warn here, too?
};
let b = 4;
let c = 5;
strct.x = b; // please warn!
strct.x = c;
println!("{}", strct.x);
}
playground: https://play.rust-lang.org/?gist=c904ff202754b2691e2968977620fd7a&version=nightly
I ran into bugs in my code that could have been prevented by warning about this :(