@@ -24,6 +24,8 @@ mod verbose_bit_mask;
24
24
pub ( crate ) mod arithmetic_side_effects;
25
25
26
26
use clippy_config:: Conf ;
27
+ use clippy_utils:: def_path_def_ids;
28
+ use rustc_hir:: def_id:: DefIdSet ;
27
29
use rustc_hir:: { Body , Expr , ExprKind , UnOp } ;
28
30
use rustc_lint:: { LateContext , LateLintPass } ;
29
31
use rustc_session:: impl_lint_pass;
@@ -774,9 +776,8 @@ declare_clippy_lint! {
774
776
"explicit self-assignment"
775
777
}
776
778
777
- #[ derive( Clone , Copy ) ]
778
779
struct FloatCmpConfig {
779
- ignore_named_constants : bool ,
780
+ allowed_constants : DefIdSet ,
780
781
ignore_constant_comparisons : bool ,
781
782
ignore_change_detection : bool ,
782
783
}
@@ -794,7 +795,11 @@ impl Operators {
794
795
verbose_bit_mask_threshold : conf. verbose_bit_mask_threshold ,
795
796
modulo_arithmetic_allow_comparison_to_zero : conf. allow_comparison_to_zero ,
796
797
float_cmp_config : FloatCmpConfig {
797
- ignore_named_constants : conf. float_cmp_ignore_named_constants ,
798
+ allowed_constants : conf
799
+ . float_cmp_allowed_constants
800
+ . iter ( )
801
+ . flat_map ( |x| def_path_def_ids ( tcx, & x. split ( "::" ) . collect :: < Vec < _ > > ( ) ) )
802
+ . collect ( ) ,
798
803
ignore_constant_comparisons : conf. float_cmp_ignore_constant_comparisons ,
799
804
ignore_change_detection : conf. float_cmp_ignore_change_detection ,
800
805
} ,
0 commit comments