1
+ use clippy_config:: msrvs:: Msrv ;
2
+ use clippy_config:: { Conf , msrvs} ;
1
3
use clippy_utils:: consts:: { ConstEvalCtxt , Constant } ;
2
4
use clippy_utils:: diagnostics:: span_lint_and_then;
3
5
use clippy_utils:: source:: SpanRangeExt ;
@@ -6,7 +8,7 @@ use rustc_errors::Applicability;
6
8
use rustc_hir:: { BinOpKind , Constness , Expr , ExprKind } ;
7
9
use rustc_lint:: { LateContext , LateLintPass , Lint , LintContext } ;
8
10
use rustc_middle:: lint:: in_external_macro;
9
- use rustc_session:: declare_lint_pass ;
11
+ use rustc_session:: impl_lint_pass ;
10
12
11
13
declare_clippy_lint ! {
12
14
/// ### What it does
@@ -56,7 +58,7 @@ declare_clippy_lint! {
56
58
style,
57
59
"use dedicated method to check if a float is finite"
58
60
}
59
- declare_lint_pass ! ( ManualFloatMethods => [ MANUAL_IS_INFINITE , MANUAL_IS_FINITE ] ) ;
61
+ impl_lint_pass ! ( ManualFloatMethods => [ MANUAL_IS_INFINITE , MANUAL_IS_FINITE ] ) ;
60
62
61
63
#[ derive( Clone , Copy ) ]
62
64
enum Variant {
@@ -80,6 +82,18 @@ impl Variant {
80
82
}
81
83
}
82
84
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
+
83
97
impl < ' tcx > LateLintPass < ' tcx > for ManualFloatMethods {
84
98
fn check_expr ( & mut self , cx : & LateContext < ' tcx > , expr : & ' tcx Expr < ' tcx > ) {
85
99
if let ExprKind :: Binary ( kind, lhs, rhs) = expr. kind
@@ -92,7 +106,7 @@ impl<'tcx> LateLintPass<'tcx> for ManualFloatMethods {
92
106
&& !in_external_macro ( cx. sess ( ) , expr. span )
93
107
&& (
94
108
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 )
96
110
)
97
111
&& let [ first, second, const_1, const_2] = exprs
98
112
&& let ecx = ConstEvalCtxt :: new ( cx)
@@ -150,6 +164,8 @@ impl<'tcx> LateLintPass<'tcx> for ManualFloatMethods {
150
164
} ) ;
151
165
}
152
166
}
167
+
168
+ extract_msrv_attr ! ( LateContext ) ;
153
169
}
154
170
155
171
fn is_infinity ( constant : & Constant < ' _ > ) -> bool {
0 commit comments