Unhelpful unreachable_code
warning on a tuple constructor with fields of uninhabited types
#139627
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-lints
Area: Lints (warnings about flaws in source code) such as unused_mut.
L-unreachable_code
Lint: unreachable_code
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Code
Current output
Desired output
Rationale and extra context
I can technically agree that the
drop(s)
expression is unreachable, but this is not becauseS(void)
is of an uninhabited type — it's because this function is impossible to call. However, since a body of a function is not marked as unreachable just because of the function's parameters, and since constructors do not divert on their own (even if using an impossible value for one of the fields), there should be no warning about unreachable code here. Moreover, in this example, the warning caused another unhelpful warning about an unused variable that is actually used.Other cases
Rust Version
Anything else?
No response
The text was updated successfully, but these errors were encountered: