mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-24 05:33:27 +00:00
Auto merge of #7774 - dswij:useless-exponent, r=llogiq
Useless exponent Closes #7745 I'm open to some thoughts on dropping the exponents on suggestions when it's zero. I personally don't see any problem on this. changelog: [`useless_exponent`] suggestion drops exponent when exponent value is zero
This commit is contained in:
commit
c6b915825f
4 changed files with 17 additions and 3 deletions
|
@ -157,8 +157,10 @@ impl<'a> NumericLiteral<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some((separator, exponent)) = self.exponent {
|
if let Some((separator, exponent)) = self.exponent {
|
||||||
output.push_str(separator);
|
if exponent != "0" {
|
||||||
Self::group_digits(&mut output, exponent, group_size, true, false);
|
output.push_str(separator);
|
||||||
|
Self::group_digits(&mut output, exponent, group_size, true, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(suffix) = self.suffix {
|
if let Some(suffix) = self.suffix {
|
||||||
|
|
|
@ -63,4 +63,7 @@ fn main() {
|
||||||
|
|
||||||
// issue #7744
|
// issue #7744
|
||||||
let _ = 2.225_073_858_507_201e-308_f64;
|
let _ = 2.225_073_858_507_201e-308_f64;
|
||||||
|
|
||||||
|
// issue #7745
|
||||||
|
let _ = 0_f64;
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,4 +63,7 @@ fn main() {
|
||||||
|
|
||||||
// issue #7744
|
// issue #7744
|
||||||
let _ = 2.225_073_858_507_201_1e-308_f64;
|
let _ = 2.225_073_858_507_201_1e-308_f64;
|
||||||
|
|
||||||
|
// issue #7745
|
||||||
|
let _ = 1.000_000_000_000_001e-324_f64;
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,5 +84,11 @@ error: float has excessive precision
|
||||||
LL | let _ = 2.225_073_858_507_201_1e-308_f64;
|
LL | let _ = 2.225_073_858_507_201_1e-308_f64;
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `2.225_073_858_507_201e-308_f64`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `2.225_073_858_507_201e-308_f64`
|
||||||
|
|
||||||
error: aborting due to 14 previous errors
|
error: float has excessive precision
|
||||||
|
--> $DIR/excessive_precision.rs:68:13
|
||||||
|
|
|
||||||
|
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
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue