Skip to content

map_unwrap_or should suggest is_ok_and(<f>) on a result #16258

@xtqqczze

Description

@xtqqczze

Summary

https://godbolt.org/z/GbzzGqb9G

Lint Name

map_unwrap_or

Reproducer

I tried this code:

pub fn m1(result: Result<i32, ()>) -> bool {
    result
    .map(|x| x == 42)
    .unwrap_or(false)
}

I expected to see this happen:

warning: called `map(<f>).unwrap_or(false)` on an `Result` value
...
help: use `is_ok_and(<f>)` instead

Instead, this happened:

no lint

Version

nightly

Metadata

Metadata

Assignees

Labels

C-bugCategory: Clippy is not doing the correct thingI-false-negativeIssue: The lint should have been triggered on code, but wasn't

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions