Summary
Since 1.97.0 Clippy fires clippy::question_mark on code that handles &Option, while it shouldn't.
Lint Name
question_mark
Reproducer
I tried this code:
fn foo() -> &'static Option<i32> {
&None
}
fn bar() -> Option<()> {
match foo() {
Some(it) => {
dbg!(it);
}
None => return None,
}
Some(())
}
I saw this happen:
warning: this `match` expression can be replaced with `?`
--> src/lib.rs:6:5
|
6 | / match foo() {
7 | | Some(it) => {
8 | | dbg!(it);
... |
11 | | }
| |_____^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.97.0/index.html#question_mark
= note: `#[warn(clippy::question_mark)]` on by default
help: try instead
|
6 ~ {
7 + let it = foo()?;
8 + dbg!(it);
9 + }
|
I expected to see this happen:
The lint should not fire. The suggested fix does not compile, you cannot use ? on &Option.
Version
Additional Labels
No response
Summary
Since 1.97.0 Clippy fires
clippy::question_markon code that handles&Option, while it shouldn't.Lint Name
question_mark
Reproducer
I tried this code:
I saw this happen:
I expected to see this happen:
The lint should not fire. The suggested fix does not compile, you cannot use
?on&Option.Version
Additional Labels
No response