-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
New lint [let_else_on_result_ok
]
#10988
Conversation
r? @giraffate (rustbot has picked a reviewer for you, use r? to override) |
5800fb5
to
185899a
Compare
☔ The latest upstream changes (presumably #10951) made this pull request unmergeable. Please resolve the merge conflicts. |
185899a
to
b967768
Compare
You explicitly do have to handle the case where there's an error with let/else already, what's the scenario this lint is expected to benefit? |
This tweet easily explains it best: https://twitter.com/nick_r_cameron/status/1588224853336793089 (though the lint description is incorrect, I wrote that pretty late :D) |
b967768
to
ca4c3ee
Compare
Looking through some examples it seems like this would be almost entirely false positives, meaning most of the changes happening would be making code worse to satisfy the lint by adding |
We could probably limit it to ones that |
There's nothing wrong with those cases though, e.g. plenty of them are handling A specific lint that suggests |
I only see a select few that do that. Majority of the others are ignoring an There really isn't any particularly good reason to remove such information in those cases, at worst you can just print to |
I went through a few pages, ignoring any |
That's fair. I do agree that there are many cases where this isn't applicable so I'll see if there's some way to make it more specialized. |
So, I've made a couple changes to it. It now only lints if the following are true:
Note that the final one would not account for functions that only ever return one variant, like let's say enum MyErrorType {
A,
B(u32),
}
fn my_error() -> Result<(), MyErrorType> {
Err(MyErrorType::A)
} Will still be linted. But I think this is fine. I think that should be good now. Is there anything else it should ignore? |
d2e5344
to
f7c0ef9
Compare
f7c0ef9
to
bd47855
Compare
☔ The latest upstream changes (presumably #10994) made this pull request unmergeable. Please resolve the merge conflicts. |
Hey this is triage, I'm closing this due to inactivity. Currently, @Centri3 sadly doesn't have the time to continue this implementation. If anyone is interested in continuing this PR, you're more than welcome to create a new PR and push it over the finish line. :D Thank you to @Centri3 and the reviewers for the time, that you already put into this! @rustbot label +S-inactive-closed -S-waiting-on-author -S-waiting-on-review |
Closes #9792.
changelog: New lint [
let_else_on_result_ok
]