Skip to content

Commit 6dabdef

Browse files
committed
Auto merge of rust-lang#13928 - danieleades:clone-on-copy, r=lnicola
internal: avoid 'cloning' types that implement 'Copy'
2 parents a97cbb1 + 95d14c3 commit 6dabdef

File tree

6 files changed

+7
-7
lines changed

6 files changed

+7
-7
lines changed

crates/hir-ty/src/lower.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1931,7 +1931,7 @@ pub(crate) fn const_or_path_to_chalk(
19311931
debruijn: DebruijnIndex,
19321932
) -> Const {
19331933
match value {
1934-
ConstScalarOrPath::Scalar(s) => intern_const_scalar(s.clone(), expected_ty),
1934+
ConstScalarOrPath::Scalar(s) => intern_const_scalar(*s, expected_ty),
19351935
ConstScalarOrPath::Path(n) => {
19361936
let path = ModPath::from_segments(PathKind::Plain, Some(n.clone()));
19371937
path_to_const(db, resolver, &path, mode, args, debruijn)

crates/hir/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,7 @@ impl Struct {
923923
}
924924

925925
pub fn repr(self, db: &dyn HirDatabase) -> Option<ReprOptions> {
926-
db.struct_data(self.id).repr.clone()
926+
db.struct_data(self.id).repr
927927
}
928928

929929
pub fn kind(self, db: &dyn HirDatabase) -> StructKind {

crates/mbe/src/benchmark.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ fn invocation_fixtures(rules: &FxHashMap<String, DeclarativeMacro>) -> Vec<(Stri
145145
Op::Ident(it) => parent.token_trees.push(tt::Leaf::from(it.clone()).into()),
146146
Op::Punct(puncts) => {
147147
for punct in puncts {
148-
parent.token_trees.push(tt::Leaf::from(punct.clone()).into());
148+
parent.token_trees.push(tt::Leaf::from(*punct).into());
149149
}
150150
}
151151
Op::Repeat { tokens, kind, separator } => {

crates/mbe/src/expander/transcriber.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ fn expand_subtree(
138138
Op::Ident(it) => arena.push(tt::Leaf::from(it.clone()).into()),
139139
Op::Punct(puncts) => {
140140
for punct in puncts {
141-
arena.push(tt::Leaf::from(punct.clone()).into());
141+
arena.push(tt::Leaf::from(*punct).into());
142142
}
143143
}
144144
Op::Subtree { tokens, delimiter } => {

crates/mbe/src/parser.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ fn next_op(
126126
src.next().expect("first token already peeked");
127127
// Note that the '$' itself is a valid token inside macro_rules.
128128
let second = match src.next() {
129-
None => return Ok(Op::Punct(smallvec![p.clone()])),
129+
None => return Ok(Op::Punct(smallvec![*p])),
130130
Some(it) => it,
131131
};
132132
match second {

crates/mbe/src/tt_iter.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ impl<'a> TtIter<'a> {
114114
('.', '.', Some('.' | '=')) | ('<', '<', Some('=')) | ('>', '>', Some('=')) => {
115115
let _ = self.next().unwrap();
116116
let _ = self.next().unwrap();
117-
Ok(smallvec![first, second.clone(), third.unwrap().clone()])
117+
Ok(smallvec![first, *second, *third.unwrap()])
118118
}
119119
('-' | '!' | '*' | '/' | '&' | '%' | '^' | '+' | '<' | '=' | '>' | '|', '=', _)
120120
| ('-' | '=' | '>', '>', _)
@@ -125,7 +125,7 @@ impl<'a> TtIter<'a> {
125125
| ('<', '<', _)
126126
| ('|', '|', _) => {
127127
let _ = self.next().unwrap();
128-
Ok(smallvec![first, second.clone()])
128+
Ok(smallvec![first, *second])
129129
}
130130
_ => Ok(smallvec![first]),
131131
}

0 commit comments

Comments
 (0)