-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't have
Description
Summary
See title.
Specifically the lint for let Some(var_name) = ... else { return None; }
breaks,
but I suspect the other ? propagation lints might break as well
Lint Name
clippy::question_mark
Reproducer
I tried this code:
fn returns_option() -> Option<()> {
let _: Option<()> = try {
let Some(_) = Some(()) else { return None; };
};
Some(())
}
I saw this happen:
warning: this `let...else` may be rewritten with the `?` operator
--> src/digi4school/book.rs:65:5
|
65 | let Some(_) = Some(()) else { return None; };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `let _ = Some(())?;`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#question_mark
= note: `-W clippy::question-mark` implied by `-W clippy::style`
= help: to override `-W clippy::style` add `#[allow(clippy::question_mark)]`
I expected to see this happen:
No lint
Version
rustc 1.78.0-nightly (3406ada96 2024-02-21)
binary: rustc
commit-hash: 3406ada96f8e16e49e947a91db3eba0db45245fa
commit-date: 2024-02-21
host: x86_64-unknown-linux-gnu
release: 1.78.0-nightly
LLVM version: 18.1.0
Additional Labels
No response
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't have