Skip to content

Commit b988b8c

Browse files
committed
clippy: enable assigning_clones lint
1 parent 94d2c04 commit b988b8c

File tree

5 files changed

+9
-6
lines changed

5 files changed

+9
-6
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ jj-lib-proc-macros = { path = "lib/proc-macros", version = "0.36.0" }
134134
testutils = { path = "lib/testutils" }
135135

136136
[workspace.lints.clippy]
137+
assigning_clones = "warn"
137138
borrow_as_ptr = "warn"
138139
cast_lossless = "warn"
139140
explicit_into_iter_loop = "warn"

cli/src/commands/metaedit.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,10 @@ pub(crate) fn cmd_metaedit(
210210
new_author.name = name;
211211
new_author.email = email;
212212
} else if args.update_author {
213-
new_author.name = commit_builder.committer().name.clone();
214-
new_author.email = commit_builder.committer().email.clone();
213+
new_author.name.clone_from(&commit_builder.committer().name);
214+
new_author
215+
.email
216+
.clone_from(&commit_builder.committer().email);
215217
}
216218
if args.update_author_timestamp {
217219
new_author.timestamp = commit_builder.committer().timestamp;

cli/src/merge_tools/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ pub fn get_external_tool_config(
225225
return Ok(None);
226226
};
227227
if tool.program.is_empty() {
228-
tool.program = name.to_owned();
228+
name.clone_into(&mut tool.program);
229229
};
230230
Ok(Some(tool))
231231
}

lib/src/commit_builder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ impl DetachedCommitBuilder {
389389
/// Writes new commit and makes it visible in the `mut_repo`.
390390
pub fn write(mut self, mut_repo: &mut MutableRepo) -> BackendResult<Commit> {
391391
if self.record_predecessors_in_commit {
392-
self.commit.predecessors = self.predecessors.clone();
392+
self.commit.predecessors.clone_from(&self.predecessors);
393393
}
394394
let commit = write_to_store(&self.store, self.commit, &self.sign_settings)?;
395395
// FIXME: Google's index.has_id() always returns true.
@@ -422,7 +422,7 @@ impl DetachedCommitBuilder {
422422
pub fn write_hidden(&self) -> BackendResult<Commit> {
423423
let mut commit = self.commit.clone();
424424
if self.record_predecessors_in_commit {
425-
commit.predecessors = self.predecessors.clone();
425+
commit.predecessors.clone_from(&self.predecessors);
426426
}
427427
write_to_store(&self.store, commit, &self.sign_settings)
428428
}

lib/src/default_index/changed_path.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ impl CompositeChangedPathIndex {
464464
assert_eq!(self_start_pos + self.num_commits, other_start_pos);
465465
self.readonly_segments
466466
.extend_from_slice(&other.readonly_segments);
467-
self.mutable_segment = other.mutable_segment.clone();
467+
self.mutable_segment.clone_from(&other.mutable_segment);
468468
self.num_commits += other.num_commits;
469469
}
470470

0 commit comments

Comments
 (0)