1+ use clippy_config:: msrvs:: Msrv ;
2+ use clippy_config:: { Conf , msrvs} ;
13use clippy_utils:: consts:: { ConstEvalCtxt , Constant } ;
24use clippy_utils:: diagnostics:: span_lint_and_then;
35use clippy_utils:: source:: SpanRangeExt ;
@@ -6,7 +8,7 @@ use rustc_errors::Applicability;
68use rustc_hir:: { BinOpKind , Constness , Expr , ExprKind } ;
79use rustc_lint:: { LateContext , LateLintPass , Lint , LintContext } ;
810use rustc_middle:: lint:: in_external_macro;
9- use rustc_session:: declare_lint_pass ;
11+ use rustc_session:: impl_lint_pass ;
1012
1113declare_clippy_lint ! {
1214 /// ### What it does
@@ -56,7 +58,7 @@ declare_clippy_lint! {
5658 style,
5759 "use dedicated method to check if a float is finite"
5860}
59- declare_lint_pass ! ( ManualFloatMethods => [ MANUAL_IS_INFINITE , MANUAL_IS_FINITE ] ) ;
61+ impl_lint_pass ! ( ManualFloatMethods => [ MANUAL_IS_INFINITE , MANUAL_IS_FINITE ] ) ;
6062
6163#[ derive( Clone , Copy ) ]
6264enum Variant {
@@ -80,6 +82,18 @@ impl Variant {
8082 }
8183}
8284
85+ pub struct ManualFloatMethods {
86+ msrv : Msrv ,
87+ }
88+
89+ impl ManualFloatMethods {
90+ pub fn new ( conf : & ' static Conf ) -> Self {
91+ Self {
92+ msrv : conf. msrv . clone ( ) ,
93+ }
94+ }
95+ }
96+
8397impl < ' tcx > LateLintPass < ' tcx > for ManualFloatMethods {
8498 fn check_expr ( & mut self , cx : & LateContext < ' tcx > , expr : & ' tcx Expr < ' tcx > ) {
8599 if let ExprKind :: Binary ( kind, lhs, rhs) = expr. kind
@@ -92,7 +106,7 @@ impl<'tcx> LateLintPass<'tcx> for ManualFloatMethods {
92106 && !in_external_macro ( cx. sess ( ) , expr. span )
93107 && (
94108 matches ! ( cx. tcx. constness( cx. tcx. hir( ) . enclosing_body_owner( expr. hir_id) ) , Constness :: NotConst )
95- || cx . tcx . features ( ) . declared ( sym ! ( const_float_classify ) )
109+ || self . msrv . meets ( msrvs :: CONST_FLOAT_CLASSIFY )
96110 )
97111 && let [ first, second, const_1, const_2] = exprs
98112 && let ecx = ConstEvalCtxt :: new ( cx)
@@ -150,6 +164,8 @@ impl<'tcx> LateLintPass<'tcx> for ManualFloatMethods {
150164 } ) ;
151165 }
152166 }
167+
168+ extract_msrv_attr ! ( LateContext ) ;
153169}
154170
155171fn is_infinity ( constant : & Constant < ' _ > ) -> bool {
0 commit comments