Skip to content

Commit 055a27d

Browse files
committed
Remove some unnecessary clones.
I found these by grepping for `&[a-z_\.]*\.clone()`, i.e. expressions like `&a.b.clone()`, which are sometimes unnecessary clones, and also looking at clones nearby to cases like that.
1 parent b8c54d6 commit 055a27d

File tree

4 files changed

+7
-8
lines changed

4 files changed

+7
-8
lines changed

compiler/rustc_ast_pretty/src/pprust/state.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
799799
has_bang,
800800
Some(*ident),
801801
macro_def.body.delim,
802-
&macro_def.body.tokens.clone(),
802+
&macro_def.body.tokens,
803803
true,
804804
sp,
805805
);
@@ -1469,7 +1469,7 @@ impl<'a> State<'a> {
14691469
true,
14701470
None,
14711471
m.args.delim,
1472-
&m.args.tokens.clone(),
1472+
&m.args.tokens,
14731473
true,
14741474
m.span(),
14751475
);

compiler/rustc_trait_selection/src/traits/query/type_op/ascribe_user_type.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,7 @@ fn relate_mir_and_user_args<'tcx>(
117117
CRATE_DEF_ID,
118118
ObligationCauseCode::AscribeUserTypeProvePredicate(predicate_span),
119119
);
120-
let instantiated_predicate =
121-
ocx.normalize(&cause.clone(), param_env, instantiated_predicate);
120+
let instantiated_predicate = ocx.normalize(&cause, param_env, instantiated_predicate);
122121

123122
ocx.register_obligation(Obligation::new(tcx, cause, param_env, instantiated_predicate));
124123
}

library/alloc/src/collections/btree/set.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ pub struct Iter<'a, T: 'a> {
139139
#[stable(feature = "collection_debug", since = "1.17.0")]
140140
impl<T: fmt::Debug> fmt::Debug for Iter<'_, T> {
141141
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
142-
f.debug_tuple("Iter").field(&self.iter.clone()).finish()
142+
f.debug_tuple("Iter").field(&self.iter).finish()
143143
}
144144
}
145145

src/bootstrap/src/core/build_steps/setup.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ impl Step for Editor {
683683
match EditorKind::prompt_user() {
684684
Ok(editor_kind) => {
685685
if let Some(editor_kind) = editor_kind {
686-
while !t!(create_editor_settings_maybe(config, editor_kind.clone())) {}
686+
while !t!(create_editor_settings_maybe(config, &editor_kind)) {}
687687
} else {
688688
println!("Ok, skipping editor setup!");
689689
}
@@ -695,7 +695,7 @@ impl Step for Editor {
695695

696696
/// Create the recommended editor LSP config file for rustc development, or just print it
697697
/// If this method should be re-called, it returns `false`.
698-
fn create_editor_settings_maybe(config: &Config, editor: EditorKind) -> io::Result<bool> {
698+
fn create_editor_settings_maybe(config: &Config, editor: &EditorKind) -> io::Result<bool> {
699699
let hashes = editor.hashes();
700700
let (current_hash, historical_hashes) = hashes.split_last().unwrap();
701701
let settings_path = editor.settings_path(config);
@@ -752,7 +752,7 @@ fn create_editor_settings_maybe(config: &Config, editor: EditorKind) -> io::Resu
752752
// exists but user modified, back it up
753753
Some(false) => {
754754
// exists and is not current version or outdated, so back it up
755-
let backup = settings_path.clone().with_extension(editor.backup_extension());
755+
let backup = settings_path.with_extension(editor.backup_extension());
756756
eprintln!(
757757
"WARNING: copying `{}` to `{}`",
758758
settings_path.file_name().unwrap().to_str().unwrap(),

0 commit comments

Comments
 (0)