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

@ -89,7 +89,7 @@ impl ContextPickerCompletionProvider {
) -> Option<Completion> {
match entry {
ContextPickerEntry::Mode(mode) => Some(Completion {
replace_range: source_range.clone(),
replace_range: source_range,
new_text: format!("@{} ", mode.keyword()),
label: CodeLabel::plain(mode.label().to_string(), None),
icon_path: Some(mode.icon().path().into()),
@ -146,7 +146,7 @@ impl ContextPickerCompletionProvider {
};
Some(Completion {
replace_range: source_range.clone(),
replace_range: source_range,
new_text,
label: CodeLabel::plain(action.label().to_string(), None),
icon_path: Some(action.icon().path().into()),
@ -187,7 +187,7 @@ impl ContextPickerCompletionProvider {
documentation: None,
insert_text_mode: None,
source: project::CompletionSource::Custom,
icon_path: Some(icon_for_completion.clone()),
icon_path: Some(icon_for_completion),
confirm: Some(confirm_completion_callback(
thread_entry.title().clone(),
source_range.start,
@ -218,9 +218,9 @@ impl ContextPickerCompletionProvider {
documentation: None,
insert_text_mode: None,
source: project::CompletionSource::Custom,
icon_path: Some(icon_path.clone()),
icon_path: Some(icon_path),
confirm: Some(confirm_completion_callback(
rule.title.clone(),
rule.title,
source_range.start,
new_text_len - 1,
editor,
@ -260,7 +260,7 @@ impl ContextPickerCompletionProvider {
let completion_icon_path = if is_recent {
IconName::HistoryRerun.path().into()
} else {
crease_icon_path.clone()
crease_icon_path
};
let new_text = format!("{} ", uri.as_link());
@ -309,10 +309,10 @@ impl ContextPickerCompletionProvider {
label,
documentation: None,
source: project::CompletionSource::Custom,
icon_path: Some(icon_path.clone()),
icon_path: Some(icon_path),
insert_text_mode: None,
confirm: Some(confirm_completion_callback(
symbol.name.clone().into(),
symbol.name.into(),
source_range.start,
new_text_len - 1,
message_editor,
@ -327,7 +327,7 @@ impl ContextPickerCompletionProvider {
message_editor: WeakEntity<MessageEditor>,
cx: &mut App,
) -> Option<Completion> {
let new_text = format!("@fetch {} ", url_to_fetch.clone());
let new_text = format!("@fetch {} ", url_to_fetch);
let url_to_fetch = url::Url::parse(url_to_fetch.as_ref())
.or_else(|_| url::Url::parse(&format!("https://{url_to_fetch}")))
.ok()?;
@ -341,7 +341,7 @@ impl ContextPickerCompletionProvider {
label: CodeLabel::plain(url_to_fetch.to_string(), None),
documentation: None,
source: project::CompletionSource::Custom,
icon_path: Some(icon_path.clone()),
icon_path: Some(icon_path),
insert_text_mode: None,
confirm: Some(confirm_completion_callback(
url_to_fetch.to_string().into(),
@ -365,8 +365,7 @@ impl ContextPickerCompletionProvider {
};
match mode {
Some(ContextPickerMode::File) => {
let search_files_task =
search_files(query.clone(), cancellation_flag.clone(), &workspace, cx);
let search_files_task = search_files(query, cancellation_flag, &workspace, cx);
cx.background_spawn(async move {
search_files_task
.await
@ -377,8 +376,7 @@ impl ContextPickerCompletionProvider {
}
Some(ContextPickerMode::Symbol) => {
let search_symbols_task =
search_symbols(query.clone(), cancellation_flag.clone(), &workspace, cx);
let search_symbols_task = search_symbols(query, cancellation_flag, &workspace, cx);
cx.background_spawn(async move {
search_symbols_task
.await
@ -389,12 +387,8 @@ impl ContextPickerCompletionProvider {
}
Some(ContextPickerMode::Thread) => {
let search_threads_task = search_threads(
query.clone(),
cancellation_flag.clone(),
&self.history_store,
cx,
);
let search_threads_task =
search_threads(query, cancellation_flag, &self.history_store, cx);
cx.background_spawn(async move {
search_threads_task
.await
@ -415,7 +409,7 @@ impl ContextPickerCompletionProvider {
Some(ContextPickerMode::Rules) => {
if let Some(prompt_store) = self.prompt_store.as_ref() {
let search_rules_task =
search_rules(query.clone(), cancellation_flag.clone(), prompt_store, cx);
search_rules(query, cancellation_flag, prompt_store, cx);
cx.background_spawn(async move {
search_rules_task
.await
@ -448,7 +442,7 @@ impl ContextPickerCompletionProvider {
let executor = cx.background_executor().clone();
let search_files_task =
search_files(query.clone(), cancellation_flag.clone(), &workspace, cx);
search_files(query.clone(), cancellation_flag, &workspace, cx);
let entries = self.available_context_picker_entries(&workspace, cx);
let entry_candidates = entries

View file

@ -260,7 +260,7 @@ impl MessageEditor {
*excerpt_id,
start,
content_len,
crease_text.clone(),
crease_text,
mention_uri.icon_path(cx),
self.editor.clone(),
window,
@ -883,7 +883,7 @@ impl MessageEditor {
.spawn_in(window, {
let abs_path = abs_path.clone();
async move |_, cx| {
let image = image.await.map_err(|e| e.to_string())?;
let image = image.await?;
let format = image.format;
let image = cx
.update(|_, cx| LanguageModelImage::from_image(image, cx))
@ -1231,7 +1231,6 @@ fn render_image_fold_icon_button(
editor: WeakEntity<Editor>,
) -> Arc<dyn Send + Sync + Fn(FoldId, Range<Anchor>, &mut App) -> AnyElement> {
Arc::new({
let image_task = image_task.clone();
move |fold_id, fold_range, cx| {
let is_in_text_selection = editor
.update(cx, |editor, cx| editor.is_range_selected(&fold_range, cx))
@ -1408,10 +1407,7 @@ impl MentionSet {
crease_id,
Mention::Text {
uri,
content: content
.await
.map_err(|e| anyhow::anyhow!("{e}"))?
.to_string(),
content: content.await.map_err(|e| anyhow::anyhow!("{e}"))?,
},
))
})
@ -1478,10 +1474,7 @@ impl MentionSet {
crease_id,
Mention::Text {
uri,
content: content
.await
.map_err(|e| anyhow::anyhow!("{e}"))?
.to_string(),
content: content.await.map_err(|e| anyhow::anyhow!("{e}"))?,
},
))
})
@ -1821,7 +1814,7 @@ mod tests {
impl Focusable for MessageEditorItem {
fn focus_handle(&self, cx: &App) -> FocusHandle {
self.0.read(cx).focus_handle(cx).clone()
self.0.read(cx).focus_handle(cx)
}
}
@ -2219,7 +2212,7 @@ mod tests {
let completions = editor.current_completions().expect("Missing completions");
completions
.into_iter()
.map(|completion| completion.label.text.to_string())
.map(|completion| completion.label.text)
.collect::<Vec<_>>()
}
}

View file

@ -1534,7 +1534,7 @@ impl AcpThreadView {
window: &Window,
cx: &Context<Self>,
) -> AnyElement {
let button_id = SharedString::from(format!("tool_output-{:?}", tool_call_id.clone()));
let button_id = SharedString::from(format!("tool_output-{:?}", tool_call_id));
v_flex()
.mt_1p5()
@ -1555,9 +1555,8 @@ impl AcpThreadView {
.icon_color(Color::Muted)
.icon_position(IconPosition::Start)
.on_click(cx.listener({
let id = tool_call_id.clone();
move |this: &mut Self, _, _, cx: &mut Context<Self>| {
this.expanded_tool_calls.remove(&id);
this.expanded_tool_calls.remove(&tool_call_id);
cx.notify();
}
})),
@ -1578,7 +1577,7 @@ impl AcpThreadView {
uri.clone()
};
let button_id = SharedString::from(format!("item-{}", uri.clone()));
let button_id = SharedString::from(format!("item-{}", uri));
div()
.ml(px(7.))
@ -1724,7 +1723,7 @@ impl AcpThreadView {
&& let Some(editor) = entry.editor_for_diff(diff)
&& diff.read(cx).has_revealed_range(cx)
{
editor.clone().into_any_element()
editor.into_any_element()
} else if tool_progress {
self.render_diff_loading(cx)
} else {
@ -2888,7 +2887,6 @@ impl AcpThreadView {
.icon_size(IconSize::Small)
.icon_color(Color::Muted)
.tooltip({
let focus_handle = focus_handle.clone();
move |window, cx| {
Tooltip::for_action_in(
expand_tooltip,
@ -4372,7 +4370,7 @@ pub(crate) mod tests {
impl Focusable for ThreadViewItem {
fn focus_handle(&self, cx: &App) -> FocusHandle {
self.0.read(cx).focus_handle(cx).clone()
self.0.read(cx).focus_handle(cx)
}
}

View file

@ -491,7 +491,7 @@ fn render_markdown_code_block(
.on_click({
let active_thread = active_thread.clone();
let parsed_markdown = parsed_markdown.clone();
let code_block_range = metadata.content_range.clone();
let code_block_range = metadata.content_range;
move |_event, _window, cx| {
active_thread.update(cx, |this, cx| {
this.copied_code_block_ids.insert((message_id, ix));
@ -532,7 +532,6 @@ fn render_markdown_code_block(
"Expand Code"
}))
.on_click({
let active_thread = active_thread.clone();
move |_event, _window, cx| {
active_thread.update(cx, |this, cx| {
this.toggle_codeblock_expanded(message_id, ix);
@ -916,7 +915,7 @@ impl ActiveThread {
) {
let rendered = self
.rendered_tool_uses
.entry(tool_use_id.clone())
.entry(tool_use_id)
.or_insert_with(|| RenderedToolUse {
label: cx.new(|cx| {
Markdown::new("".into(), Some(self.language_registry.clone()), None, cx)
@ -1218,7 +1217,7 @@ impl ActiveThread {
match AgentSettings::get_global(cx).notify_when_agent_waiting {
NotifyWhenAgentWaiting::PrimaryScreen => {
if let Some(primary) = cx.primary_display() {
self.pop_up(icon, caption.into(), title.clone(), window, primary, cx);
self.pop_up(icon, caption.into(), title, window, primary, cx);
}
}
NotifyWhenAgentWaiting::AllScreens => {
@ -2112,7 +2111,7 @@ impl ActiveThread {
.gap_1()
.children(message_content)
.when_some(editing_message_state, |this, state| {
let focus_handle = state.editor.focus_handle(cx).clone();
let focus_handle = state.editor.focus_handle(cx);
this.child(
h_flex()
@ -2173,7 +2172,6 @@ impl ActiveThread {
.icon_color(Color::Muted)
.icon_size(IconSize::Small)
.tooltip({
let focus_handle = focus_handle.clone();
move |window, cx| {
Tooltip::for_action_in(
"Regenerate",
@ -2312,7 +2310,7 @@ impl ActiveThread {
.into_any_element()
} else if let Some(error) = error {
restore_checkpoint_button
.tooltip(Tooltip::text(error.to_string()))
.tooltip(Tooltip::text(error))
.into_any_element()
} else {
restore_checkpoint_button.into_any_element()

View file

@ -165,8 +165,8 @@ impl AgentConfiguration {
provider: &Arc<dyn LanguageModelProvider>,
cx: &mut Context<Self>,
) -> impl IntoElement + use<> {
let provider_id = provider.id().0.clone();
let provider_name = provider.name().0.clone();
let provider_id = provider.id().0;
let provider_name = provider.name().0;
let provider_id_string = SharedString::from(format!("provider-disclosure-{provider_id}"));
let configuration_view = self
@ -269,7 +269,7 @@ impl AgentConfiguration {
.closed_icon(IconName::ChevronDown),
)
.on_click(cx.listener({
let provider_id = provider.id().clone();
let provider_id = provider.id();
move |this, _event, _window, _cx| {
let is_expanded = this
.expanded_provider_configurations
@ -665,7 +665,7 @@ impl AgentConfiguration {
.size(IconSize::XSmall)
.color(Color::Accent)
.with_animation(
SharedString::from(format!("{}-starting", context_server_id.0.clone(),)),
SharedString::from(format!("{}-starting", context_server_id.0,)),
Animation::new(Duration::from_secs(3)).repeat(),
|icon, delta| icon.transform(Transformation::rotate(percentage(delta))),
)
@ -865,7 +865,6 @@ impl AgentConfiguration {
.on_click({
let context_server_manager =
self.context_server_store.clone();
let context_server_id = context_server_id.clone();
let fs = self.fs.clone();
move |state, _window, cx| {
@ -1075,7 +1074,6 @@ fn show_unable_to_uninstall_extension_with_context_server(
cx,
move |this, _cx| {
let workspace_handle = workspace_handle.clone();
let context_server_id = context_server_id.clone();
this.icon(ToastIcon::new(IconName::Warning).color(Color::Warning))
.dismiss_button(true)

View file

@ -261,7 +261,6 @@ impl ConfigureContextServerModal {
_cx: &mut Context<Workspace>,
) {
workspace.register_action({
let language_registry = language_registry.clone();
move |_workspace, _: &AddContextServer, window, cx| {
let workspace_handle = cx.weak_entity();
let language_registry = language_registry.clone();

View file

@ -464,7 +464,7 @@ impl ManageProfilesModal {
},
))
.child(ListSeparator)
.child(h_flex().p_2().child(mode.name_editor.clone()))
.child(h_flex().p_2().child(mode.name_editor))
}
fn render_view_profile(

View file

@ -185,7 +185,7 @@ impl AgentDiffPane {
let focus_handle = cx.focus_handle();
let multibuffer = cx.new(|_| MultiBuffer::new(Capability::ReadWrite));
let project = thread.project(cx).clone();
let project = thread.project(cx);
let editor = cx.new(|cx| {
let mut editor =
Editor::for_multibuffer(multibuffer.clone(), Some(project.clone()), window, cx);
@ -196,7 +196,7 @@ impl AgentDiffPane {
editor
});
let action_log = thread.action_log(cx).clone();
let action_log = thread.action_log(cx);
let mut this = Self {
_subscriptions: vec![
@ -1312,7 +1312,7 @@ impl AgentDiff {
let entity = cx.new(|_cx| Self::default());
let global = AgentDiffGlobal(entity.clone());
cx.set_global(global);
entity.clone()
entity
})
}
@ -1334,7 +1334,7 @@ impl AgentDiff {
window: &mut Window,
cx: &mut Context<Self>,
) {
let action_log = thread.action_log(cx).clone();
let action_log = thread.action_log(cx);
let action_log_subscription = cx.observe_in(&action_log, window, {
let workspace = workspace.clone();
@ -1544,7 +1544,7 @@ impl AgentDiff {
&& let Some(editor) = item.downcast::<Editor>()
&& let Some(buffer) = Self::full_editor_buffer(editor.read(cx), cx)
{
self.register_editor(workspace.downgrade(), buffer.clone(), editor, window, cx);
self.register_editor(workspace.downgrade(), buffer, editor, window, cx);
}
}

View file

@ -66,10 +66,8 @@ impl AgentModelSelector {
fs.clone(),
cx,
move |settings, _cx| {
settings.set_inline_assistant_model(
provider.clone(),
model_id.clone(),
);
settings
.set_inline_assistant_model(provider.clone(), model_id);
},
);
}

View file

@ -956,7 +956,7 @@ impl AgentPanel {
message_editor.focus_handle(cx).focus(window);
let thread_view = ActiveView::thread(active_thread.clone(), message_editor, window, cx);
let thread_view = ActiveView::thread(active_thread, message_editor, window, cx);
self.set_active_view(thread_view, window, cx);
AgentDiff::set_active_thread(&self.workspace, thread.clone(), window, cx);
@ -1163,7 +1163,7 @@ impl AgentPanel {
});
self.set_active_view(
ActiveView::prompt_editor(
editor.clone(),
editor,
self.history_store.clone(),
self.acp_history_store.clone(),
self.language_registry.clone(),
@ -1236,7 +1236,7 @@ impl AgentPanel {
});
message_editor.focus_handle(cx).focus(window);
let thread_view = ActiveView::thread(active_thread.clone(), message_editor, window, cx);
let thread_view = ActiveView::thread(active_thread, message_editor, window, cx);
self.set_active_view(thread_view, window, cx);
AgentDiff::set_active_thread(&self.workspace, thread.clone(), window, cx);
}
@ -1525,7 +1525,7 @@ impl AgentPanel {
return;
}
let model = thread_state.configured_model().map(|cm| cm.model.clone());
let model = thread_state.configured_model().map(|cm| cm.model);
if let Some(model) = model {
thread.update(cx, |active_thread, cx| {
active_thread.thread().update(cx, |thread, cx| {
@ -1680,7 +1680,7 @@ impl AgentPanel {
.open_thread_by_id(&id, window, cx)
.detach_and_log_err(cx),
HistoryEntryId::Context(path) => this
.open_saved_prompt_editor(path.clone(), window, cx)
.open_saved_prompt_editor(path, window, cx)
.detach_and_log_err(cx),
})
.ok();
@ -1966,7 +1966,7 @@ impl AgentPanel {
};
match state {
ThreadSummary::Pending => Label::new(ThreadSummary::DEFAULT.clone())
ThreadSummary::Pending => Label::new(ThreadSummary::DEFAULT)
.truncate()
.into_any_element(),
ThreadSummary::Generating => Label::new(LOADING_SUMMARY_PLACEHOLDER)
@ -2106,7 +2106,6 @@ impl AgentPanel {
.anchor(Corner::TopRight)
.with_handle(self.agent_panel_menu_handle.clone())
.menu({
let focus_handle = focus_handle.clone();
move |window, cx| {
Some(ContextMenu::build(window, cx, |mut menu, _window, _| {
menu = menu.context(focus_handle.clone());
@ -2184,7 +2183,6 @@ impl AgentPanel {
.trigger_with_tooltip(
IconButton::new("agent-nav-menu", icon).icon_size(IconSize::Small),
{
let focus_handle = focus_handle.clone();
move |window, cx| {
Tooltip::for_action_in(
"Toggle Recent Threads",
@ -2222,8 +2220,6 @@ impl AgentPanel {
this.go_back(&workspace::GoBack, window, cx);
}))
.tooltip({
let focus_handle = focus_handle.clone();
move |window, cx| {
Tooltip::for_action_in("Go Back", &workspace::GoBack, &focus_handle, window, cx)
}
@ -2249,7 +2245,6 @@ impl AgentPanel {
.anchor(Corner::TopRight)
.with_handle(self.new_thread_menu_handle.clone())
.menu({
let focus_handle = focus_handle.clone();
move |window, cx| {
let active_thread = active_thread.clone();
Some(ContextMenu::build(window, cx, |mut menu, _window, cx| {
@ -2377,7 +2372,6 @@ impl AgentPanel {
.anchor(Corner::TopLeft)
.with_handle(self.new_thread_menu_handle.clone())
.menu({
let focus_handle = focus_handle.clone();
let workspace = self.workspace.clone();
move |window, cx| {
@ -3015,7 +3009,7 @@ impl AgentPanel {
// TODO: Add keyboard navigation.
let is_hovered =
self.hovered_recent_history_item == Some(index);
HistoryEntryElement::new(entry.clone(), cx.entity().downgrade())
HistoryEntryElement::new(entry, cx.entity().downgrade())
.hovered(is_hovered)
.on_hover(cx.listener(
move |this, is_hovered, _window, cx| {
@ -3339,7 +3333,7 @@ impl AgentPanel {
.severity(Severity::Error)
.icon(IconName::XCircle)
.title(header)
.description(message.clone())
.description(message)
.actions_slot(
h_flex()
.gap_0p5()
@ -3359,7 +3353,7 @@ impl AgentPanel {
Callout::new()
.severity(Severity::Error)
.title("Error")
.description(message.clone())
.description(message)
.actions_slot(
h_flex()
.gap_0p5()

View file

@ -240,12 +240,7 @@ pub fn init(
client.telemetry().clone(),
cx,
);
terminal_inline_assistant::init(
fs.clone(),
prompt_builder.clone(),
client.telemetry().clone(),
cx,
);
terminal_inline_assistant::init(fs.clone(), prompt_builder, client.telemetry().clone(), cx);
cx.observe_new(move |workspace, window, cx| {
ConfigureContextServerModal::register(workspace, language_registry.clone(), window, cx)
})
@ -391,7 +386,6 @@ fn register_slash_commands(cx: &mut App) {
slash_command_registry.register_command(assistant_slash_commands::FetchSlashCommand, true);
cx.observe_flag::<assistant_slash_commands::StreamingExampleSlashCommandFeatureFlag, _>({
let slash_command_registry = slash_command_registry.clone();
move |is_enabled, _cx| {
if is_enabled {
slash_command_registry.register_command(

View file

@ -1129,7 +1129,7 @@ mod tests {
)
});
let chunks_tx = simulate_response_stream(codegen.clone(), cx);
let chunks_tx = simulate_response_stream(&codegen, cx);
let mut new_text = concat!(
" let mut x = 0;\n",
@ -1196,7 +1196,7 @@ mod tests {
)
});
let chunks_tx = simulate_response_stream(codegen.clone(), cx);
let chunks_tx = simulate_response_stream(&codegen, cx);
cx.background_executor.run_until_parked();
@ -1265,7 +1265,7 @@ mod tests {
)
});
let chunks_tx = simulate_response_stream(codegen.clone(), cx);
let chunks_tx = simulate_response_stream(&codegen, cx);
cx.background_executor.run_until_parked();
@ -1334,7 +1334,7 @@ mod tests {
)
});
let chunks_tx = simulate_response_stream(codegen.clone(), cx);
let chunks_tx = simulate_response_stream(&codegen, cx);
let new_text = concat!(
"func main() {\n",
"\tx := 0\n",
@ -1391,7 +1391,7 @@ mod tests {
)
});
let chunks_tx = simulate_response_stream(codegen.clone(), cx);
let chunks_tx = simulate_response_stream(&codegen, cx);
chunks_tx
.unbounded_send("let mut x = 0;\nx += 1;".to_string())
.unwrap();
@ -1473,7 +1473,7 @@ mod tests {
}
fn simulate_response_stream(
codegen: Entity<CodegenAlternative>,
codegen: &Entity<CodegenAlternative>,
cx: &mut TestAppContext,
) -> mpsc::UnboundedSender<String> {
let (chunks_tx, chunks_rx) = mpsc::unbounded();

View file

@ -818,13 +818,8 @@ pub fn crease_for_mention(
let render_trailer = move |_row, _unfold, _window: &mut Window, _cx: &mut App| Empty.into_any();
Crease::inline(
range,
placeholder.clone(),
fold_toggle("mention"),
render_trailer,
)
.with_metadata(CreaseMetadata { icon_path, label })
Crease::inline(range, placeholder, fold_toggle("mention"), render_trailer)
.with_metadata(CreaseMetadata { icon_path, label })
}
fn render_fold_icon_button(

View file

@ -79,8 +79,7 @@ fn search(
) -> Task<Vec<Match>> {
match mode {
Some(ContextPickerMode::File) => {
let search_files_task =
search_files(query.clone(), cancellation_flag.clone(), &workspace, cx);
let search_files_task = search_files(query, cancellation_flag, &workspace, cx);
cx.background_spawn(async move {
search_files_task
.await
@ -91,8 +90,7 @@ fn search(
}
Some(ContextPickerMode::Symbol) => {
let search_symbols_task =
search_symbols(query.clone(), cancellation_flag.clone(), &workspace, cx);
let search_symbols_task = search_symbols(query, cancellation_flag, &workspace, cx);
cx.background_spawn(async move {
search_symbols_task
.await
@ -108,13 +106,8 @@ fn search(
.and_then(|t| t.upgrade())
.zip(text_thread_context_store.as_ref().and_then(|t| t.upgrade()))
{
let search_threads_task = search_threads(
query.clone(),
cancellation_flag.clone(),
thread_store,
context_store,
cx,
);
let search_threads_task =
search_threads(query, cancellation_flag, thread_store, context_store, cx);
cx.background_spawn(async move {
search_threads_task
.await
@ -137,8 +130,7 @@ fn search(
Some(ContextPickerMode::Rules) => {
if let Some(prompt_store) = prompt_store.as_ref() {
let search_rules_task =
search_rules(query.clone(), cancellation_flag.clone(), prompt_store, cx);
let search_rules_task = search_rules(query, cancellation_flag, prompt_store, cx);
cx.background_spawn(async move {
search_rules_task
.await
@ -196,7 +188,7 @@ fn search(
let executor = cx.background_executor().clone();
let search_files_task =
search_files(query.clone(), cancellation_flag.clone(), &workspace, cx);
search_files(query.clone(), cancellation_flag, &workspace, cx);
let entries =
available_context_picker_entries(&prompt_store, &thread_store, &workspace, cx);
@ -283,7 +275,7 @@ impl ContextPickerCompletionProvider {
) -> Option<Completion> {
match entry {
ContextPickerEntry::Mode(mode) => Some(Completion {
replace_range: source_range.clone(),
replace_range: source_range,
new_text: format!("@{} ", mode.keyword()),
label: CodeLabel::plain(mode.label().to_string(), None),
icon_path: Some(mode.icon().path().into()),
@ -330,9 +322,6 @@ impl ContextPickerCompletionProvider {
);
let callback = Arc::new({
let context_store = context_store.clone();
let selections = selections.clone();
let selection_infos = selection_infos.clone();
move |_, window: &mut Window, cx: &mut App| {
context_store.update(cx, |context_store, cx| {
for (buffer, range) in &selections {
@ -441,7 +430,7 @@ impl ContextPickerCompletionProvider {
excerpt_id,
source_range.start,
new_text_len - 1,
editor.clone(),
editor,
context_store.clone(),
move |window, cx| match &thread_entry {
ThreadContextEntry::Thread { id, .. } => {
@ -510,7 +499,7 @@ impl ContextPickerCompletionProvider {
excerpt_id,
source_range.start,
new_text_len - 1,
editor.clone(),
editor,
context_store.clone(),
move |_, cx| {
let user_prompt_id = rules.prompt_id;
@ -547,7 +536,7 @@ impl ContextPickerCompletionProvider {
excerpt_id,
source_range.start,
new_text_len - 1,
editor.clone(),
editor,
context_store.clone(),
move |_, cx| {
let context_store = context_store.clone();
@ -704,16 +693,16 @@ impl ContextPickerCompletionProvider {
excerpt_id,
source_range.start,
new_text_len - 1,
editor.clone(),
editor,
context_store.clone(),
move |_, cx| {
let symbol = symbol.clone();
let context_store = context_store.clone();
let workspace = workspace.clone();
let result = super::symbol_context_picker::add_symbol(
symbol.clone(),
symbol,
false,
workspace.clone(),
workspace,
context_store.downgrade(),
cx,
);
@ -1162,7 +1151,7 @@ mod tests {
impl Focusable for AtMentionEditor {
fn focus_handle(&self, cx: &App) -> FocusHandle {
self.0.read(cx).focus_handle(cx).clone()
self.0.read(cx).focus_handle(cx)
}
}
@ -1480,7 +1469,7 @@ mod tests {
let completions = editor.current_completions().expect("Missing completions");
completions
.into_iter()
.map(|completion| completion.label.text.to_string())
.map(|completion| completion.label.text)
.collect::<Vec<_>>()
}

View file

@ -1693,7 +1693,7 @@ impl InlineAssist {
}),
range,
codegen: codegen.clone(),
workspace: workspace.clone(),
workspace,
_subscriptions: vec![
window.on_focus_in(&prompt_editor_focus_handle, cx, move |_, cx| {
InlineAssistant::update_global(cx, |this, cx| {

View file

@ -93,7 +93,7 @@ impl LanguageModelPickerDelegate {
let entries = models.entries();
Self {
on_model_changed: on_model_changed.clone(),
on_model_changed,
all_models: Arc::new(models),
selected_index: Self::get_active_model_index(&entries, get_active_model(cx)),
filtered_entries: entries,
@ -514,7 +514,7 @@ impl PickerDelegate for LanguageModelPickerDelegate {
.pl_0p5()
.gap_1p5()
.w(px(240.))
.child(Label::new(model_info.model.name().0.clone()).truncate()),
.child(Label::new(model_info.model.name().0).truncate()),
)
.end_slot(div().pr_3().when(is_selected, |this| {
this.child(

View file

@ -248,7 +248,7 @@ impl MessageEditor {
editor: editor.clone(),
project: thread.read(cx).project().clone(),
thread,
incompatible_tools_state: incompatible_tools.clone(),
incompatible_tools_state: incompatible_tools,
workspace,
context_store,
prompt_store,
@ -839,7 +839,6 @@ impl MessageEditor {
.child(self.profile_selector.clone())
.child(self.model_selector.clone())
.map({
let focus_handle = focus_handle.clone();
move |parent| {
if is_generating {
parent
@ -1801,7 +1800,7 @@ impl AgentPreview for MessageEditor {
.bg(cx.theme().colors().panel_background)
.border_1()
.border_color(cx.theme().colors().border)
.child(default_message_editor.clone())
.child(default_message_editor)
.into_any_element(),
)])
.into_any_element(),

View file

@ -137,12 +137,11 @@ impl ProfileSelector {
entry.handler({
let fs = self.fs.clone();
let provider = self.provider.clone();
let profile_id = profile_id.clone();
move |_window, cx| {
update_settings_file::<AgentSettings>(fs.clone(), cx, {
let profile_id = profile_id.clone();
move |settings, _cx| {
settings.set_profile(profile_id.clone());
settings.set_profile(profile_id);
}
});
@ -175,7 +174,6 @@ impl Render for ProfileSelector {
PopoverMenu::new("profile-selector")
.trigger_with_tooltip(trigger_button, {
let focus_handle = focus_handle.clone();
move |window, cx| {
Tooltip::for_action_in(
"Toggle Profile Menu",

View file

@ -88,8 +88,6 @@ impl SlashCommandCompletionProvider {
.map(|(editor, workspace)| {
let command_name = mat.string.clone();
let command_range = command_range.clone();
let editor = editor.clone();
let workspace = workspace.clone();
Arc::new(
move |intent: CompletionIntent,
window: &mut Window,
@ -158,7 +156,7 @@ impl SlashCommandCompletionProvider {
if let Some(command) = self.slash_commands.command(command_name, cx) {
let completions = command.complete_argument(
arguments,
new_cancel_flag.clone(),
new_cancel_flag,
self.workspace.clone(),
window,
cx,

View file

@ -432,7 +432,7 @@ impl TerminalInlineAssist {
terminal: terminal.downgrade(),
prompt_editor: Some(prompt_editor.clone()),
codegen: codegen.clone(),
workspace: workspace.clone(),
workspace,
context_store,
prompt_store,
_subscriptions: vec![

View file

@ -1739,7 +1739,7 @@ impl TextThreadEditor {
render_slash_command_output_toggle,
|_, _, _, _| Empty.into_any(),
)
.with_metadata(metadata.crease.clone())
.with_metadata(metadata.crease)
}),
cx,
);
@ -1810,7 +1810,7 @@ impl TextThreadEditor {
.filter_map(|(anchor, render_image)| {
const MAX_HEIGHT_IN_LINES: u32 = 8;
let anchor = buffer.anchor_in_excerpt(excerpt_id, anchor).unwrap();
let image = render_image.clone();
let image = render_image;
anchor.is_valid(&buffer).then(|| BlockProperties {
placement: BlockPlacement::Above(anchor),
height: Some(MAX_HEIGHT_IN_LINES),
@ -1873,7 +1873,7 @@ impl TextThreadEditor {
}
fn render_send_button(&self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
let focus_handle = self.focus_handle(cx).clone();
let focus_handle = self.focus_handle(cx);
let (style, tooltip) = match token_state(&self.context, cx) {
Some(TokenState::NoTokensLeft { .. }) => (
@ -2015,7 +2015,7 @@ impl TextThreadEditor {
None => IconName::Ai,
};
let focus_handle = self.editor().focus_handle(cx).clone();
let focus_handle = self.editor().focus_handle(cx);
PickerPopoverMenu::new(
self.language_model_selector.clone(),

View file

@ -499,7 +499,7 @@ impl AddedContext {
let thread = handle.thread.clone();
Some(Rc::new(move |_, cx| {
let text = thread.read(cx).latest_detailed_summary_or_text();
ContextPillHover::new_text(text.clone(), cx).into()
ContextPillHover::new_text(text, cx).into()
}))
},
handle: AgentContextHandle::Thread(handle),
@ -574,7 +574,7 @@ impl AddedContext {
.unwrap_or_else(|| "Unnamed Rule".into());
Some(AddedContext {
kind: ContextKind::Rules,
name: title.clone(),
name: title,
parent: None,
tooltip: None,
icon_path: None,