-
Notifications
You must be signed in to change notification settings - Fork 13.8k
unused_must_use: Don't warn on Result<(), Uninhabited>
#147382
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
base: master
Are you sure you want to change the base?
unused_must_use: Don't warn on Result<(), Uninhabited>
#147382
Conversation
This simplifies the initial conditional, and will allow reusing the variable in subsequent checks.
This suppresses warnings on things like `Result<(), !>`, which helps simplify code using the common pattern of having an `Error` associated type: code will only have to check the error if there is a possibility of error.
I'll be waiting for the outcome of T-lang's triage meeting before reviewing this since the proposed rules might very well change drastically (e.g., trait-driven vs. not trait-driven; cc Zulip discussion). |
Summarizing the Zulip discussion:
|
My proposal, here, is that we handle this simple case to make common patterns more usable. This does not rule out the possibility of adding more cases in the future, including general trait-based cases. However, I don't think we should make this common case wait on the more general cases. In particular, this solution does not close any doors on replacing this special case with a general case. This would unblock some planned work in the standard library to make |
As a general rule I think this should follow the same rules what |
This suppresses warnings on things like
Result<(), !>
, which helps simplify code using the common pattern of having anError
associated type: code will only have to check the error if there is a possibility of error.This will, for instance, help with future refactorings of
write!
in the standard library.As this is a user-visible change to lint behavior, it'll require a lang FCP.