Skip to content

manual_is_power_of_two is too broad for a default lint #13547

@newpavlov

Description

@newpavlov

Description

In my project I have a bunch of code like this:

use static_assertions as sa;

const MY_FLAG: u32 = const {
    // const computation
};

// Enforce that the flag mask contains only one bit
sa::const_assert_eq!(MY_FLAG.count_ones(), 1);

The new manual_is_power_of_two lint gets triggered by the assert. Changing it to is_power_of_two() as suggested by the lint would make the intent less clear.

Version

rustc 1.84.0-nightly (27861c4 2024-10-13)
binary: rustc
commit-hash: 27861c4
commit-date: 2024-10-13
host: x86_64-unknown-linux-gnu
release: 1.84.0-nightly
LLVM version: 19.1.1

Additional Labels

No response

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions