-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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 Reproducer. Note that in my trials, this only happens when one variant is std::io::Error
Lint Name
or_fun_call
Reproducer
I tried this code:
pub enum E1 {
A(usize),
B(std::io::Error),
}
pub fn foo() -> Result<(), E1> {
None.ok_or(E1::A(1))
}I saw this happen:
no warning
I expected to see this happen:
warning: use of `ok_or` followed by a function call
--> src/tmp1/src/main.rs:61:10
|
61 | None.ok_or(E1::A(1))
| ^^^^^^^^^^^^^^^ help: try this: `ok_or_else(|| E1::A(1))`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#or_fun_call
= note: `#[warn(clippy::or_fun_call)]` on by default
Version
rustc 1.66.0-nightly (b8c35ca26 2022-10-15)
binary: rustc
commit-hash: b8c35ca26b191bb9a9ac669a4b3f4d3d52d97fb1
commit-date: 2022-10-15
host: aarch64-apple-darwin
release: 1.66.0-nightly
LLVM version: 15.0.2
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