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
@@ -192,7 +192,7 @@ impl BreakpointStore {
}
pub(crate) fn shared(&mut self, project_id: u64, downstream_client: AnyProtoClient) {
self.downstream_client = Some((downstream_client.clone(), project_id));
self.downstream_client = Some((downstream_client, project_id));
}
pub(crate) fn unshared(&mut self, cx: &mut Context<Self>) {
@@ -450,9 +450,9 @@ impl BreakpointStore {
});
if let Some(found_bp) = found_bp {
found_bp.message = Some(log_message.clone());
found_bp.message = Some(log_message);
} else {
breakpoint.bp.message = Some(log_message.clone());
breakpoint.bp.message = Some(log_message);
// We did not remove any breakpoint, hence let's toggle one.
breakpoint_set
.breakpoints
@@ -482,9 +482,9 @@ impl BreakpointStore {
});
if let Some(found_bp) = found_bp {
found_bp.hit_condition = Some(hit_condition.clone());
found_bp.hit_condition = Some(hit_condition);
} else {
breakpoint.bp.hit_condition = Some(hit_condition.clone());
breakpoint.bp.hit_condition = Some(hit_condition);
// We did not remove any breakpoint, hence let's toggle one.
breakpoint_set
.breakpoints
@@ -514,9 +514,9 @@ impl BreakpointStore {
});
if let Some(found_bp) = found_bp {
found_bp.condition = Some(condition.clone());
found_bp.condition = Some(condition);
} else {
breakpoint.bp.condition = Some(condition.clone());
breakpoint.bp.condition = Some(condition);
// We did not remove any breakpoint, hence let's toggle one.
breakpoint_set
.breakpoints
@@ -591,7 +591,7 @@ impl BreakpointStore {
cx: &mut Context<Self>,
) {
if let Some(breakpoints) = self.breakpoints.remove(&old_path) {
self.breakpoints.insert(new_path.clone(), breakpoints);
self.breakpoints.insert(new_path, breakpoints);
cx.notify();
}
+1 -1
View File
@@ -1454,7 +1454,7 @@ impl DapCommand for EvaluateCommand {
variables_reference: message.variable_reference,
named_variables: message.named_variables,
indexed_variables: message.indexed_variables,
memory_reference: message.memory_reference.clone(),
memory_reference: message.memory_reference,
value_location_reference: None, //TODO
})
}
+1 -1
View File
@@ -721,7 +721,7 @@ impl DapStore {
downstream_client: AnyProtoClient,
_: &mut Context<Self>,
) {
self.downstream_client = Some((downstream_client.clone(), project_id));
self.downstream_client = Some((downstream_client, project_id));
}
pub fn unshared(&mut self, cx: &mut Context<Self>) {
+3 -6
View File
@@ -1394,7 +1394,7 @@ impl Session {
let breakpoint_store = self.breakpoint_store.clone();
if let Some((local, path)) = self.as_running_mut().and_then(|local| {
let breakpoint = local.tmp_breakpoint.take()?;
let path = breakpoint.path.clone();
let path = breakpoint.path;
Some((local, path))
}) {
local
@@ -1710,7 +1710,7 @@ impl Session {
this.threads = result
.into_iter()
.map(|thread| (ThreadId(thread.id), Thread::from(thread.clone())))
.map(|thread| (ThreadId(thread.id), Thread::from(thread)))
.collect();
this.invalidate_command_type::<StackTraceCommand>();
@@ -2553,10 +2553,7 @@ impl Session {
mode: Option<String>,
cx: &mut Context<Self>,
) -> Task<Option<dap::DataBreakpointInfoResponse>> {
let command = DataBreakpointInfoCommand {
context: context.clone(),
mode,
};
let command = DataBreakpointInfoCommand { context, mode };
self.request(command, |_, response, _| response.ok(), cx)
}