Skip to content

Commit 07b6927

Browse files
committed
Change floating_point_arthmetic::detect_hypot() to enclose the expression in parentheses.
1 parent 45a3b51 commit 07b6927

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

clippy_lints/src/floating_point_arithmetic.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ fn detect_hypot(cx: &LateContext<'_>, args: &[Expr<'_>]) -> Option<String> {
356356
if eq_expr_value(cx, lmul_lhs, lmul_rhs);
357357
if eq_expr_value(cx, rmul_lhs, rmul_rhs);
358358
then {
359-
return Some(format!("{}.hypot({})", Sugg::hir(cx, lmul_lhs, ".."), Sugg::hir(cx, rmul_lhs, "..")));
359+
return Some(format!("{}.hypot({})", Sugg::hir(cx, lmul_lhs, "..").maybe_par(), Sugg::hir(cx, rmul_lhs, "..")));
360360
}
361361
}
362362

@@ -379,7 +379,7 @@ fn detect_hypot(cx: &LateContext<'_>, args: &[Expr<'_>]) -> Option<String> {
379379
if let Some((rvalue, _)) = constant(cx, cx.typeck_results(), rargs_1);
380380
if Int(2) == lvalue && Int(2) == rvalue;
381381
then {
382-
return Some(format!("{}.hypot({})", Sugg::hir(cx, largs_0, ".."), Sugg::hir(cx, rargs_0, "..")));
382+
return Some(format!("{}.hypot({})", Sugg::hir(cx, largs_0, "..").maybe_par(), Sugg::hir(cx, rargs_0, "..")));
383383
}
384384
}
385385
}

0 commit comments

Comments
 (0)