-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
rustc 1.92.0-beta3 flags unreachable code where there is none #149571
Copy link
Copy link
Closed
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.L-unreachable_codeLint: unreachable_codeLint: unreachable_codeP-highHigh priorityHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.Performance or correctness regression from stable to beta.
Milestone
Metadata
Metadata
Assignees
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.L-unreachable_codeLint: unreachable_codeLint: unreachable_codeP-highHigh priorityHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.Performance or correctness regression from stable to beta.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Code
Current output
Desired output
Rationale and extra context
The real-world version of this where the lint tripped upon updating the compiler looks like this:
It is intended that the passed continuation never returns, and no user code exists past it. The fact that it will never return is surfaced to the caller through the type signature.
I understand that there may be MIR which is "unreachable" in this case (the return path), but there is no unreachable user code.
There's currently no way to write the function above without suppressing the modified lint that I can see, because the lint also triggers on
If we had never type support, this lint might be reasonable as with
#![feature(never_type)]and a signaturefn reset_stack_guards(continuation: impl FnOnce() -> !) -> !, the lint does not complain.Since never types are not stable, this means that a useful, default-enabled lint now reports in non-actionable situations.
Other cases
Rust Version
Anything else?
No response