-
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-negativeIssue: The lint should have been triggered on code, but wasn'tIssue: The lint should have been triggered on code, but wasn't
Description
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);
}
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
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-negativeIssue: The lint should have been triggered on code, but wasn'tIssue: The lint should have been triggered on code, but wasn't