Skip to content

Allowing clippy::arithmetic in const contexts #9307

Closed
@DrSloth

Description

@DrSloth

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesgood first issueThese issues are a good way to get started with Clippy

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions