rust-lang / rust-lang/rust-clippy

`excessive_precision` adds underscores that weren't there before

Open
#6,232 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug L-suggestion
Dominant language
Rust
Stars
13.5k
Forks
2.2k
Avg merge
2d 10h
Merged PRs (30d)
32

Description

I tried this code:

pub const Y: f64 = 0.33333333333333334;

I expected to see this happen: excessive_precision replaces it with 0.3333333333333333.

Instead, this happened: excessive_precision replaces it with 0.333_333_333_333_333_3.

Meta
  • cargo clippy -V: clippy 0.0.212 (ffa2e7a 2020-10-24)
  • rustc -Vv:
rustc 1.49.0-nightly (ffa2e7ae8 2020-10-24)
binary: rustc
commit-hash: ffa2e7ae8fbf9badc035740db949b9dae271c29f
commit-date: 2020-10-24
host: x86_64-unknown-linux-gnu
release: 1.49.0-nightly
LLVM version: 11.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the reported excessive_precision lint with the Rust constant shown in the issue, then locate the lint's implementation and existing tests. Check how the suggested replacement is formatted; done means the suggestion preserves the original decimal style without adding underscores, with regression coverage for this example.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.