Fix missing parenthesis in suboptimal floating point help

This commit is contained in:
Andre Bogus 2023-10-27 16:28:10 +02:00
parent 2f0f4ddcf7
commit 1ed1001440
5 changed files with 22 additions and 19 deletions

View file

@ -465,7 +465,10 @@ forward_binop_impls_to_ref!(impl Sub, sub for Sugg<'_>, type Output = Sugg<'stat
impl Neg for Sugg<'_> {
type Output = Sugg<'static>;
fn neg(self) -> Sugg<'static> {
make_unop("-", self)
match &self {
Self::BinOp(AssocOp::As, ..) => Sugg::MaybeParen(format!("-({self})").into()),
_ => make_unop("-", self),
}
}
}