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

inconsistent_digit_grouping is inconsistent when a floating point exponent used #6096

Closed
iliekturtles opened this issue Sep 29, 2020 · 2 comments · Fixed by #6104
Closed
Labels
C-bug Category: Clippy is not doing the correct thing

Comments

@iliekturtles
Copy link

The inconsistent_digit_grouping is inconsistent when a floating point exponent is used. e.g. 1.234E1.

https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=c4df1f0f3ccc3411adf952eba66cf300

fn main() {
    let a = 1.025_011_10E0;
    let b = 1.025_011_10_E0;
    
    println!("{}", a);
    println!("{}", b);
}

I expected to see this happen: No warning is displayed for either literal.

Instead, this happened: A inconsistent_digit_grouping warning is displayed only for the literal assigned to b.

It looks like the final _ before the E binds to the fractional portion of the number rather than the exponent. It would be good if an _ before the E did not group with the fractional portion so that an _ can be used to make the E stand out from the digits.

Meta

  • cargo clippy -V: e.g. clippy 0.0.212 (f455e46 2020-06-20)
  • rustc -Vv:
    rustc 1.46.0-nightly (f455e46ea 2020-06-20)
    binary: rustc
    commit-hash: f455e46eae1a227d735091091144601b467e1565
    commit-date: 2020-06-20
    host: x86_64-unknown-linux-gnu
    release: 1.46.0-nightly
    LLVM version: 10.0
    
@iliekturtles iliekturtles added the C-bug Category: Clippy is not doing the correct thing label Sep 29, 2020
@ghost
Copy link

ghost commented Oct 1, 2020

I'll fix this one.

@ghost ghost mentioned this issue Oct 2, 2020
bors added a commit that referenced this issue Oct 2, 2020
Allow exponent separator

Fixes #6096

changelog: Fixed bug in `clippy::inconsistent_digit_grouping` when floating point exponent is used
bors added a commit that referenced this issue Oct 2, 2020
Allow exponent separator

Fixes #6096

changelog: Fixed bug in `clippy::inconsistent_digit_grouping` when floating point exponent is used
@bors bors closed this as completed in e91202c Oct 2, 2020
@iliekturtles
Copy link
Author

Thanks @mikerite!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant