rust-lang / rust-clippy

A bunch of lints to catch common mistakes and improve your Rust code. Book: https://doc.rust-lang.org/clippy/
https://rust-lang.github.io/rust-clippy/
Other
11.34k stars 1.53k forks source link

inconsistent_digit_grouping doesn't like grouping 0s by base 2 #7230

Open gilescope opened 3 years ago

gilescope commented 3 years ago

Lint name: inconsistent-digit-grouping

I tried this code:

1_0000_0000

The lint suggests the following grouping but it doesn't show the same intent:

100_000_000

Many times we're dealing with computers that like base 2. We should allow consistent base 2 groupings as not being something we should complain about.

This is inconsistent and I would be ok with it linting:

1_000_0_0000

But if there's a consistent pattern I think it's really not a helpful lint. I think we need to get a bit more nuanced with how this lint is designed.

xFrednet commented 3 years ago

Hey, thank you for the report. Could you try to reproduce this false positive again? I've tried the example in Rust's playground, but Clippy didn't trigger on 1_0000_0000. See playground :upside_down_face: