@@ -114,7 +114,7 @@ declare_lint_pass!(FloatingPointArithmetic => [
114
114
// Returns the specialized log method for a given base if base is constant
115
115
// and is one of 2, 10 and e
116
116
fn get_specialized_log_method ( cx : & LateContext < ' _ > , base : & Expr < ' _ > ) -> Option < & ' static str > {
117
- if let Some ( ( value, _ ) ) = constant ( cx, cx. typeck_results ( ) , base) {
117
+ if let Some ( value) = constant ( cx, cx. typeck_results ( ) , base) {
118
118
if F32 ( 2.0 ) == value || F64 ( 2.0 ) == value {
119
119
return Some ( "log2" ) ;
120
120
} else if F32 ( 10.0 ) == value || F64 ( 10.0 ) == value {
@@ -193,8 +193,8 @@ fn check_ln1p(cx: &LateContext<'_>, expr: &Expr<'_>, receiver: &Expr<'_>) {
193
193
constant ( cx, cx. typeck_results ( ) , lhs) ,
194
194
constant ( cx, cx. typeck_results ( ) , rhs) ,
195
195
) {
196
- ( Some ( ( value, _ ) ) , _) if F32 ( 1.0 ) == value || F64 ( 1.0 ) == value => rhs,
197
- ( _, Some ( ( value, _ ) ) ) if F32 ( 1.0 ) == value || F64 ( 1.0 ) == value => lhs,
196
+ ( Some ( value) , _) if F32 ( 1.0 ) == value || F64 ( 1.0 ) == value => rhs,
197
+ ( _, Some ( value) ) if F32 ( 1.0 ) == value || F64 ( 1.0 ) == value => lhs,
198
198
_ => return ,
199
199
} ;
200
200
@@ -237,7 +237,7 @@ fn get_integer_from_float_constant(value: &Constant) -> Option<i32> {
237
237
238
238
fn check_powf ( cx : & LateContext < ' _ > , expr : & Expr < ' _ > , receiver : & Expr < ' _ > , args : & [ Expr < ' _ > ] ) {
239
239
// Check receiver
240
- if let Some ( ( value, _ ) ) = constant ( cx, cx. typeck_results ( ) , receiver) {
240
+ if let Some ( value) = constant ( cx, cx. typeck_results ( ) , receiver) {
241
241
if let Some ( method) = if F32 ( f32_consts:: E ) == value || F64 ( f64_consts:: E ) == value {
242
242
Some ( "exp" )
243
243
} else if F32 ( 2.0 ) == value || F64 ( 2.0 ) == value {
@@ -258,7 +258,7 @@ fn check_powf(cx: &LateContext<'_>, expr: &Expr<'_>, receiver: &Expr<'_>, args:
258
258
}
259
259
260
260
// Check argument
261
- if let Some ( ( value, _ ) ) = constant ( cx, cx. typeck_results ( ) , & args[ 0 ] ) {
261
+ if let Some ( value) = constant ( cx, cx. typeck_results ( ) , & args[ 0 ] ) {
262
262
let ( lint, help, suggestion) = if F32 ( 1.0 / 2.0 ) == value || F64 ( 1.0 / 2.0 ) == value {
263
263
(
264
264
SUBOPTIMAL_FLOPS ,
@@ -298,7 +298,7 @@ fn check_powf(cx: &LateContext<'_>, expr: &Expr<'_>, receiver: &Expr<'_>, args:
298
298
}
299
299
300
300
fn check_powi ( cx : & LateContext < ' _ > , expr : & Expr < ' _ > , receiver : & Expr < ' _ > , args : & [ Expr < ' _ > ] ) {
301
- if let Some ( ( value, _ ) ) = constant ( cx, cx. typeck_results ( ) , & args[ 0 ] ) {
301
+ if let Some ( value) = constant ( cx, cx. typeck_results ( ) , & args[ 0 ] ) {
302
302
if value == Int ( 2 ) {
303
303
if let Some ( parent) = get_parent_expr ( cx, expr) {
304
304
if let Some ( grandparent) = get_parent_expr ( cx, parent) {
@@ -384,8 +384,8 @@ fn detect_hypot(cx: &LateContext<'_>, receiver: &Expr<'_>) -> Option<String> {
384
384
_
385
385
) = & add_rhs. kind;
386
386
if lmethod_name. as_str( ) == "powi" && rmethod_name. as_str( ) == "powi" ;
387
- if let Some ( ( lvalue, _ ) ) = constant( cx, cx. typeck_results( ) , largs_1) ;
388
- if let Some ( ( rvalue, _ ) ) = constant( cx, cx. typeck_results( ) , rargs_1) ;
387
+ if let Some ( lvalue) = constant( cx, cx. typeck_results( ) , largs_1) ;
388
+ if let Some ( rvalue) = constant( cx, cx. typeck_results( ) , rargs_1) ;
389
389
if Int ( 2 ) == lvalue && Int ( 2 ) == rvalue;
390
390
then {
391
391
return Some ( format!( "{}.hypot({})" , Sugg :: hir( cx, largs_0, ".." ) . maybe_par( ) , Sugg :: hir( cx, rargs_0, ".." ) ) ) ;
@@ -416,7 +416,7 @@ fn check_expm1(cx: &LateContext<'_>, expr: &Expr<'_>) {
416
416
if_chain ! {
417
417
if let ExprKind :: Binary ( Spanned { node: BinOpKind :: Sub , .. } , lhs, rhs) = expr. kind;
418
418
if cx. typeck_results( ) . expr_ty( lhs) . is_floating_point( ) ;
419
- if let Some ( ( value, _ ) ) = constant( cx, cx. typeck_results( ) , rhs) ;
419
+ if let Some ( value) = constant( cx, cx. typeck_results( ) , rhs) ;
420
420
if F32 ( 1.0 ) == value || F64 ( 1.0 ) == value;
421
421
if let ExprKind :: MethodCall ( path, self_arg, ..) = & lhs. kind;
422
422
if cx. typeck_results( ) . expr_ty( self_arg) . is_floating_point( ) ;
@@ -669,8 +669,8 @@ fn check_radians(cx: &LateContext<'_>, expr: &Expr<'_>) {
669
669
mul_lhs,
670
670
mul_rhs,
671
671
) = & div_lhs. kind;
672
- if let Some ( ( rvalue, _ ) ) = constant( cx, cx. typeck_results( ) , div_rhs) ;
673
- if let Some ( ( lvalue, _ ) ) = constant( cx, cx. typeck_results( ) , mul_rhs) ;
672
+ if let Some ( rvalue) = constant( cx, cx. typeck_results( ) , div_rhs) ;
673
+ if let Some ( lvalue) = constant( cx, cx. typeck_results( ) , mul_rhs) ;
674
674
then {
675
675
// TODO: also check for constant values near PI/180 or 180/PI
676
676
if ( F32 ( f32_consts:: PI ) == rvalue || F64 ( f64_consts:: PI ) == rvalue) &&
0 commit comments