diff options
| author | bors <bors@rust-lang.org> | 2024-07-16 12:56:10 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-07-16 12:56:10 +0000 |
| commit | 0ee9f44568b60aaef5d04684cb08f112edd89542 (patch) | |
| tree | ba07607fb70ddadffe7b58c83ed7dd4ab4843ced /tests/ui | |
| parent | eb4d88e690c431691bc0fd8eaa9f7096ecc2a723 (diff) | |
| parent | 489a77831ce61e3e3679f4fbcf93be42d3922e52 (diff) | |
Auto merge of #13096 - apoisternex:issue12954, r=y21
fix [`excessive_precision`] suggestions on floats written in scientific notation fixes #12954 changelog: fix [`excessive_precision`] suggestions on float literal written in scientific notation
Diffstat (limited to 'tests/ui')
| -rw-r--r-- | tests/ui/excessive_precision.fixed | 4 | ||||
| -rw-r--r-- | tests/ui/excessive_precision.rs | 4 | ||||
| -rw-r--r-- | tests/ui/excessive_precision.stderr | 8 |
3 files changed, 15 insertions, 1 deletions
diff --git a/tests/ui/excessive_precision.fixed b/tests/ui/excessive_precision.fixed index cc553103530..372f64f7d99 100644 --- a/tests/ui/excessive_precision.fixed +++ b/tests/ui/excessive_precision.fixed @@ -78,4 +78,8 @@ fn main() { const NEG_INF1: f32 = -1.0e+33f32; const NEG_INF2: f64 = -1.0e+3300f64; const NEG_INF3: f32 = -3.40282357e+38_f32; + + // issue #12954 + const _: f64 = 3.0; + const _: f64 = 3.0000000000000000; } diff --git a/tests/ui/excessive_precision.rs b/tests/ui/excessive_precision.rs index fff986a8296..1e40efbf245 100644 --- a/tests/ui/excessive_precision.rs +++ b/tests/ui/excessive_precision.rs @@ -78,4 +78,8 @@ fn main() { const NEG_INF1: f32 = -1.0e+33f32; const NEG_INF2: f64 = -1.0e+3300f64; const NEG_INF3: f32 = -3.40282357e+38_f32; + + // issue #12954 + const _: f64 = 3.0000000000000000e+00; + const _: f64 = 3.0000000000000000; } diff --git a/tests/ui/excessive_precision.stderr b/tests/ui/excessive_precision.stderr index 22dd96e53bd..6d8e166a649 100644 --- a/tests/ui/excessive_precision.stderr +++ b/tests/ui/excessive_precision.stderr @@ -91,5 +91,11 @@ error: float has excessive precision LL | let _ = 1.000_000_000_000_001e-324_f64; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0_f64` -error: aborting due to 15 previous errors +error: float has excessive precision + --> tests/ui/excessive_precision.rs:83:20 + | +LL | const _: f64 = 3.0000000000000000e+00; + | ^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `3.0` + +error: aborting due to 16 previous errors |
