]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/float_equality_without_abs.rs
ast/hir: Rename field-related structures
[rust.git] / clippy_lints / src / float_equality_without_abs.rs
index 9ac5a45eb4590c6b65c9e8f29ee74647ebc2a896..c1c08597ee67004700cc2aef27b2e0c8e4ba39f7 100644 (file)
@@ -1,7 +1,8 @@
-use crate::utils::{match_qpath, paths, span_lint_and_then, sugg};
+use crate::utils::{match_def_path, paths, span_lint_and_then, sugg};
 use if_chain::if_chain;
 use rustc_ast::util::parser::AssocOp;
 use rustc_errors::Applicability;
+use rustc_hir::def::{DefKind, Res};
 use rustc_hir::{BinOpKind, Expr, ExprKind};
 use rustc_lint::{LateContext, LateLintPass};
 use rustc_middle::ty;
@@ -76,13 +77,14 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
 
             // right hand side matches either f32::EPSILON or f64::EPSILON
             if let ExprKind::Path(ref epsilon_path) = rhs.kind;
-            if match_qpath(epsilon_path, &paths::F32_EPSILON) || match_qpath(epsilon_path, &paths::F64_EPSILON);
+            if let Res::Def(DefKind::AssocConst, def_id) = cx.qpath_res(epsilon_path, rhs.hir_id);
+            if match_def_path(cx, def_id, &paths::F32_EPSILON) || match_def_path(cx, def_id, &paths::F64_EPSILON);
 
             // values of the substractions on the left hand side are of the type float
             let t_val_l = cx.typeck_results().expr_ty(val_l);
             let t_val_r = cx.typeck_results().expr_ty(val_r);
-            if let ty::Float(_) = t_val_l.kind;
-            if let ty::Float(_) = t_val_r.kind;
+            if let ty::Float(_) = t_val_l.kind();
+            if let ty::Float(_) = t_val_r.kind();
 
             then {
                 let sug_l = sugg::Sugg::hir(cx, &val_l, "..");