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

Allowing clippy::arithmetic in const contexts #9307

Closed
DrSloth opened this issue Aug 8, 2022 · 1 comment · Fixed by #9365
Closed

Allowing clippy::arithmetic in const contexts #9307

DrSloth opened this issue Aug 8, 2022 · 1 comment · Fixed by #9365
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

@DrSloth
Copy link

DrSloth commented Aug 8, 2022

Description

The new clippy::arithmetic lint always lints against usage of arithmetic operators. Would it be feasible to not lint in const contexts? The reasoning for the lint is the overflow/panic behavior, there are a lot of scenarios which could be statically checked.

For instance:

// This will never panic
let x = 60i32 * 100;
// This will never panic and a panic in a const would appear at compile time
const Y = 100u8 + 17;

Would it be feasible to disallow arithmetic only in scenarios which may actually overflow/panic?

Version

binary: rustc
commit-hash: d394408fb38c4de61f765a3ed5189d2731a1da91
commit-date: 2022-08-07
host: x86_64-unknown-linux-gnu
release: 1.65.0-nightly
LLVM version: 14.0.6

Additional Labels

@rustbot label +C-enhancement

@rustbot rustbot added the C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages label Aug 8, 2022
@xFrednet xFrednet added the good-first-issue These issues are a good way to get started with Clippy label Aug 8, 2022
@c410-f3r
Copy link
Contributor

Yes, it is in my TODO list. I will probably provide a PR in the following days.

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

Successfully merging a pull request may close this issue.

4 participants