Description
I tried this code:
with expansion:
https://gist.github.com/bkchr/92b754ec82efcc115637ab5533e79ff4
use futures::{future, select}; // 0.3.6
pub enum Foo {
Bar,
Baz,
}
/* this function does produce warnings
fn match_foo(foo: Foo) -> i32 {
match foo {
x => 1,
_ => unreachable!("why you do this rust?"),
}
}
*/
pub async fn foo(foo: Foo) {
let mut a = future::ready(4);
use Foo::Bar;
let res = select! {
// but this doesn't
a_res = a => match foo {
Bar => 1,
_ => 4,
_ => unreachable!("why you do this rust?"),
},
};
assert_eq!(res, 4, "oh");
}
fn main() {
futures::executor::block_on(async move {
foo(Foo::Baz).await
});
}
I expected to see this happen:
Be warned about the unreachable pattern / enum variant.
Instead, this happened:
No warning was displayed despite an unreachable pattern being present.
Compiling playground v0.0.1 (/playground)
Finished dev [unoptimized + debuginfo] target(s) in 0.79s
Running `target/debug/playground`
thread 'main' panicked at 'assertion failed: `(left == right)`
left: `1`,
right: `4`: oh', src/main.rs:29:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Meta
rustc --version --verbose
:
rustc 1.47.0 (18bf6b4f0 2020-10-07)
binary: rustc
commit-hash: 18bf6b4f01a6feaf7259ba7cdae58031af1b7b39
commit-date: 2020-10-07
host: x86_64-unknown-linux-gnu
release: 1.47.0
LLVM version: 11.0
Credit for example @ordian , initial finding by @coriolinus