Skip to content

suboptimal suggestion for match of checked math #15655

@hkBst

Description

@hkBst

Description

Given (playground):

fn f1() {
    match 1usize.checked_sub(1) {
        Some(v) => v,
        None => 0,
    };
}

clippy suggests 1usize.checked_sub(1).unwrap_or_default();, but I think it should suggest 1usize.saturating_sub(1); instead for both of those.

Version


Additional Labels

No response

Metadata

Metadata

Assignees

Labels

C-enhancementCategory: Enhancement of lints, like adding more cases or adding help messages

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions