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

or_fun_call doesn't suggest map_or_else #8993

Closed
junbl opened this issue Jun 13, 2022 · 2 comments · Fixed by #9689
Closed

or_fun_call doesn't suggest map_or_else #8993

junbl opened this issue Jun 13, 2022 · 2 comments · Fixed by #9689
Assignees
Labels
C-bug Category: Clippy is not doing the correct thing I-false-negative Issue: The lint should have been triggered on code, but wasn't

Comments

@junbl
Copy link

junbl commented Jun 13, 2022

Summary

When calling map_or with a function call as the default value, clippy does not suggest writing it with map_or_else instead as it does for the other or methods.

This may be related to #5821.

Lint Name

or_fun_call

Reproducer

#![deny(clippy::or_fun_call)]

fn g() -> i32 { 3 }

fn main() {
    let v = Some(4);
    
    v.map_or(g(), |v| v);
    v.map_or_else(g, |v| v);
}

Playground link

I expected to see this happen:

The line with map_or should trigger the lint, suggesting the code below it.

Instead, this happened:

No lint is produced.

Version

rustc 1.61.0 (fe5b13d68 2022-05-18)
binary: rustc
commit-hash: fe5b13d681f25ee6474be29d748c65adcd91f69e
commit-date: 2022-05-18
host: x86_64-unknown-linux-gnu
release: 1.61.0
LLVM version: 14.0.0
@junbl junbl added C-bug Category: Clippy is not doing the correct thing I-false-negative Issue: The lint should have been triggered on code, but wasn't labels Jun 13, 2022
@alex-semenyuk
Copy link
Member

alex-semenyuk commented Jul 11, 2022

@rustbot claim

@alex-semenyuk alex-semenyuk removed their assignment Jul 27, 2022
@koka831
Copy link
Contributor

koka831 commented Oct 22, 2022

@rustbot claim

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-negative Issue: The lint should have been triggered on code, but wasn't
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants