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:
@@ -180,7 +180,7 @@ impl SubView {
|
||||
let weak_list = list.downgrade();
|
||||
let focus_handle = list.focus_handle(cx);
|
||||
let this = Self::new(
|
||||
focus_handle.clone(),
|
||||
focus_handle,
|
||||
list.into(),
|
||||
DebuggerPaneItem::BreakpointList,
|
||||
cx,
|
||||
@@ -1167,9 +1167,9 @@ impl RunningState {
|
||||
id: task::TaskId("debug".to_string()),
|
||||
full_label: title.clone(),
|
||||
label: title.clone(),
|
||||
command: command.clone(),
|
||||
command,
|
||||
args,
|
||||
command_label: title.clone(),
|
||||
command_label: title,
|
||||
cwd,
|
||||
env: envs,
|
||||
use_new_terminal: true,
|
||||
@@ -1756,7 +1756,7 @@ impl RunningState {
|
||||
this.activate_item(0, false, false, window, cx);
|
||||
});
|
||||
|
||||
let rightmost_pane = new_debugger_pane(workspace.clone(), project.clone(), window, cx);
|
||||
let rightmost_pane = new_debugger_pane(workspace.clone(), project, window, cx);
|
||||
rightmost_pane.update(cx, |this, cx| {
|
||||
this.add_item(
|
||||
Box::new(SubView::new(
|
||||
|
||||
@@ -685,7 +685,6 @@ impl BreakpointList {
|
||||
selection_kind.map(|kind| kind.0) != Some(SelectedBreakpointKind::Source),
|
||||
)
|
||||
.on_click({
|
||||
let focus_handle = focus_handle.clone();
|
||||
move |_, window, cx| {
|
||||
focus_handle.focus(window);
|
||||
window.dispatch_action(UnsetBreakpoint.boxed_clone(), cx)
|
||||
@@ -1139,7 +1138,6 @@ impl ExceptionBreakpoint {
|
||||
}
|
||||
})
|
||||
.on_click({
|
||||
let list = list.clone();
|
||||
move |_, _, cx| {
|
||||
list.update(cx, |this, cx| {
|
||||
this.toggle_exception_breakpoint(&id, cx);
|
||||
|
||||
@@ -365,7 +365,7 @@ impl Console {
|
||||
Some(ContextMenu::build(window, cx, |context_menu, _, _| {
|
||||
context_menu
|
||||
.when_some(keybinding_target.clone(), |el, keybinding_target| {
|
||||
el.context(keybinding_target.clone())
|
||||
el.context(keybinding_target)
|
||||
})
|
||||
.action("Watch Expression", WatchExpression.boxed_clone())
|
||||
}))
|
||||
|
||||
@@ -57,7 +57,7 @@ impl LoadedSourceList {
|
||||
h_flex()
|
||||
.text_ui_xs(cx)
|
||||
.text_color(cx.theme().colors().text_muted)
|
||||
.when_some(source.path.clone(), |this, path| this.child(path)),
|
||||
.when_some(source.path, |this, path| this.child(path)),
|
||||
)
|
||||
.into_any()
|
||||
}
|
||||
|
||||
@@ -461,7 +461,7 @@ impl MemoryView {
|
||||
let data_breakpoint_info = this.data_breakpoint_info(context.clone(), None, cx);
|
||||
cx.spawn(async move |this, cx| {
|
||||
if let Some(info) = data_breakpoint_info.await {
|
||||
let Some(data_id) = info.data_id.clone() else {
|
||||
let Some(data_id) = info.data_id else {
|
||||
return;
|
||||
};
|
||||
_ = this.update(cx, |this, cx| {
|
||||
|
||||
@@ -157,7 +157,7 @@ impl ModuleList {
|
||||
h_flex()
|
||||
.text_ui_xs(cx)
|
||||
.text_color(cx.theme().colors().text_muted)
|
||||
.when_some(module.path.clone(), |this, path| this.child(path)),
|
||||
.when_some(module.path, |this, path| this.child(path)),
|
||||
)
|
||||
.into_any()
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ impl StackFrameList {
|
||||
self.stack_frames(cx)
|
||||
.unwrap_or_default()
|
||||
.into_iter()
|
||||
.map(|stack_frame| stack_frame.dap.clone())
|
||||
.map(|stack_frame| stack_frame.dap)
|
||||
.collect()
|
||||
}
|
||||
|
||||
@@ -224,7 +224,7 @@ impl StackFrameList {
|
||||
|
||||
let collapsed_entries = std::mem::take(&mut collapsed_entries);
|
||||
if !collapsed_entries.is_empty() {
|
||||
entries.push(StackFrameEntry::Collapsed(collapsed_entries.clone()));
|
||||
entries.push(StackFrameEntry::Collapsed(collapsed_entries));
|
||||
}
|
||||
self.entries = entries;
|
||||
|
||||
@@ -418,7 +418,7 @@ impl StackFrameList {
|
||||
let source = stack_frame.source.clone();
|
||||
let is_selected_frame = Some(ix) == self.selected_ix;
|
||||
|
||||
let path = source.clone().and_then(|s| s.path.or(s.name));
|
||||
let path = source.and_then(|s| s.path.or(s.name));
|
||||
let formatted_path = path.map(|path| format!("{}:{}", path, stack_frame.line,));
|
||||
let formatted_path = formatted_path.map(|path| {
|
||||
Label::new(path)
|
||||
|
||||
@@ -313,7 +313,7 @@ impl VariableList {
|
||||
watcher.variables_reference,
|
||||
watcher.variables_reference,
|
||||
EntryPath::for_watcher(watcher.expression.clone()),
|
||||
DapEntry::Watcher(watcher.clone()),
|
||||
DapEntry::Watcher(watcher),
|
||||
)
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
@@ -1301,8 +1301,6 @@ impl VariableList {
|
||||
IconName::Close,
|
||||
)
|
||||
.on_click({
|
||||
let weak = weak.clone();
|
||||
let path = path.clone();
|
||||
move |_, window, cx| {
|
||||
weak.update(cx, |variable_list, cx| {
|
||||
variable_list.selection = Some(path.clone());
|
||||
@@ -1470,7 +1468,6 @@ impl VariableList {
|
||||
}))
|
||||
})
|
||||
.on_secondary_mouse_down(cx.listener({
|
||||
let path = path.clone();
|
||||
let entry = variable.clone();
|
||||
move |this, event: &MouseDownEvent, window, cx| {
|
||||
this.selection = Some(path.clone());
|
||||
|
||||
Reference in New Issue
Block a user