Skip to content

Commit 4ae85e0

Browse files
committed
use #[derive] instead of the manual implementation
1 parent c2696b7 commit 4ae85e0

File tree

1 file changed

+1
-40
lines changed

1 file changed

+1
-40
lines changed

clippy_lints/src/utils/sugg.rs

+1-40
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use std::fmt::Display;
1616
use std::ops::{Add, Neg, Not, Sub};
1717

1818
/// A helper type to build suggestion correctly handling parenthesis.
19+
#[derive(Clone)]
1920
pub enum Sugg<'a> {
2021
/// An expression that never needs parenthesis such as `1337` or `[0; 42]`.
2122
NonParen(Cow<'a, str>),
@@ -37,46 +38,6 @@ impl Display for Sugg<'_> {
3738
}
3839
}
3940

40-
// It's impossible to derive Clone due to the lack of the impl Clone for AssocOp
41-
impl Clone for Sugg<'_> {
42-
fn clone(&self) -> Self {
43-
/// manually cloning AssocOp
44-
fn clone_assoc_op(this: &AssocOp) -> AssocOp {
45-
match this {
46-
AssocOp::Add => AssocOp::Add,
47-
AssocOp::Subtract => AssocOp::Subtract,
48-
AssocOp::Multiply => AssocOp::Multiply,
49-
AssocOp::Divide => AssocOp::Divide,
50-
AssocOp::Modulus => AssocOp::Modulus,
51-
AssocOp::LAnd => AssocOp::LAnd,
52-
AssocOp::LOr => AssocOp::LOr,
53-
AssocOp::BitXor => AssocOp::BitXor,
54-
AssocOp::BitAnd => AssocOp::BitAnd,
55-
AssocOp::BitOr => AssocOp::BitOr,
56-
AssocOp::ShiftLeft => AssocOp::ShiftLeft,
57-
AssocOp::ShiftRight => AssocOp::ShiftRight,
58-
AssocOp::Equal => AssocOp::Equal,
59-
AssocOp::Less => AssocOp::Less,
60-
AssocOp::LessEqual => AssocOp::LessEqual,
61-
AssocOp::NotEqual => AssocOp::NotEqual,
62-
AssocOp::Greater => AssocOp::Greater,
63-
AssocOp::GreaterEqual => AssocOp::GreaterEqual,
64-
AssocOp::Assign => AssocOp::Assign,
65-
AssocOp::AssignOp(t) => AssocOp::AssignOp(*t),
66-
AssocOp::As => AssocOp::As,
67-
AssocOp::DotDot => AssocOp::DotDot,
68-
AssocOp::DotDotEq => AssocOp::DotDotEq,
69-
AssocOp::Colon => AssocOp::Colon,
70-
}
71-
}
72-
match self {
73-
Sugg::NonParen(x) => Sugg::NonParen(x.clone()),
74-
Sugg::MaybeParen(x) => Sugg::MaybeParen(x.clone()),
75-
Sugg::BinOp(op, x) => Sugg::BinOp(clone_assoc_op(op), x.clone()),
76-
}
77-
}
78-
}
79-
8041
#[allow(clippy::wrong_self_convention)] // ok, because of the function `as_ty` method
8142
impl<'a> Sugg<'a> {
8243
/// Prepare a suggestion from an expression.

0 commit comments

Comments
 (0)