Skip to content

Commit 278e837

Browse files
committed
float_literal: Check HIR tree before checking types.
1 parent ca7e5c1 commit 278e837

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

clippy_lints/src/float_literal.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,9 @@ declare_lint_pass!(FloatLiteral => [EXCESSIVE_PRECISION, LOSSY_FLOAT_LITERAL]);
6262

6363
impl<'tcx> LateLintPass<'tcx> for FloatLiteral {
6464
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>) {
65-
let ty = cx.typeck_results().expr_ty(expr);
66-
if let ty::Float(fty) = *ty.kind()
67-
&& let hir::ExprKind::Lit(lit) = expr.kind
65+
if let hir::ExprKind::Lit(lit) = expr.kind
6866
&& let LitKind::Float(sym, lit_float_ty) = lit.node
67+
&& let ty::Float(fty) = *cx.typeck_results().expr_ty(expr).kind()
6968
{
7069
let sym_str = sym.as_str();
7170
let formatter = FloatFormat::new(sym_str);

0 commit comments

Comments
 (0)