-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
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
Sometimes a manual impl of the ? operator is needed, because using it will cause "type annotations needed" due to the From::from() function it calls on the error type.
Lint Name
question_mark
Reproducer
I tried this code:
fn main() {
_ = (|| {
if let Err(err) = Err::<(), _>(()) {
return Err(err);
}
Ok(())
})();
}I saw this happen:
warning: this block may be rewritten with the `?` operator
--> src/main.rs:3:9
|
3 | / if let Err(err) = Err::<(), _>(()) {
4 | | return Err(err);
5 | | }
| |_________^ help: replace it with: `Err::<(), _>(())?;`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.91.0/index.html#question_mark
= note: `#[warn(clippy::question_mark)]` on by default
I expected to see this happen:
No warning. Replacing with Clippy's suggestion leads to a "type annotations needed" error.
Version
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