fn main() {
let mut x = 0;
match () {
() if {
x = 42;
false
} => {}
_ => {
println!("{}", x); // prints 42
}
}
}
(Playground)
Output:
Errors:
Compiling playground v0.0.1 (/playground)
warning: value assigned to `x` is never read
--> src/main.rs:5:13
|
5 | x = 42;
| ^
|
= note: `#[warn(unused_assignments)]` on by default
= help: maybe it is overwritten before being read?
warning: 1 warning emitted
Finished dev [unoptimized + debuginfo] target(s) in 0.74s
Running `target/debug/playground`
@rustbot modify labels: T-compiler, A-diagnostics, A-lint, D-incorrect, C-bug
(Playground)
Output:
Errors:
@rustbot modify labels: T-compiler, A-diagnostics, A-lint, D-incorrect, C-bug