@@ -154,7 +154,7 @@ fn prepare_receiver_sugg<'a>(cx: &LateContext<'_>, mut expr: &'a Expr<'a>) -> Su
154
154
} ;
155
155
}
156
156
157
- suggestion. maybe_par ( )
157
+ suggestion. maybe_paren ( )
158
158
}
159
159
160
160
fn check_log_base ( cx : & LateContext < ' _ > , expr : & Expr < ' _ > , receiver : & Expr < ' _ > , args : & [ Expr < ' _ > ] ) {
@@ -165,7 +165,7 @@ fn check_log_base(cx: &LateContext<'_>, expr: &Expr<'_>, receiver: &Expr<'_>, ar
165
165
expr. span ,
166
166
"logarithm for bases 2, 10 and e can be computed more accurately" ,
167
167
"consider using" ,
168
- format ! ( "{}.{method}()" , Sugg :: hir( cx, receiver, ".." ) . maybe_par ( ) ) ,
168
+ format ! ( "{}.{method}()" , Sugg :: hir( cx, receiver, ".." ) . maybe_paren ( ) ) ,
169
169
Applicability :: MachineApplicable ,
170
170
) ;
171
171
}
@@ -254,21 +254,21 @@ fn check_powf(cx: &LateContext<'_>, expr: &Expr<'_>, receiver: &Expr<'_>, args:
254
254
(
255
255
SUBOPTIMAL_FLOPS ,
256
256
"square-root of a number can be computed more efficiently and accurately" ,
257
- format ! ( "{}.sqrt()" , Sugg :: hir( cx, receiver, ".." ) . maybe_par ( ) ) ,
257
+ format ! ( "{}.sqrt()" , Sugg :: hir( cx, receiver, ".." ) . maybe_paren ( ) ) ,
258
258
)
259
259
} else if F32 ( 1.0 / 3.0 ) == value || F64 ( 1.0 / 3.0 ) == value {
260
260
(
261
261
IMPRECISE_FLOPS ,
262
262
"cube-root of a number can be computed more accurately" ,
263
- format ! ( "{}.cbrt()" , Sugg :: hir( cx, receiver, ".." ) . maybe_par ( ) ) ,
263
+ format ! ( "{}.cbrt()" , Sugg :: hir( cx, receiver, ".." ) . maybe_paren ( ) ) ,
264
264
)
265
265
} else if let Some ( exponent) = get_integer_from_float_constant ( & value) {
266
266
(
267
267
SUBOPTIMAL_FLOPS ,
268
268
"exponentiation with integer powers can be computed more efficiently" ,
269
269
format ! (
270
270
"{}.powi({})" ,
271
- Sugg :: hir( cx, receiver, ".." ) . maybe_par ( ) ,
271
+ Sugg :: hir( cx, receiver, ".." ) . maybe_paren ( ) ,
272
272
numeric_literal:: format( & exponent. to_string( ) , None , false )
273
273
) ,
274
274
)
@@ -330,7 +330,7 @@ fn check_powi(cx: &LateContext<'_>, expr: &Expr<'_>, receiver: &Expr<'_>, args:
330
330
"consider using" ,
331
331
format ! (
332
332
"{}.mul_add({}, {})" ,
333
- Sugg :: hir( cx, receiver, ".." ) . maybe_par ( ) ,
333
+ Sugg :: hir( cx, receiver, ".." ) . maybe_paren ( ) ,
334
334
maybe_neg_sugg( receiver, expr. hir_id) ,
335
335
maybe_neg_sugg( other_addend, other_addend. hir_id) ,
336
336
) ,
@@ -371,7 +371,7 @@ fn detect_hypot(cx: &LateContext<'_>, receiver: &Expr<'_>) -> Option<String> {
371
371
{
372
372
return Some ( format ! (
373
373
"{}.hypot({})" ,
374
- Sugg :: hir( cx, lmul_lhs, ".." ) . maybe_par ( ) ,
374
+ Sugg :: hir( cx, lmul_lhs, ".." ) . maybe_paren ( ) ,
375
375
Sugg :: hir( cx, rmul_lhs, ".." )
376
376
) ) ;
377
377
}
@@ -403,7 +403,7 @@ fn detect_hypot(cx: &LateContext<'_>, receiver: &Expr<'_>) -> Option<String> {
403
403
{
404
404
return Some ( format ! (
405
405
"{}.hypot({})" ,
406
- Sugg :: hir( cx, largs_0, ".." ) . maybe_par ( ) ,
406
+ Sugg :: hir( cx, largs_0, ".." ) . maybe_paren ( ) ,
407
407
Sugg :: hir( cx, rargs_0, ".." )
408
408
) ) ;
409
409
}
@@ -449,7 +449,7 @@ fn check_expm1(cx: &LateContext<'_>, expr: &Expr<'_>) {
449
449
expr. span ,
450
450
"(e.pow(x) - 1) can be computed more accurately" ,
451
451
"consider using" ,
452
- format ! ( "{}.exp_m1()" , Sugg :: hir( cx, self_arg, ".." ) . maybe_par ( ) ) ,
452
+ format ! ( "{}.exp_m1()" , Sugg :: hir( cx, self_arg, ".." ) . maybe_paren ( ) ) ,
453
453
Applicability :: MachineApplicable ,
454
454
) ;
455
455
}
@@ -591,11 +591,11 @@ fn check_custom_abs(cx: &LateContext<'_>, expr: &Expr<'_>) {
591
591
{
592
592
let positive_abs_sugg = (
593
593
"manual implementation of `abs` method" ,
594
- format ! ( "{}.abs()" , Sugg :: hir( cx, body, ".." ) . maybe_par ( ) ) ,
594
+ format ! ( "{}.abs()" , Sugg :: hir( cx, body, ".." ) . maybe_paren ( ) ) ,
595
595
) ;
596
596
let negative_abs_sugg = (
597
597
"manual implementation of negation of `abs` method" ,
598
- format ! ( "-{}.abs()" , Sugg :: hir( cx, body, ".." ) . maybe_par ( ) ) ,
598
+ format ! ( "-{}.abs()" , Sugg :: hir( cx, body, ".." ) . maybe_paren ( ) ) ,
599
599
) ;
600
600
let sugg = if is_testing_positive ( cx, cond, body) {
601
601
if if_expr_positive {
@@ -672,7 +672,7 @@ fn check_log_division(cx: &LateContext<'_>, expr: &Expr<'_>) {
672
672
"consider using" ,
673
673
format ! (
674
674
"{}.log({})" ,
675
- Sugg :: hir( cx, largs_self, ".." ) . maybe_par ( ) ,
675
+ Sugg :: hir( cx, largs_self, ".." ) . maybe_paren ( ) ,
676
676
Sugg :: hir( cx, rargs_self, ".." ) ,
677
677
) ,
678
678
Applicability :: MachineApplicable ,
@@ -703,7 +703,7 @@ fn check_radians(cx: &LateContext<'_>, expr: &Expr<'_>) {
703
703
if ( F32 ( f32_consts:: PI ) == rvalue || F64 ( f64_consts:: PI ) == rvalue)
704
704
&& ( F32 ( 180_f32 ) == lvalue || F64 ( 180_f64 ) == lvalue)
705
705
{
706
- let mut proposal = format ! ( "{}.to_degrees()" , Sugg :: hir( cx, mul_lhs, ".." ) . maybe_par ( ) ) ;
706
+ let mut proposal = format ! ( "{}.to_degrees()" , Sugg :: hir( cx, mul_lhs, ".." ) . maybe_paren ( ) ) ;
707
707
if let ExprKind :: Lit ( literal) = mul_lhs. kind
708
708
&& let ast:: LitKind :: Float ( ref value, float_type) = literal. node
709
709
&& float_type == ast:: LitFloatType :: Unsuffixed
@@ -726,7 +726,7 @@ fn check_radians(cx: &LateContext<'_>, expr: &Expr<'_>) {
726
726
} else if ( F32 ( 180_f32 ) == rvalue || F64 ( 180_f64 ) == rvalue)
727
727
&& ( F32 ( f32_consts:: PI ) == lvalue || F64 ( f64_consts:: PI ) == lvalue)
728
728
{
729
- let mut proposal = format ! ( "{}.to_radians()" , Sugg :: hir( cx, mul_lhs, ".." ) . maybe_par ( ) ) ;
729
+ let mut proposal = format ! ( "{}.to_radians()" , Sugg :: hir( cx, mul_lhs, ".." ) . maybe_paren ( ) ) ;
730
730
if let ExprKind :: Lit ( literal) = mul_lhs. kind
731
731
&& let ast:: LitKind :: Float ( ref value, float_type) = literal. node
732
732
&& float_type == ast:: LitFloatType :: Unsuffixed
0 commit comments