add suggestions to clone_on_copy
also: * don't report clone_on_copy when reporting clone_on_double_ref * don't suggest `((x))`
This commit is contained in:
parent
ac5abcf593
commit
7e67f447ce
3 changed files with 34 additions and 14 deletions
|
|
@ -161,7 +161,13 @@ impl<'a> Sugg<'a> {
|
|||
pub fn maybe_par(self) -> Self {
|
||||
match self {
|
||||
Sugg::NonParen(..) => self,
|
||||
Sugg::MaybeParen(sugg) | Sugg::BinOp(_, sugg) => Sugg::NonParen(format!("({})", sugg).into()),
|
||||
// (x) and (x).y() both don't need additional parens
|
||||
Sugg::MaybeParen(sugg) => if sugg.starts_with('(') && sugg.ends_with(')') {
|
||||
Sugg::MaybeParen(sugg)
|
||||
} else {
|
||||
Sugg::NonParen(format!("({})", sugg).into())
|
||||
},
|
||||
Sugg::BinOp(_, sugg) => Sugg::NonParen(format!("({})", sugg).into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue