-
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
question_mark suggestion changes code semantics #9518
Comments
## Issue Addressed fixes lints from the last rust release ## Proposed Changes Fix the lints, most of the lints by `clippy::question-mark` are false positives in the form of rust-lang/rust-clippy#9518 so it's allowed for now ## Additional Info
@rustbot claim |
If I'm not mistaken, it looks like there are two issues here. Clippy's suggested code wouldn't even compile because the question mark returns the inner value of the |
`question_mark` don't lint on `if let Err` with `else` cc #9518 AFAICT the only time this would be a valid suggestion is the rather esoteric ```rust let _ = if let Err(e) = x { return Err(e); } else { // no side effects x.unwrap() } ``` which doesn't seem worth checking to me. Please correct me if I'm missing something. changelog: [`question_mark`] don't lint on `if let Err` with `else`
## Issue Addressed fixes lints from the last rust release ## Proposed Changes Fix the lints, most of the lints by `clippy::question-mark` are false positives in the form of rust-lang/rust-clippy#9518 so it's allowed for now ## Additional Info
Summary
If let expression that produces a result is suggested to change to
?
, changing the semantics of the codeLint Name
question_mark
Reproducer
I tried this code:
I saw this happen:
I expected to see this happen:
There should be no warning. Changing the code for what clippy suggests would prevent calling
do_something_with_result
when the result is an errorVersion
Additional Labels
No response
The text was updated successfully, but these errors were encountered: