Skip to content

inconsistent_digit_grouping is inconsistent when a floating point exponent used #6096

@iliekturtles

Description

@iliekturtles

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
    

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions