Fix clippy::redundant_clone lint violations (#36558)

This removes around 900 unnecessary clones, ranging from cloning a few
ints all the way to large data structures and images.

A lot of these were fixed using `cargo clippy --fix --workspace
--all-targets`, however it often breaks other lints and needs to be run
again. This was then followed up with some manual fixing.

I understand this is a large diff, but all the changes are pretty
trivial. Rust is doing some heavy lifting here for us. Once I get it up
to speed with main, I'd appreciate this getting merged rather sooner
than later.

Release Notes:

- N/A
This commit is contained in:
tidely 2025-08-20 13:20:13 +03:00 committed by GitHub
parent cf7c64d77f
commit 7bdc99abc1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
306 changed files with 805 additions and 1102 deletions

View file

@ -345,7 +345,7 @@ impl GitRepository for FakeGitRepository {
fn create_branch(&self, name: String) -> BoxFuture<'_, Result<()>> {
self.with_state_async(true, move |state| {
state.branches.insert(name.to_owned());
state.branches.insert(name);
Ok(())
})
}

View file

@ -1960,7 +1960,7 @@ impl FileHandle for FakeHandle {
};
if state.try_entry(&target, false).is_some() {
return Ok(target.clone());
return Ok(target);
}
anyhow::bail!("fake fd target not found")
}
@ -2256,7 +2256,7 @@ impl Fs for FakeFs {
async fn load(&self, path: &Path) -> Result<String> {
let content = self.load_internal(path).await?;
Ok(String::from_utf8(content.clone())?)
Ok(String::from_utf8(content)?)
}
async fn load_bytes(&self, path: &Path) -> Result<Vec<u8>> {
@ -2412,7 +2412,7 @@ impl Fs for FakeFs {
tx,
original_path: path.to_owned(),
fs_state: self.state.clone(),
prefixes: Mutex::new(vec![path.to_owned()]),
prefixes: Mutex::new(vec![path]),
});
(
Box::pin(futures::StreamExt::filter(rx, {

View file

@ -159,7 +159,7 @@ impl GlobalWatcher {
path: path.clone(),
};
state.watchers.insert(id, registration_state);
*state.path_registrations.entry(path.clone()).or_insert(0) += 1;
*state.path_registrations.entry(path).or_insert(0) += 1;
Ok(id)
}