Skip to content
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

false positive of or_fun_call for enum #9663

Closed
xxchan opened this issue Oct 16, 2022 · 2 comments
Closed

false positive of or_fun_call for enum #9663

xxchan opened this issue Oct 16, 2022 · 2 comments
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have

Comments

@xxchan
Copy link
Contributor

xxchan commented Oct 16, 2022

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

@xxchan xxchan added C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have labels Oct 16, 2022
@kraktus
Copy link
Contributor

kraktus commented Oct 17, 2022

probably fixed already by #9610

@J-ZhengLi
Copy link
Member

Same as #9693, it appears to be already fixed, so I'm closing this, thank you for the report 👀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have
Projects
None yet
Development

No branches or pull requests

3 participants