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 12:20:13 +02:00
committed by GitHub
parent cf7c64d77f
commit 7bdc99abc1
306 changed files with 805 additions and 1102 deletions
+1 -1
View File
@@ -465,7 +465,7 @@ impl VisualContext for AsyncWindowContext {
V: Focusable,
{
self.window.update(self, |_, window, cx| {
view.read(cx).focus_handle(cx).clone().focus(window);
view.read(cx).focus_handle(cx).focus(window);
})
}
}
+2 -1
View File
@@ -231,14 +231,15 @@ impl AnyEntity {
Self {
entity_id: id,
entity_type,
entity_map: entity_map.clone(),
#[cfg(any(test, feature = "leak-detection"))]
handle_id: entity_map
.clone()
.upgrade()
.unwrap()
.write()
.leak_detector
.handle_created(id),
entity_map,
}
}
+4 -4
View File
@@ -134,7 +134,7 @@ impl TestAppContext {
app: App::new_app(platform.clone(), asset_source, http_client),
background_executor,
foreground_executor,
dispatcher: dispatcher.clone(),
dispatcher,
test_platform: platform,
text_system,
fn_name,
@@ -339,7 +339,7 @@ impl TestAppContext {
/// Returns all windows open in the test.
pub fn windows(&self) -> Vec<AnyWindowHandle> {
self.app.borrow().windows().clone()
self.app.borrow().windows()
}
/// Run the given task on the main thread.
@@ -619,7 +619,7 @@ impl<V> Entity<V> {
}
}),
cx.subscribe(self, {
let mut tx = tx.clone();
let mut tx = tx;
move |_, _: &Evt, _| {
tx.blocking_send(()).ok();
}
@@ -1026,7 +1026,7 @@ impl VisualContext for VisualTestContext {
fn focus<V: crate::Focusable>(&mut self, view: &Entity<V>) -> Self::Result<()> {
self.window
.update(&mut self.cx, |_, window, cx| {
view.read(cx).focus_handle(cx).clone().focus(window)
view.read(cx).focus_handle(cx).focus(window)
})
.unwrap()
}