let (cast_from, cast_to) = (cx.typeck_results().expr_ty(ex), cx.typeck_results().expr_ty(expr));
lint_fn_to_numeric_cast(cx, expr, ex, cast_from, cast_to);
if let Some(lit) = get_numeric_literal(ex) {
- let literal_str = snippet_opt(cx, lit.span).unwrap_or_default();
+ let literal_str = snippet_opt(cx, ex.span).unwrap_or_default();
if_chain! {
if let LitKind::Int(n, _) = lit.node;
LL | 0.5 as f32;
| ^^^^^^^^^^ help: try: `0.5_f32`
-error: aborting due to 10 previous errors
+error: casting integer literal to `i32` is unnecessary
+ --> $DIR/unnecessary_cast_fixable.rs:33:5
+ |
+LL | -1 as i32;
+ | ^^^^^^^^^ help: try: `-1_i32`
+
+error: casting float literal to `f32` is unnecessary
+ --> $DIR/unnecessary_cast_fixable.rs:34:5
+ |
+LL | -1.0 as f32;
+ | ^^^^^^^^^^^ help: try: `-1.0_f32`
+
+error: aborting due to 12 previous errors