avoid 'cloning' types that implement 'Copy'

This commit is contained in:
Daniel Eades 2023-01-10 18:20:12 +00:00
parent 3987c835f2
commit 95d14c393c
6 changed files with 7 additions and 7 deletions

View file

@ -1931,7 +1931,7 @@ pub(crate) fn const_or_path_to_chalk(
debruijn: DebruijnIndex, debruijn: DebruijnIndex,
) -> Const { ) -> Const {
match value { match value {
ConstScalarOrPath::Scalar(s) => intern_const_scalar(s.clone(), expected_ty), ConstScalarOrPath::Scalar(s) => intern_const_scalar(*s, expected_ty),
ConstScalarOrPath::Path(n) => { ConstScalarOrPath::Path(n) => {
let path = ModPath::from_segments(PathKind::Plain, Some(n.clone())); let path = ModPath::from_segments(PathKind::Plain, Some(n.clone()));
path_to_const(db, resolver, &path, mode, args, debruijn) path_to_const(db, resolver, &path, mode, args, debruijn)

View file

@ -923,7 +923,7 @@ impl Struct {
} }
pub fn repr(self, db: &dyn HirDatabase) -> Option<ReprOptions> { pub fn repr(self, db: &dyn HirDatabase) -> Option<ReprOptions> {
db.struct_data(self.id).repr.clone() db.struct_data(self.id).repr
} }
pub fn kind(self, db: &dyn HirDatabase) -> StructKind { pub fn kind(self, db: &dyn HirDatabase) -> StructKind {

View file

@ -145,7 +145,7 @@ fn invocation_fixtures(rules: &FxHashMap<String, DeclarativeMacro>) -> Vec<(Stri
Op::Ident(it) => parent.token_trees.push(tt::Leaf::from(it.clone()).into()), Op::Ident(it) => parent.token_trees.push(tt::Leaf::from(it.clone()).into()),
Op::Punct(puncts) => { Op::Punct(puncts) => {
for punct in puncts { for punct in puncts {
parent.token_trees.push(tt::Leaf::from(punct.clone()).into()); parent.token_trees.push(tt::Leaf::from(*punct).into());
} }
} }
Op::Repeat { tokens, kind, separator } => { Op::Repeat { tokens, kind, separator } => {

View file

@ -138,7 +138,7 @@ fn expand_subtree(
Op::Ident(it) => arena.push(tt::Leaf::from(it.clone()).into()), Op::Ident(it) => arena.push(tt::Leaf::from(it.clone()).into()),
Op::Punct(puncts) => { Op::Punct(puncts) => {
for punct in puncts { for punct in puncts {
arena.push(tt::Leaf::from(punct.clone()).into()); arena.push(tt::Leaf::from(*punct).into());
} }
} }
Op::Subtree { tokens, delimiter } => { Op::Subtree { tokens, delimiter } => {

View file

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

View file

@ -114,7 +114,7 @@ impl<'a> TtIter<'a> {
('.', '.', Some('.' | '=')) | ('<', '<', Some('=')) | ('>', '>', Some('=')) => { ('.', '.', Some('.' | '=')) | ('<', '<', Some('=')) | ('>', '>', Some('=')) => {
let _ = self.next().unwrap(); let _ = self.next().unwrap();
let _ = self.next().unwrap(); let _ = self.next().unwrap();
Ok(smallvec![first, second.clone(), third.unwrap().clone()]) Ok(smallvec![first, *second, *third.unwrap()])
} }
('-' | '!' | '*' | '/' | '&' | '%' | '^' | '+' | '<' | '=' | '>' | '|', '=', _) ('-' | '!' | '*' | '/' | '&' | '%' | '^' | '+' | '<' | '=' | '>' | '|', '=', _)
| ('-' | '=' | '>', '>', _) | ('-' | '=' | '>', '>', _)
@ -125,7 +125,7 @@ impl<'a> TtIter<'a> {
| ('<', '<', _) | ('<', '<', _)
| ('|', '|', _) => { | ('|', '|', _) => {
let _ = self.next().unwrap(); let _ = self.next().unwrap();
Ok(smallvec![first, second.clone()]) Ok(smallvec![first, *second])
} }
_ => Ok(smallvec![first]), _ => Ok(smallvec![first]),
} }