-
Notifications
You must be signed in to change notification settings - Fork 13k
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
False-positive with the unreachable code lint #88393
Comments
@rustbot claim |
Hi @bjorn3! Can you elaborate a little on what makes |
|
@rustbot release-assignment |
I've located the issue to be in the liveness check: rust/compiler/rustc_passes/src/liveness.rs Lines 875 to 896 in 56694b0
Here a diverge point sits inside a conditional block, but this information is lost when calling A simple fix for this would be skipping the check for conditional neighbors. But that will actually bring out another false negative case: #![allow(deprecated, invalid_value)]
enum Void {}
fn main() {
let b = false;
// should warn:
// any code following this `match` expression is unreachable, as all arms diverge
match b {
false => unsafe { std::mem::uninitialized::<Void>(); }
_ => unreachable!(),
}
println!();
} I'm quite new to the compiler code, but this case seems difficult to fix because the exhaustiveness check takes place in a earlier(?) pass which doesn't have the complete type information. |
Given the following code: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=67b068c7dded060fd71f7e5a5ca91278
The current output is:
I expected no lint to trigger as the
println!()
is actually reachable. This problem doesn't occur forpanic!()
.The text was updated successfully, but these errors were encountered: