-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unreachable pattern not warned when used in sufficiently complex macro / procmacro hack #78234
Comments
Can confirm the 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 {
Bar => 1,
_ => unreachable!("why you do this rust?"),
}
}
*/
pub async fn asdf(foo: Foo) {
let mut a = future::ready(4);
select! {
// but this doesn't
a_res = a => match foo {
Bar => 1,
_ => 4,
// _ => unreachable!("why you do this rust?"),
},
};
}
fn main() {
futures::executor::block_on(asdf(Foo::Baz));
} @rustbot prioritize |
@drahnr By the way, not sure if you realized this but matching on |
This appears to be due to the rust/compiler/rustc_middle/src/lint.rs Lines 245 to 260 in 7f58716
This should be fixed when dtolnay/proc-macro-hack#62 is implemented. I don't think there's anything that can be done on the rustc side. |
I think that was a result of minimization removing a |
Assigning |
According to this comment, this should have been fixed by dtolnay/proc-macro-hack#66, which was released in 0.5.19.
I am still not getting the warnings. |
It looks like that change requires explicit opt-in via |
This now produces a warning if you change the
|
I tried this code:
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=49f774bfbf796f141b31e716fba52820
with expansion:
https://gist.github.com/bkchr/92b754ec82efcc115637ab5533e79ff4
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.
Meta
rustc --version --verbose
:Credit for example @ordian , initial finding by @coriolinus
The text was updated successfully, but these errors were encountered: