@@ -154,7 +154,7 @@ fn prepare_receiver_sugg<'a>(cx: &LateContext<'_>, mut expr: &'a Expr<'a>) -> Su
154154 } ;
155155 }
156156
157- suggestion. maybe_par ( )
157+ suggestion. maybe_paren ( )
158158}
159159
160160fn 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
165165 expr. span ,
166166 "logarithm for bases 2, 10 and e can be computed more accurately" ,
167167 "consider using" ,
168- format ! ( "{}.{method}()" , Sugg :: hir( cx, receiver, ".." ) . maybe_par ( ) ) ,
168+ format ! ( "{}.{method}()" , Sugg :: hir( cx, receiver, ".." ) . maybe_paren ( ) ) ,
169169 Applicability :: MachineApplicable ,
170170 ) ;
171171 }
@@ -254,21 +254,21 @@ fn check_powf(cx: &LateContext<'_>, expr: &Expr<'_>, receiver: &Expr<'_>, args:
254254 (
255255 SUBOPTIMAL_FLOPS ,
256256 "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 ( ) ) ,
258258 )
259259 } else if F32 ( 1.0 / 3.0 ) == value || F64 ( 1.0 / 3.0 ) == value {
260260 (
261261 IMPRECISE_FLOPS ,
262262 "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 ( ) ) ,
264264 )
265265 } else if let Some ( exponent) = get_integer_from_float_constant ( & value) {
266266 (
267267 SUBOPTIMAL_FLOPS ,
268268 "exponentiation with integer powers can be computed more efficiently" ,
269269 format ! (
270270 "{}.powi({})" ,
271- Sugg :: hir( cx, receiver, ".." ) . maybe_par ( ) ,
271+ Sugg :: hir( cx, receiver, ".." ) . maybe_paren ( ) ,
272272 numeric_literal:: format( & exponent. to_string( ) , None , false )
273273 ) ,
274274 )
@@ -330,7 +330,7 @@ fn check_powi(cx: &LateContext<'_>, expr: &Expr<'_>, receiver: &Expr<'_>, args:
330330 "consider using" ,
331331 format ! (
332332 "{}.mul_add({}, {})" ,
333- Sugg :: hir( cx, receiver, ".." ) . maybe_par ( ) ,
333+ Sugg :: hir( cx, receiver, ".." ) . maybe_paren ( ) ,
334334 maybe_neg_sugg( receiver, expr. hir_id) ,
335335 maybe_neg_sugg( other_addend, other_addend. hir_id) ,
336336 ) ,
@@ -371,7 +371,7 @@ fn detect_hypot(cx: &LateContext<'_>, receiver: &Expr<'_>) -> Option<String> {
371371 {
372372 return Some ( format ! (
373373 "{}.hypot({})" ,
374- Sugg :: hir( cx, lmul_lhs, ".." ) . maybe_par ( ) ,
374+ Sugg :: hir( cx, lmul_lhs, ".." ) . maybe_paren ( ) ,
375375 Sugg :: hir( cx, rmul_lhs, ".." )
376376 ) ) ;
377377 }
@@ -403,7 +403,7 @@ fn detect_hypot(cx: &LateContext<'_>, receiver: &Expr<'_>) -> Option<String> {
403403 {
404404 return Some ( format ! (
405405 "{}.hypot({})" ,
406- Sugg :: hir( cx, largs_0, ".." ) . maybe_par ( ) ,
406+ Sugg :: hir( cx, largs_0, ".." ) . maybe_paren ( ) ,
407407 Sugg :: hir( cx, rargs_0, ".." )
408408 ) ) ;
409409 }
@@ -449,7 +449,7 @@ fn check_expm1(cx: &LateContext<'_>, expr: &Expr<'_>) {
449449 expr. span ,
450450 "(e.pow(x) - 1) can be computed more accurately" ,
451451 "consider using" ,
452- format ! ( "{}.exp_m1()" , Sugg :: hir( cx, self_arg, ".." ) . maybe_par ( ) ) ,
452+ format ! ( "{}.exp_m1()" , Sugg :: hir( cx, self_arg, ".." ) . maybe_paren ( ) ) ,
453453 Applicability :: MachineApplicable ,
454454 ) ;
455455 }
@@ -591,11 +591,11 @@ fn check_custom_abs(cx: &LateContext<'_>, expr: &Expr<'_>) {
591591 {
592592 let positive_abs_sugg = (
593593 "manual implementation of `abs` method" ,
594- format ! ( "{}.abs()" , Sugg :: hir( cx, body, ".." ) . maybe_par ( ) ) ,
594+ format ! ( "{}.abs()" , Sugg :: hir( cx, body, ".." ) . maybe_paren ( ) ) ,
595595 ) ;
596596 let negative_abs_sugg = (
597597 "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 ( ) ) ,
599599 ) ;
600600 let sugg = if is_testing_positive ( cx, cond, body) {
601601 if if_expr_positive {
@@ -672,7 +672,7 @@ fn check_log_division(cx: &LateContext<'_>, expr: &Expr<'_>) {
672672 "consider using" ,
673673 format ! (
674674 "{}.log({})" ,
675- Sugg :: hir( cx, largs_self, ".." ) . maybe_par ( ) ,
675+ Sugg :: hir( cx, largs_self, ".." ) . maybe_paren ( ) ,
676676 Sugg :: hir( cx, rargs_self, ".." ) ,
677677 ) ,
678678 Applicability :: MachineApplicable ,
@@ -703,7 +703,7 @@ fn check_radians(cx: &LateContext<'_>, expr: &Expr<'_>) {
703703 if ( F32 ( f32_consts:: PI ) == rvalue || F64 ( f64_consts:: PI ) == rvalue)
704704 && ( F32 ( 180_f32 ) == lvalue || F64 ( 180_f64 ) == lvalue)
705705 {
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 ( ) ) ;
707707 if let ExprKind :: Lit ( literal) = mul_lhs. kind
708708 && let ast:: LitKind :: Float ( ref value, float_type) = literal. node
709709 && float_type == ast:: LitFloatType :: Unsuffixed
@@ -726,7 +726,7 @@ fn check_radians(cx: &LateContext<'_>, expr: &Expr<'_>) {
726726 } else if ( F32 ( 180_f32 ) == rvalue || F64 ( 180_f64 ) == rvalue)
727727 && ( F32 ( f32_consts:: PI ) == lvalue || F64 ( f64_consts:: PI ) == lvalue)
728728 {
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 ( ) ) ;
730730 if let ExprKind :: Lit ( literal) = mul_lhs. kind
731731 && let ast:: LitKind :: Float ( ref value, float_type) = literal. node
732732 && float_type == ast:: LitFloatType :: Unsuffixed
0 commit comments