You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The lint suggests truncating 3.0000000000000000e+00 to 3 which causes a "mismatched types" compilation error.
Lint Name
clippy::excessive_precision
Reproducer
I tried this code:
pubconstDATA:f64 = 3.0000000000000000e+00;
I saw this happen:
cargo clippy --fix --allow-staged
Checking clippy_test v0.1.0 (C:\dev\tencek\sandbox\rust\clippy_test)
warning: failed to automatically apply fixes suggested by rustc to crate `clippy_test`
after fixes were automatically applied the compiler reported errors within these files:
* src\data.rs
This likely indicates a bug in either rustc or cargo itself,
and we would appreciate a bug report! You're likely to see
a number of compiler warnings after this message which cargo
attempted to fix but failed. If you could open an issue at
https://github.com/rust-lang/rust-clippy/issues
quoting the full output of this command we'd be very appreciative!
Note that you may be able to make some more progress in the near-term
fixing code with the `--broken-code` flag
The following errors were reported:
error[E0308]: mismatched types
--> src\data.rs:1:23
|
1 | pub const DATA: f64 = 3;
| ^
| |
| expected `f64`, found integer
| help: use a float literal: `3.0`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0308`.
Original diagnostics will follow.
warning: float has excessive precision
--> src\data.rs:1:23
|
1 | pub const DATA: f64 = 3.0000000000000000e+00;
| ^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `3`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#excessive_precision
= note: `#[warn(clippy::excessive_precision)]` on by default
warning: `clippy_test` (bin "clippy_test") generated 1 warning (run `cargo clippy --fix --bin "clippy_test"` to apply 1 suggestion)
warning: failed to automatically apply fixes suggested by rustc to crate `clippy_test`
after fixes were automatically applied the compiler reported errors within these files:
* src\data.rs
This likely indicates a bug in either rustc or cargo itself,
and we would appreciate a bug report! You're likely to see
a number of compiler warnings after this message which cargo
attempted to fix but failed. If you could open an issue at
https://github.com/rust-lang/rust-clippy/issues
quoting the full output of this command we'd be very appreciative!
Note that you may be able to make some more progress in the near-term
fixing code with the `--broken-code` flag
The following errors were reported:
error[E0308]: mismatched types
--> src\data.rs:1:23
|
1 | pub const DATA: f64 = 3;
| ^
| |
| expected `f64`, found integer
| help: use a float literal: `3.0`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0308`.
Original diagnostics will follow.
fix [`excessive_precision`] suggestions on floats written in scientific notation
fixes#12954
changelog: fix [`excessive_precision`] suggestions on float literal written in scientific notation
Summary
The lint suggests truncating
3.0000000000000000e+00
to3
which causes a "mismatched types" compilation error.Lint Name
clippy::excessive_precision
Reproducer
I tried this code:
I saw this happen:
I expected to see this happen:
Probably this:
Version
Additional Labels
I-suggestion-causing-error
The text was updated successfully, but these errors were encountered: