Keep original literal notation in suggestion
This commit is contained in:
parent
dfe37f13cf
commit
921f4d317e
@ -36,7 +36,7 @@ fn is_useless_rounding(expr: &Expr) -> Option<(&str, String)> {
|
||||
&& let ExprKind::Lit(spanned) = &receiver.kind
|
||||
&& let LitKind::Float(symbol, ty) = spanned.kind {
|
||||
let f = symbol.as_str().parse::<f64>().unwrap();
|
||||
let f_str = symbol.to_string() + if let LitFloatType::Suffixed(ty) = ty {
|
||||
let f_str = spanned.token_lit.symbol.to_string() + if let LitFloatType::Suffixed(ty) = ty {
|
||||
ty.name_str()
|
||||
} else {
|
||||
""
|
||||
|
@ -6,4 +6,9 @@ fn main() {
|
||||
let _ = 1.0f64;
|
||||
let _ = 1.00f32;
|
||||
let _ = 2e-54f64.floor();
|
||||
|
||||
// issue9866
|
||||
let _ = 3.3_f32.round();
|
||||
let _ = 3.3_f64.round();
|
||||
let _ = 3.0_f32;
|
||||
}
|
||||
|
@ -6,4 +6,9 @@ fn main() {
|
||||
let _ = 1.0f64.floor();
|
||||
let _ = 1.00f32.round();
|
||||
let _ = 2e-54f64.floor();
|
||||
|
||||
// issue9866
|
||||
let _ = 3.3_f32.round();
|
||||
let _ = 3.3_f64.round();
|
||||
let _ = 3.0_f32.round();
|
||||
}
|
||||
|
@ -18,5 +18,11 @@ error: used the `round` method with a whole number float
|
||||
LL | let _ = 1.00f32.round();
|
||||
| ^^^^^^^^^^^^^^^ help: remove the `round` method call: `1.00f32`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error: used the `round` method with a whole number float
|
||||
--> $DIR/unused_rounding.rs:13:13
|
||||
|
|
||||
LL | let _ = 3.0_f32.round();
|
||||
| ^^^^^^^^^^^^^^^ help: remove the `round` method call: `3.0_f32`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user