Skip to content

Commit 179df0b

Browse files
committed
Added F32::EPSILON and F64::EPSILON to paths.rs
1 parent 680c681 commit 179df0b

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

clippy_lints/src/float_equality_without_abs.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::utils::{match_qpath, snippet, span_lint_and_sugg};
1+
use crate::utils::{match_qpath, paths, snippet, span_lint_and_sugg};
22
use if_chain::if_chain;
33
use rustc_errors::Applicability;
44
use rustc_hir::{BinOpKind, Expr, ExprKind};
@@ -75,7 +75,7 @@ impl<'tcx> LateLintPass<'tcx> for FloatEqualityWithoutAbs {
7575

7676
// right hand side matches either f32::EPSILON or f64::EPSILON
7777
if let ExprKind::Path(ref epsilon_path) = rhs.kind;
78-
if match_qpath(epsilon_path, &["f32", "EPSILON"]) || match_qpath(epsilon_path, &["f64", "EPSILON"]);
78+
if match_qpath(epsilon_path, &paths::F32_EPSILON) || match_qpath(epsilon_path, &paths::F64_EPSILON);
7979

8080
// values of the substractions on the left hand side are of the type float
8181
let t_val_l = cx.typeck_results().expr_ty(val_l);

clippy_lints/src/utils/paths.rs

+2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ pub const DROP_TRAIT: [&str; 4] = ["core", "ops", "drop", "Drop"];
3535
pub const DURATION: [&str; 3] = ["core", "time", "Duration"];
3636
pub const EARLY_CONTEXT: [&str; 4] = ["rustc", "lint", "context", "EarlyContext"];
3737
pub const EXIT: [&str; 3] = ["std", "process", "exit"];
38+
pub const F32_EPSILON: [&str; 2] = ["f32", "EPSILON"];
39+
pub const F64_EPSILON: [&str; 2] = ["f64", "EPSILON"];
3840
pub const FILE: [&str; 3] = ["std", "fs", "File"];
3941
pub const FILE_TYPE: [&str; 3] = ["std", "fs", "FileType"];
4042
pub const FMT_ARGUMENTS_NEW_V1: [&str; 4] = ["core", "fmt", "Arguments", "new_v1"];

0 commit comments

Comments
 (0)