I tried this code:
fn foo() -> ! { todo!() }
fn main() {
let res = foo();
match res as Result<u32, u32> {
Ok(v) => todo!(),
Err(err) => todo!(),
}
}
I expected to see this happen: Should only have an unreachable code warning.
Instead, this happened: Also says res is unused.
warning: unreachable expression
--> src/main.rs:5:5
|
4 | let res = foo();
| ----- any code following this expression is unreachable
5 | / match res as Result<u32, u32> {
6 | | Ok(v) => todo!(),
7 | | Err(err) => todo!(),
8 | | }
| |_____^ unreachable expression
|
= note: `#[warn(unreachable_code)]` (part of `#[warn(unused)]`) on by default
warning: unused variable: `res`
--> src/main.rs:4:9
|
4 | let res = foo();
| ^^^ help: if this is intentional, prefix it with an underscore: `_res`
|
= note: `#[warn(unused_variables)]` (part of `#[warn(unused)]`) on by default
Meta
rustc --version --verbose:
I tried this code:
I expected to see this happen: Should only have an unreachable code warning.
Instead, this happened: Also says
resis unused.Meta
rustc --version --verbose: