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

v.checked_sub(1).unwrap_or(v) is also an implicit_saturating_sub #8215

Closed
gilescope opened this issue Jan 3, 2022 · 3 comments
Closed

v.checked_sub(1).unwrap_or(v) is also an implicit_saturating_sub #8215

gilescope opened this issue Jan 3, 2022 · 3 comments
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages good-first-issue These issues are a good way to get started with Clippy

Comments

@gilescope
Copy link

Description

we already detect saturating_subs done one way:

https://github.com/rust-lang/rust-clippy/blob/master/clippy_lints/src/implicit_saturating_sub.rs

I came across someone doing it another way: v.checked_sub(1).unwrap_or(v)

Thought it might be one to add into the logic. Maybe an easy one for a new person to hack on?

Version

n/a

Additional Labels

No response

@camsteffen camsteffen added C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages good-first-issue These issues are a good way to get started with Clippy labels Jan 7, 2022
@tamaroning
Copy link
Contributor

Hi, @gilescope . Are you tackling with this?

@tamaroning
Copy link
Contributor

tamaroning commented Feb 19, 2022

This lint seems to be covered by #1557

@giraffate
Copy link
Contributor

As noted above, the manual_saturating_arithmetic covers this, so I'm closing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages good-first-issue These issues are a good way to get started with Clippy
Projects
None yet
Development

No branches or pull requests

4 participants