Detailed changes
@@ -840,6 +840,7 @@ match_like_matches_macro = "warn"
module_inception = { level = "deny" }
question_mark = { level = "deny" }
single_match = "warn"
+redundant_clone = "warn"
redundant_closure = { level = "deny" }
redundant_static_lifetimes = { level = "warn" }
redundant_pattern_matching = "warn"
@@ -471,7 +471,7 @@ impl ContentBlock {
fn block_string_contents(&self, block: acp::ContentBlock) -> String {
match block {
- acp::ContentBlock::Text(text_content) => text_content.text.clone(),
+ acp::ContentBlock::Text(text_content) => text_content.text,
acp::ContentBlock::ResourceLink(resource_link) => {
Self::resource_link_md(&resource_link.uri)
}
@@ -1020,7 +1020,7 @@ impl AcpThread {
let location_updated = update.fields.locations.is_some();
current_call.update_fields(update.fields, languages, cx);
if location_updated {
- self.resolve_locations(update.id.clone(), cx);
+ self.resolve_locations(update.id, cx);
}
}
ToolCallUpdate::UpdateDiff(update) => {
@@ -222,7 +222,7 @@ impl PendingDiff {
fn finalize(&self, cx: &mut Context<Diff>) -> FinalizedDiff {
let ranges = self.excerpt_ranges(cx);
let base_text = self.base_text.clone();
- let language_registry = self.buffer.read(cx).language_registry().clone();
+ let language_registry = self.buffer.read(cx).language_registry();
let path = self
.buffer
@@ -248,7 +248,6 @@ impl PendingDiff {
let buffer_diff = cx.spawn({
let buffer = buffer.clone();
- let language_registry = language_registry.clone();
async move |_this, cx| {
build_buffer_diff(base_text, &buffer, language_registry, cx).await
}
@@ -161,7 +161,7 @@ impl ActionLog {
diff_base,
last_seen_base,
unreviewed_edits,
- snapshot: text_snapshot.clone(),
+ snapshot: text_snapshot,
status,
version: buffer.read(cx).version(),
diff,
@@ -461,7 +461,7 @@ impl ActionLog {
anyhow::Ok((
tracked_buffer.diff.clone(),
buffer.read(cx).language().cloned(),
- buffer.read(cx).language_registry().clone(),
+ buffer.read(cx).language_registry(),
))
})??;
let diff_snapshot = BufferDiff::update_diff(
@@ -529,12 +529,12 @@ impl ActionLog {
/// Mark a buffer as created by agent, so we can refresh it in the context
pub fn buffer_created(&mut self, buffer: Entity<Buffer>, cx: &mut Context<Self>) {
- self.track_buffer_internal(buffer.clone(), true, cx);
+ self.track_buffer_internal(buffer, true, cx);
}
/// Mark a buffer as edited by agent, so we can refresh it in the context
pub fn buffer_edited(&mut self, buffer: Entity<Buffer>, cx: &mut Context<Self>) {
- let tracked_buffer = self.track_buffer_internal(buffer.clone(), false, cx);
+ let tracked_buffer = self.track_buffer_internal(buffer, false, cx);
if let TrackedBufferStatus::Deleted = tracked_buffer.status {
tracked_buffer.status = TrackedBufferStatus::Modified;
}
@@ -2425,7 +2425,7 @@ mod tests {
assert_eq!(
unreviewed_hunks(&action_log, cx),
vec![(
- buffer.clone(),
+ buffer,
vec![
HunkStatus {
range: Point::new(6, 0)..Point::new(7, 0),
@@ -132,7 +132,7 @@ mod tests {
});
let tool_set = default_tool_set(cx);
- let profile = AgentProfile::new(id.clone(), tool_set);
+ let profile = AgentProfile::new(id, tool_set);
let mut enabled_tools = cx
.read(|cx| profile.enabled_tools(cx))
@@ -169,7 +169,7 @@ mod tests {
});
let tool_set = default_tool_set(cx);
- let profile = AgentProfile::new(id.clone(), tool_set);
+ let profile = AgentProfile::new(id, tool_set);
let mut enabled_tools = cx
.read(|cx| profile.enabled_tools(cx))
@@ -202,7 +202,7 @@ mod tests {
});
let tool_set = default_tool_set(cx);
- let profile = AgentProfile::new(id.clone(), tool_set);
+ let profile = AgentProfile::new(id, tool_set);
let mut enabled_tools = cx
.read(|cx| profile.enabled_tools(cx))
@@ -86,15 +86,13 @@ impl Tool for ContextServerTool {
) -> ToolResult {
if let Some(server) = self.store.read(cx).get_running_server(&self.server_id) {
let tool_name = self.tool.name.clone();
- let server_clone = server.clone();
- let input_clone = input.clone();
cx.spawn(async move |_cx| {
- let Some(protocol) = server_clone.client() else {
+ let Some(protocol) = server.client() else {
bail!("Context server not initialized");
};
- let arguments = if let serde_json::Value::Object(map) = input_clone {
+ let arguments = if let serde_json::Value::Object(map) = input {
Some(map.into_iter().collect())
} else {
None
@@ -494,7 +494,7 @@ impl Thread {
last_received_chunk_at: None,
request_callback: None,
remaining_turns: u32::MAX,
- configured_model: configured_model.clone(),
+ configured_model,
profile: AgentProfile::new(profile_id, tools),
}
}
@@ -532,7 +532,7 @@ impl Thread {
.and_then(|model| {
let model = SelectedModel {
provider: model.provider.clone().into(),
- model: model.model.clone().into(),
+ model: model.model.into(),
};
registry.select_model(&model, cx)
})
@@ -1646,10 +1646,10 @@ impl Thread {
};
self.tool_use
- .request_tool_use(tool_message_id, tool_use, tool_use_metadata.clone(), cx);
+ .request_tool_use(tool_message_id, tool_use, tool_use_metadata, cx);
self.tool_use.insert_tool_output(
- tool_use_id.clone(),
+ tool_use_id,
tool_name,
tool_output,
self.configured_model.as_ref(),
@@ -3241,7 +3241,7 @@ impl Thread {
self.configured_model.as_ref(),
self.completion_mode,
);
- self.tool_finished(tool_use_id.clone(), None, true, window, cx);
+ self.tool_finished(tool_use_id, None, true, window, cx);
}
}
@@ -3873,7 +3873,7 @@ fn main() {{
AgentSettings {
model_parameters: vec![LanguageModelParameters {
provider: Some(model.provider_id().0.to_string().into()),
- model: Some(model.id().0.clone()),
+ model: Some(model.id().0),
temperature: Some(0.66),
}],
..AgentSettings::get_global(cx).clone()
@@ -3893,7 +3893,7 @@ fn main() {{
AgentSettings {
model_parameters: vec![LanguageModelParameters {
provider: None,
- model: Some(model.id().0.clone()),
+ model: Some(model.id().0),
temperature: Some(0.66),
}],
..AgentSettings::get_global(cx).clone()
@@ -3933,7 +3933,7 @@ fn main() {{
AgentSettings {
model_parameters: vec![LanguageModelParameters {
provider: Some("anthropic".into()),
- model: Some(model.id().0.clone()),
+ model: Some(model.id().0),
temperature: Some(0.66),
}],
..AgentSettings::get_global(cx).clone()
@@ -255,7 +255,7 @@ impl NativeAgent {
}),
cx.subscribe(&thread_handle, Self::handle_thread_token_usage_updated),
cx.observe(&thread_handle, move |this, thread, cx| {
- this.save_thread(thread.clone(), cx)
+ this.save_thread(thread, cx)
}),
];
@@ -499,8 +499,8 @@ impl NativeAgent {
self.models.refresh_list(cx);
let registry = LanguageModelRegistry::read_global(cx);
- let default_model = registry.default_model().map(|m| m.model.clone());
- let summarization_model = registry.thread_summary_model().map(|m| m.model.clone());
+ let default_model = registry.default_model().map(|m| m.model);
+ let summarization_model = registry.thread_summary_model().map(|m| m.model);
for session in self.sessions.values_mut() {
session.thread.update(cx, |thread, cx| {
@@ -287,7 +287,7 @@ impl ThreadsDatabase {
.map_err(|e| anyhow!("Failed to create threads table: {}", e))?;
let db = Self {
- executor: executor.clone(),
+ executor,
connection: Arc::new(Mutex::new(connection)),
};
@@ -325,7 +325,7 @@ impl ThreadsDatabase {
INSERT OR REPLACE INTO threads (id, summary, updated_at, data_type, data) VALUES (?, ?, ?, ?, ?)
"})?;
- insert((id.0.clone(), title, updated_at, data_type, data))?;
+ insert((id.0, title, updated_at, data_type, data))?;
Ok(())
}
@@ -434,7 +434,7 @@ mod tests {
let client = Client::new(clock, http_client, cx);
agent::init(cx);
agent_settings::init(cx);
- language_model::init(client.clone(), cx);
+ language_model::init(client, cx);
});
}
@@ -1401,7 +1401,7 @@ async fn test_agent_connection(cx: &mut TestAppContext) {
let client = Client::new(clock, http_client, cx);
let user_store = cx.new(|cx| UserStore::new(client.clone(), cx));
language_model::init(client.clone(), cx);
- language_models::init(user_store.clone(), client.clone(), cx);
+ language_models::init(user_store, client.clone(), cx);
Project::init_settings(cx);
LanguageModelRegistry::test(cx);
agent_settings::init(cx);
@@ -1854,7 +1854,7 @@ async fn setup(cx: &mut TestAppContext, model: TestModel) -> ThreadTest {
let client = Client::production(cx);
let user_store = cx.new(|cx| UserStore::new(client.clone(), cx));
language_model::init(client.clone(), cx);
- language_models::init(user_store.clone(), client.clone(), cx);
+ language_models::init(user_store, client.clone(), cx);
watch_settings(fs.clone(), cx);
});
@@ -679,7 +679,7 @@ impl Thread {
.and_then(|model| {
let model = SelectedModel {
provider: model.provider.clone().into(),
- model: model.model.clone().into(),
+ model: model.model.into(),
};
registry.select_model(&model, cx)
})
@@ -176,15 +176,13 @@ impl AnyAgentTool for ContextServerTool {
return Task::ready(Err(anyhow!("Context server not found")));
};
let tool_name = self.tool.name.clone();
- let server_clone = server.clone();
- let input_clone = input.clone();
cx.spawn(async move |_cx| {
- let Some(protocol) = server_clone.client() else {
+ let Some(protocol) = server.client() else {
bail!("Context server not initialized");
};
- let arguments = if let serde_json::Value::Object(map) = input_clone {
+ let arguments = if let serde_json::Value::Object(map) = input {
Some(map.into_iter().collect())
} else {
None
@@ -427,7 +427,7 @@ impl AgentTool for EditFileTool {
Ok(EditFileToolOutput {
input_path: input.path,
- new_text: new_text.clone(),
+ new_text,
old_text,
diff: unified_diff,
edit_agent_output,
@@ -318,7 +318,7 @@ mod tests {
init_test(cx);
cx.executor().allow_parking();
- let fs = FakeFs::new(cx.executor().clone());
+ let fs = FakeFs::new(cx.executor());
fs.insert_tree(
path!("/root"),
serde_json::json!({
@@ -403,7 +403,7 @@ mod tests {
init_test(cx);
cx.executor().allow_parking();
- let fs = FakeFs::new(cx.executor().clone());
+ let fs = FakeFs::new(cx.executor());
fs.insert_tree(
path!("/root"),
serde_json::json!({
@@ -478,7 +478,7 @@ mod tests {
init_test(cx);
cx.executor().allow_parking();
- let fs = FakeFs::new(cx.executor().clone());
+ let fs = FakeFs::new(cx.executor());
// Create test file with syntax structures
fs.insert_tree(
@@ -763,7 +763,7 @@ mod tests {
if cfg!(windows) {
result.replace("root\\", "root/")
} else {
- result.to_string()
+ result
}
}
Err(e) => panic!("Failed to run grep tool: {}", e),
@@ -234,7 +234,7 @@ fn process_content(
if is_empty {
"Command executed successfully.".to_string()
} else {
- content.to_string()
+ content
}
}
Some(exit_status) => {
@@ -787,7 +787,7 @@ impl Content {
pub fn chunks(self) -> impl Iterator<Item = ContentChunk> {
match self {
Self::Chunks(chunks) => chunks.into_iter(),
- Self::UntaggedText(text) => vec![ContentChunk::Text { text: text.clone() }].into_iter(),
+ Self::UntaggedText(text) => vec![ContentChunk::Text { text }].into_iter(),
}
}
}
@@ -58,7 +58,7 @@ impl ClaudeTool {
Self::Terminal(None)
} else {
Self::Other {
- name: tool_name.to_string(),
+ name: tool_name,
input,
}
}
@@ -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
@@ -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<_>>()
}
}
@@ -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)
}
}
@@ -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()
@@ -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)
@@ -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();
@@ -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(
@@ -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);
}
}
@@ -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);
},
);
}
@@ -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()
@@ -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(
@@ -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();
@@ -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(
@@ -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<_>>()
}
@@ -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| {
@@ -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(
@@ -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(),
@@ -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",
@@ -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,
@@ -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![
@@ -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(),
@@ -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,
@@ -33,7 +33,7 @@ impl ApiKeysWithProviders {
.filter(|provider| {
provider.is_authenticated(cx) && provider.id() != ZED_CLOUD_PROVIDER_ID
})
- .map(|provider| (provider.icon(), provider.name().0.clone()))
+ .map(|provider| (provider.icon(), provider.name().0))
.collect()
}
}
@@ -50,7 +50,7 @@ impl AgentPanelOnboarding {
.filter(|provider| {
provider.is_authenticated(cx) && provider.id() != ZED_CLOUD_PROVIDER_ID
})
- .map(|provider| (provider.icon(), provider.name().0.clone()))
+ .map(|provider| (provider.icon(), provider.name().0))
.collect()
}
}
@@ -2282,7 +2282,7 @@ impl AssistantContext {
let mut contents = self.contents(cx).peekable();
fn collect_text_content(buffer: &Buffer, range: Range<usize>) -> Option<String> {
- let text: String = buffer.text_for_range(range.clone()).collect();
+ let text: String = buffer.text_for_range(range).collect();
if text.trim().is_empty() {
None
} else {
@@ -1321,7 +1321,7 @@ fn test_summarize_error(
fn setup_context_editor_with_fake_model(
cx: &mut TestAppContext,
) -> (Entity<AssistantContext>, Arc<FakeLanguageModel>) {
- let registry = Arc::new(LanguageRegistry::test(cx.executor().clone()));
+ let registry = Arc::new(LanguageRegistry::test(cx.executor()));
let fake_provider = Arc::new(FakeLanguageModelProvider::default());
let fake_model = Arc::new(fake_provider.test_model());
@@ -1376,7 +1376,7 @@ fn messages_cache(
context
.read(cx)
.messages(cx)
- .map(|message| (message.id, message.cache.clone()))
+ .map(|message| (message.id, message.cache))
.collect()
}
@@ -862,7 +862,7 @@ impl ContextStore {
ContextServerStatus::Running => {
self.load_context_server_slash_commands(
server_id.clone(),
- context_server_store.clone(),
+ context_server_store,
cx,
);
}
@@ -44,7 +44,7 @@ impl DiagnosticsSlashCommand {
score: 0.,
positions: Vec::new(),
worktree_id: entry.worktree_id.to_usize(),
- path: entry.path.clone(),
+ path: entry.path,
path_prefix: path_prefix.clone(),
is_dir: false, // Diagnostics can't be produced for directories
distance_to_relative_ancestor: 0,
@@ -80,7 +80,7 @@ impl SlashCommand for PromptSlashCommand {
};
let store = PromptStore::global(cx);
- let title = SharedString::from(title.clone());
+ let title = SharedString::from(title);
let prompt = cx.spawn({
let title = title.clone();
async move |cx| {
@@ -1153,8 +1153,7 @@ impl EvalInput {
.expect("Conversation must end with an edit_file tool use")
.clone();
- let edit_file_input: EditFileToolInput =
- serde_json::from_value(tool_use.input.clone()).unwrap();
+ let edit_file_input: EditFileToolInput = serde_json::from_value(tool_use.input).unwrap();
EvalInput {
conversation,
@@ -1460,7 +1459,7 @@ impl EditAgentTest {
async fn new(cx: &mut TestAppContext) -> Self {
cx.executor().allow_parking();
- let fs = FakeFs::new(cx.executor().clone());
+ let fs = FakeFs::new(cx.executor());
cx.update(|cx| {
settings::init(cx);
gpui_tokio::init(cx);
@@ -1475,7 +1474,7 @@ impl EditAgentTest {
Project::init_settings(cx);
language::init(cx);
language_model::init(client.clone(), cx);
- language_models::init(user_store.clone(), client.clone(), cx);
+ language_models::init(user_store, client.clone(), cx);
crate::init(client.http_client(), cx);
});
@@ -319,7 +319,7 @@ mod tests {
);
let snapshot = buffer.snapshot();
- let mut finder = StreamingFuzzyMatcher::new(snapshot.clone());
+ let mut finder = StreamingFuzzyMatcher::new(snapshot);
assert_eq!(push(&mut finder, ""), None);
assert_eq!(finish(finder), None);
}
@@ -333,7 +333,7 @@ mod tests {
);
let snapshot = buffer.snapshot();
- let mut finder = StreamingFuzzyMatcher::new(snapshot.clone());
+ let mut finder = StreamingFuzzyMatcher::new(snapshot);
// Push partial query
assert_eq!(push(&mut finder, "This"), None);
@@ -365,7 +365,7 @@ mod tests {
);
let snapshot = buffer.snapshot();
- let mut finder = StreamingFuzzyMatcher::new(snapshot.clone());
+ let mut finder = StreamingFuzzyMatcher::new(snapshot);
// Push a fuzzy query that should match the first function
assert_eq!(
@@ -391,7 +391,7 @@ mod tests {
);
let snapshot = buffer.snapshot();
- let mut finder = StreamingFuzzyMatcher::new(snapshot.clone());
+ let mut finder = StreamingFuzzyMatcher::new(snapshot);
// No match initially
assert_eq!(push(&mut finder, "Lin"), None);
@@ -420,7 +420,7 @@ mod tests {
);
let snapshot = buffer.snapshot();
- let mut finder = StreamingFuzzyMatcher::new(snapshot.clone());
+ let mut finder = StreamingFuzzyMatcher::new(snapshot);
// Push text in small chunks across line boundaries
assert_eq!(push(&mut finder, "jumps "), None); // No newline yet
@@ -458,7 +458,7 @@ mod tests {
);
let snapshot = buffer.snapshot();
- let mut finder = StreamingFuzzyMatcher::new(snapshot.clone());
+ let mut finder = StreamingFuzzyMatcher::new(snapshot);
assert_eq!(
push(&mut finder, "impl Debug for User {\n"),
@@ -711,7 +711,7 @@ mod tests {
"Expected to match `second_function` based on the line hint"
);
- let mut matcher = StreamingFuzzyMatcher::new(snapshot.clone());
+ let mut matcher = StreamingFuzzyMatcher::new(snapshot);
matcher.push(query, None);
matcher.finish();
let best_match = matcher.select_best_match();
@@ -727,7 +727,7 @@ mod tests {
let buffer = TextBuffer::new(0, BufferId::new(1).unwrap(), text.clone());
let snapshot = buffer.snapshot();
- let mut matcher = StreamingFuzzyMatcher::new(snapshot.clone());
+ let mut matcher = StreamingFuzzyMatcher::new(snapshot);
// Split query into random chunks
let chunks = to_random_chunks(rng, query);
@@ -376,7 +376,7 @@ impl Tool for EditFileTool {
let output = EditFileToolOutput {
original_path: project_path.path.to_path_buf(),
- new_text: new_text.clone(),
+ new_text,
old_text,
raw_output: Some(agent_output),
};
@@ -643,7 +643,7 @@ impl EditFileToolCard {
diff
});
- self.buffer = Some(buffer.clone());
+ self.buffer = Some(buffer);
self.base_text = Some(base_text.into());
self.buffer_diff = Some(buffer_diff.clone());
@@ -776,7 +776,6 @@ impl EditFileToolCard {
let buffer_diff = cx.spawn({
let buffer = buffer.clone();
- let language_registry = language_registry.clone();
async move |_this, cx| {
build_buffer_diff(base_text, &buffer, &language_registry, cx).await
}
@@ -863,7 +862,6 @@ impl ToolCard for EditFileToolCard {
)
.on_click({
let path = self.path.clone();
- let workspace = workspace.clone();
move |_, window, cx| {
workspace
.update(cx, {
@@ -327,7 +327,7 @@ mod tests {
init_test(cx);
cx.executor().allow_parking();
- let fs = FakeFs::new(cx.executor().clone());
+ let fs = FakeFs::new(cx.executor());
fs.insert_tree(
path!("/root"),
serde_json::json!({
@@ -415,7 +415,7 @@ mod tests {
init_test(cx);
cx.executor().allow_parking();
- let fs = FakeFs::new(cx.executor().clone());
+ let fs = FakeFs::new(cx.executor());
fs.insert_tree(
path!("/root"),
serde_json::json!({
@@ -494,7 +494,7 @@ mod tests {
init_test(cx);
cx.executor().allow_parking();
- let fs = FakeFs::new(cx.executor().clone());
+ let fs = FakeFs::new(cx.executor());
// Create test file with syntax structures
fs.insert_tree(
@@ -350,7 +350,7 @@ fn process_content(
if is_empty {
"Command executed successfully.".to_string()
} else {
- content.to_string()
+ content
}
}
Some(exit_status) => {
@@ -101,14 +101,11 @@ impl RenderOnce for ToolCallCardHeader {
})
.when_some(secondary_text, |this, secondary_text| {
this.child(bullet_divider())
- .child(div().text_size(font_size).child(secondary_text.clone()))
+ .child(div().text_size(font_size).child(secondary_text))
})
.when_some(code_path, |this, code_path| {
- this.child(bullet_divider()).child(
- Label::new(code_path.clone())
- .size(LabelSize::Small)
- .inline_code(cx),
- )
+ this.child(bullet_divider())
+ .child(Label::new(code_path).size(LabelSize::Small).inline_code(cx))
})
.with_animation(
"loading-label",
@@ -193,10 +193,7 @@ impl ToolCard for WebSearchToolCard {
)
}
})
- .on_click({
- let url = url.clone();
- move |_, _, cx| cx.open_url(&url)
- })
+ .on_click(move |_, _, cx| cx.open_url(&url))
}))
.into_any(),
),
@@ -114,7 +114,7 @@ fn view_release_notes_locally(
cx,
);
workspace.add_item_to_active_pane(
- Box::new(markdown_preview.clone()),
+ Box::new(markdown_preview),
None,
true,
window,
@@ -175,12 +175,8 @@ impl BufferDiffSnapshot {
if let Some(text) = &base_text {
let base_text_rope = Rope::from(text.as_str());
base_text_pair = Some((text.clone(), base_text_rope.clone()));
- let snapshot = language::Buffer::build_snapshot(
- base_text_rope,
- language.clone(),
- language_registry.clone(),
- cx,
- );
+ let snapshot =
+ language::Buffer::build_snapshot(base_text_rope, language, language_registry, cx);
base_text_snapshot = cx.background_spawn(snapshot);
base_text_exists = true;
} else {
@@ -957,7 +953,7 @@ impl BufferDiff {
.buffer_range
.start;
let end = self
- .hunks_intersecting_range_rev(range.clone(), buffer)
+ .hunks_intersecting_range_rev(range, buffer)
.next()?
.buffer_range
.end;
@@ -1441,7 +1437,7 @@ mod tests {
.unindent();
let buffer = Buffer::new(0, BufferId::new(1).unwrap(), buffer_text);
- let unstaged_diff = BufferDiffSnapshot::new_sync(buffer.clone(), index_text.clone(), cx);
+ let unstaged_diff = BufferDiffSnapshot::new_sync(buffer.clone(), index_text, cx);
let mut uncommitted_diff =
BufferDiffSnapshot::new_sync(buffer.clone(), head_text.clone(), cx);
uncommitted_diff.secondary_diff = Some(Box::new(unstaged_diff));
@@ -438,7 +438,7 @@ fn init_test(cx: &mut App) -> Entity<ChannelStore> {
let clock = Arc::new(FakeSystemClock::new());
let http = FakeHttpClient::with_404_response();
- let client = Client::new(clock, http.clone(), cx);
+ let client = Client::new(clock, http, cx);
let user_store = cx.new(|cx| UserStore::new(client.clone(), cx));
client::init(&client, cx);
@@ -926,7 +926,7 @@ mod mac_os {
fn path(&self) -> PathBuf {
match self {
- Bundle::App { app_bundle, .. } => app_bundle.join("Contents/MacOS/zed").clone(),
+ Bundle::App { app_bundle, .. } => app_bundle.join("Contents/MacOS/zed"),
Bundle::LocalPath { executable, .. } => executable.clone(),
}
}
@@ -181,7 +181,7 @@ pub fn init(client: &Arc<Client>, cx: &mut App) {
});
cx.on_action({
- let client = client.clone();
+ let client = client;
move |_: &Reconnect, cx| {
if let Some(client) = client.upgrade() {
cx.spawn(async move |cx| {
@@ -791,7 +791,7 @@ impl Client {
Arc::new(move |subscriber, envelope, client, cx| {
let subscriber = subscriber.downcast::<E>().unwrap();
let envelope = envelope.into_any().downcast::<TypedEnvelope<M>>().unwrap();
- handler(subscriber, *envelope, client.clone(), cx).boxed_local()
+ handler(subscriber, *envelope, client, cx).boxed_local()
}),
);
if prev_handler.is_some() {
@@ -2048,10 +2048,7 @@ mod tests {
assert_eq!(*auth_count.lock(), 1);
assert_eq!(*dropped_auth_count.lock(), 0);
- let _authenticate = cx.spawn({
- let client = client.clone();
- |cx| async move { client.connect(false, &cx).await }
- });
+ let _authenticate = cx.spawn(|cx| async move { client.connect(false, &cx).await });
executor.run_until_parked();
assert_eq!(*auth_count.lock(), 2);
assert_eq!(*dropped_auth_count.lock(), 1);
@@ -739,7 +739,7 @@ mod tests {
);
// Third scan of worktree does not double report, as we already reported
- test_project_discovery_helper(telemetry.clone(), vec!["package.json"], None, worktree_id);
+ test_project_discovery_helper(telemetry, vec!["package.json"], None, worktree_id);
}
#[gpui::test]
@@ -751,7 +751,7 @@ mod tests {
let telemetry = cx.update(|cx| Telemetry::new(clock.clone(), http, cx));
test_project_discovery_helper(
- telemetry.clone(),
+ telemetry,
vec!["package.json", "pnpm-lock.yaml"],
Some(vec!["node", "pnpm"]),
1,
@@ -767,7 +767,7 @@ mod tests {
let telemetry = cx.update(|cx| Telemetry::new(clock.clone(), http, cx));
test_project_discovery_helper(
- telemetry.clone(),
+ telemetry,
vec!["package.json", "yarn.lock"],
Some(vec!["node", "yarn"]),
1,
@@ -786,7 +786,7 @@ mod tests {
// project type for the same worktree multiple times
test_project_discovery_helper(
- telemetry.clone().clone(),
+ telemetry.clone(),
vec!["global.json"],
Some(vec!["dotnet"]),
1,
@@ -280,7 +280,7 @@ pub async fn post_hang(
service = "client",
version = %report.app_version.unwrap_or_default().to_string(),
os_name = %report.os_name,
- os_version = report.os_version.unwrap_or_default().to_string(),
+ os_version = report.os_version.unwrap_or_default(),
incident_id = %incident_id,
installation_id = %report.installation_id.unwrap_or_default(),
backtrace = %backtrace,
@@ -236,7 +236,7 @@ mod test {
#[gpui::test]
async fn test_verify_access_token(cx: &mut gpui::TestAppContext) {
- let test_db = crate::db::TestDb::sqlite(cx.executor().clone());
+ let test_db = crate::db::TestDb::sqlite(cx.executor());
let db = test_db.db();
let user = db
@@ -8,7 +8,7 @@ use time::{Duration, OffsetDateTime, PrimitiveDateTime};
// SQLite does not support array arguments, so we only test this against a real postgres instance
#[gpui::test]
async fn test_get_embeddings_postgres(cx: &mut gpui::TestAppContext) {
- let test_db = TestDb::postgres(cx.executor().clone());
+ let test_db = TestDb::postgres(cx.executor());
let db = test_db.db();
let provider = "test_model";
@@ -38,7 +38,7 @@ async fn test_get_embeddings_postgres(cx: &mut gpui::TestAppContext) {
#[gpui::test]
async fn test_purge_old_embeddings(cx: &mut gpui::TestAppContext) {
- let test_db = TestDb::postgres(cx.executor().clone());
+ let test_db = TestDb::postgres(cx.executor());
let db = test_db.db();
let model = "test_model";
@@ -310,7 +310,7 @@ impl Server {
let mut server = Self {
id: parking_lot::Mutex::new(id),
peer: Peer::new(id.0 as u32),
- app_state: app_state.clone(),
+ app_state,
connection_pool: Default::default(),
handlers: Default::default(),
teardown: watch::channel(false).0,
@@ -1386,9 +1386,7 @@ async fn create_room(
let live_kit = live_kit?;
let user_id = session.user_id().to_string();
- let token = live_kit
- .room_token(&livekit_room, &user_id.to_string())
- .trace_err()?;
+ let token = live_kit.room_token(&livekit_room, &user_id).trace_err()?;
Some(proto::LiveKitConnectionInfo {
server_url: live_kit.url().into(),
@@ -2015,9 +2013,9 @@ async fn join_project(
.unzip();
response.send(proto::JoinProjectResponse {
project_id: project.id.0 as u64,
- worktrees: worktrees.clone(),
+ worktrees,
replica_id: replica_id.0 as u32,
- collaborators: collaborators.clone(),
+ collaborators,
language_servers,
language_server_capabilities,
role: project.role.into(),
@@ -3593,7 +3593,7 @@ async fn test_add_breakpoints(cx_a: &mut TestAppContext, cx_b: &mut TestAppConte
let abs_path = project_a.read_with(cx_a, |project, cx| {
project
.absolute_path(&project_path, cx)
- .map(|path_buf| Arc::from(path_buf.to_owned()))
+ .map(Arc::from)
.unwrap()
});
@@ -3647,20 +3647,16 @@ async fn test_add_breakpoints(cx_a: &mut TestAppContext, cx_b: &mut TestAppConte
let breakpoints_a = editor_a.update(cx_a, |editor, cx| {
editor
.breakpoint_store()
- .clone()
.unwrap()
.read(cx)
.all_source_breakpoints(cx)
- .clone()
});
let breakpoints_b = editor_b.update(cx_b, |editor, cx| {
editor
.breakpoint_store()
- .clone()
.unwrap()
.read(cx)
.all_source_breakpoints(cx)
- .clone()
});
assert_eq!(1, breakpoints_a.len());
@@ -3680,20 +3676,16 @@ async fn test_add_breakpoints(cx_a: &mut TestAppContext, cx_b: &mut TestAppConte
let breakpoints_a = editor_a.update(cx_a, |editor, cx| {
editor
.breakpoint_store()
- .clone()
.unwrap()
.read(cx)
.all_source_breakpoints(cx)
- .clone()
});
let breakpoints_b = editor_b.update(cx_b, |editor, cx| {
editor
.breakpoint_store()
- .clone()
.unwrap()
.read(cx)
.all_source_breakpoints(cx)
- .clone()
});
assert_eq!(1, breakpoints_a.len());
@@ -3713,20 +3705,16 @@ async fn test_add_breakpoints(cx_a: &mut TestAppContext, cx_b: &mut TestAppConte
let breakpoints_a = editor_a.update(cx_a, |editor, cx| {
editor
.breakpoint_store()
- .clone()
.unwrap()
.read(cx)
.all_source_breakpoints(cx)
- .clone()
});
let breakpoints_b = editor_b.update(cx_b, |editor, cx| {
editor
.breakpoint_store()
- .clone()
.unwrap()
.read(cx)
.all_source_breakpoints(cx)
- .clone()
});
assert_eq!(1, breakpoints_a.len());
@@ -3746,20 +3734,16 @@ async fn test_add_breakpoints(cx_a: &mut TestAppContext, cx_b: &mut TestAppConte
let breakpoints_a = editor_a.update(cx_a, |editor, cx| {
editor
.breakpoint_store()
- .clone()
.unwrap()
.read(cx)
.all_source_breakpoints(cx)
- .clone()
});
let breakpoints_b = editor_b.update(cx_b, |editor, cx| {
editor
.breakpoint_store()
- .clone()
.unwrap()
.read(cx)
.all_source_breakpoints(cx)
- .clone()
});
assert_eq!(0, breakpoints_a.len());
@@ -266,7 +266,7 @@ impl RandomizedTest for RandomChannelBufferTest {
"client {user_id} has different text than client {prev_user_id} for channel {channel_name}",
);
} else {
- prev_text = Some((user_id, text.clone()));
+ prev_text = Some((user_id, text));
}
// Assert that all clients and the server agree about who is present in the
@@ -643,7 +643,7 @@ impl RandomizedTest for ProjectCollaborationTest {
);
let project = project.await?;
- client.dev_server_projects_mut().push(project.clone());
+ client.dev_server_projects_mut().push(project);
}
ClientOperation::CreateWorktreeEntry {
@@ -370,8 +370,8 @@ impl TestServer {
let client = TestClient {
app_state,
username: name.to_string(),
- channel_store: cx.read(ChannelStore::global).clone(),
- notification_store: cx.read(NotificationStore::global).clone(),
+ channel_store: cx.read(ChannelStore::global),
+ notification_store: cx.read(NotificationStore::global),
state: Default::default(),
};
client.wait_for_current_user(cx).await;
@@ -66,7 +66,7 @@ impl ChannelView {
channel_id,
link_position,
pane.clone(),
- workspace.clone(),
+ workspace,
window,
cx,
);
@@ -1038,7 +1038,7 @@ impl Render for ChatPanel {
.cloned();
el.when_some(reply_message, |el, reply_message| {
- let user_being_replied_to = reply_message.sender.clone();
+ let user_being_replied_to = reply_message.sender;
el.child(
h_flex()
@@ -2507,7 +2507,7 @@ impl CollabPanel {
let button = match section {
Section::ActiveCall => channel_link.map(|channel_link| {
- let channel_link_copy = channel_link.clone();
+ let channel_link_copy = channel_link;
IconButton::new("channel-link", IconName::Copy)
.icon_size(IconSize::Small)
.size(ButtonSize::None)
@@ -2691,7 +2691,7 @@ impl CollabPanel {
h_flex()
.w_full()
.justify_between()
- .child(Label::new(github_login.clone()))
+ .child(Label::new(github_login))
.child(h_flex().children(controls)),
)
.start_slot(Avatar::new(user.avatar_uri.clone()))
@@ -3125,7 +3125,7 @@ impl Panel for CollabPanel {
impl Focusable for CollabPanel {
fn focus_handle(&self, cx: &App) -> gpui::FocusHandle {
- self.filter_editor.focus_handle(cx).clone()
+ self.filter_editor.focus_handle(cx)
}
}
@@ -289,7 +289,7 @@ impl NotificationPanel {
.gap_1()
.size_full()
.overflow_hidden()
- .child(Label::new(text.clone()))
+ .child(Label::new(text))
.child(
h_flex()
.child(
@@ -206,7 +206,7 @@ impl CommandPaletteDelegate {
if parse_zed_link(&query, cx).is_some() {
intercept_results = vec![CommandInterceptResult {
action: OpenZedUrl { url: query.clone() }.boxed_clone(),
- string: query.clone(),
+ string: query,
positions: vec![],
}]
}
@@ -42,7 +42,7 @@ impl RenderOnce for ComponentExample {
div()
.text_size(rems(0.875))
.text_color(cx.theme().colors().text_muted)
- .child(description.clone()),
+ .child(description),
)
}),
)
@@ -112,7 +112,6 @@ impl McpServer {
annotations: Some(tool.annotations()),
},
handler: Box::new({
- let tool = tool.clone();
move |input_value, cx| {
let input = match input_value {
Some(input) => serde_json::from_value(input),
@@ -81,10 +81,7 @@ pub fn init(
};
copilot_chat::init(fs.clone(), http.clone(), configuration, cx);
- let copilot = cx.new({
- let node_runtime = node_runtime.clone();
- move |cx| Copilot::start(new_server_id, fs, node_runtime, cx)
- });
+ let copilot = cx.new(move |cx| Copilot::start(new_server_id, fs, node_runtime, cx));
Copilot::set_global(copilot.clone(), cx);
cx.observe(&copilot, |copilot, cx| {
copilot.update(cx, |copilot, cx| copilot.update_action_visibilities(cx));
@@ -1083,7 +1083,7 @@ mod tests {
let replace_range_marker: TextRangeMarker = ('<', '>').into();
let (_, mut marked_ranges) = marked_text_ranges_by(
marked_string,
- vec![complete_from_marker.clone(), replace_range_marker.clone()],
+ vec![complete_from_marker, replace_range_marker.clone()],
);
let replace_range =
@@ -664,7 +664,7 @@ impl ToolbarItemView for DapLogToolbarItemView {
if let Some(item) = active_pane_item
&& let Some(log_view) = item.downcast::<DapLogView>()
{
- self.log_view = Some(log_view.clone());
+ self.log_view = Some(log_view);
return workspace::ToolbarItemLocation::PrimaryLeft;
}
self.log_view = None;
@@ -386,10 +386,10 @@ impl DebugPanel {
return;
};
- let dap_store_handle = self.project.read(cx).dap_store().clone();
+ let dap_store_handle = self.project.read(cx).dap_store();
let label = curr_session.read(cx).label();
let quirks = curr_session.read(cx).quirks();
- let adapter = curr_session.read(cx).adapter().clone();
+ let adapter = curr_session.read(cx).adapter();
let binary = curr_session.read(cx).binary().cloned().unwrap();
let task_context = curr_session.read(cx).task_context().clone();
@@ -447,9 +447,9 @@ impl DebugPanel {
return;
};
- let dap_store_handle = self.project.read(cx).dap_store().clone();
+ let dap_store_handle = self.project.read(cx).dap_store();
let label = self.label_for_child_session(&parent_session, request, cx);
- let adapter = parent_session.read(cx).adapter().clone();
+ let adapter = parent_session.read(cx).adapter();
let quirks = parent_session.read(cx).quirks();
let Some(mut binary) = parent_session.read(cx).binary().cloned() else {
log::error!("Attempted to start a child-session without a binary");
@@ -932,7 +932,6 @@ impl DebugPanel {
.cloned(),
|this, running_state| {
this.children({
- let running_state = running_state.clone();
let threads =
running_state.update(cx, |running_state, cx| {
let session = running_state.session();
@@ -1645,7 +1644,6 @@ impl Render for DebugPanel {
}
})
.on_action({
- let this = this.clone();
move |_: &ToggleSessionPicker, window, cx| {
this.update(cx, |this, cx| {
this.toggle_session_picker(window, cx);
@@ -272,7 +272,6 @@ pub fn init(cx: &mut App) {
}
})
.on_action({
- let active_item = active_item.clone();
move |_: &ToggleIgnoreBreakpoints, _, cx| {
active_item
.update(cx, |item, cx| item.toggle_ignore_breakpoints(cx))
@@ -293,9 +292,8 @@ pub fn init(cx: &mut App) {
let Some(debug_panel) = workspace.read(cx).panel::<DebugPanel>(cx) else {
return;
};
- let Some(active_session) = debug_panel
- .clone()
- .update(cx, |panel, _| panel.active_session())
+ let Some(active_session) =
+ debug_panel.update(cx, |panel, _| panel.active_session())
else {
return;
};
@@ -272,10 +272,9 @@ impl DebugPanel {
.child(session_entry.label_element(self_depth, cx))
.child(
IconButton::new("close-debug-session", IconName::Close)
- .visible_on_hover(id.clone())
+ .visible_on_hover(id)
.icon_size(IconSize::Small)
.on_click({
- let weak = weak.clone();
move |_, window, cx| {
weak.update(cx, |panel, cx| {
panel.close_session(session_entity_id, window, cx);
@@ -785,7 +785,7 @@ impl RenderOnce for AttachMode {
v_flex()
.w_full()
.track_focus(&self.attach_picker.focus_handle(cx))
- .child(self.attach_picker.clone())
+ .child(self.attach_picker)
}
}
@@ -256,7 +256,7 @@ pub(crate) fn deserialize_pane_layout(
Some(Member::Axis(PaneAxis::load(
if should_invert { axis.invert() } else { axis },
members,
- flexes.clone(),
+ flexes,
)))
}
SerializedPaneLayout::Pane(serialized_pane) => {
@@ -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());
@@ -1330,7 +1330,6 @@ async fn test_unsetting_breakpoints_on_clear_breakpoint_action(
let called_set_breakpoints = Arc::new(AtomicBool::new(false));
client.on_request::<SetBreakpoints, _>({
- let called_set_breakpoints = called_set_breakpoints.clone();
move |_, args| {
assert!(
args.breakpoints.is_none_or(|bps| bps.is_empty()),
@@ -1445,7 +1444,6 @@ async fn test_we_send_arguments_from_user_config(
let launch_handler_called = Arc::new(AtomicBool::new(false));
start_debug_session_with(&workspace, cx, debug_definition.clone(), {
- let debug_definition = debug_definition.clone();
let launch_handler_called = launch_handler_called.clone();
move |client| {
@@ -1783,9 +1781,8 @@ async fn test_debug_adapters_shutdown_on_app_quit(
let disconnect_request_received = Arc::new(AtomicBool::new(false));
let disconnect_clone = disconnect_request_received.clone();
- let disconnect_clone_for_handler = disconnect_clone.clone();
client.on_request::<Disconnect, _>(move |_, _| {
- disconnect_clone_for_handler.store(true, Ordering::SeqCst);
+ disconnect_clone.store(true, Ordering::SeqCst);
Ok(())
});
@@ -106,9 +106,7 @@ async fn test_debug_session_substitutes_variables_and_relativizes_paths(
);
let expected_other_field = if input_path.contains("$ZED_WORKTREE_ROOT") {
- input_path
- .replace("$ZED_WORKTREE_ROOT", path!("/test/worktree/path"))
- .to_owned()
+ input_path.replace("$ZED_WORKTREE_ROOT", path!("/test/worktree/path"))
} else {
input_path.to_string()
};
@@ -61,15 +61,13 @@ impl PreprocessorError {
for alias in action.deprecated_aliases {
if alias == &action_name {
return PreprocessorError::DeprecatedActionUsed {
- used: action_name.clone(),
+ used: action_name,
should_be: action.name.to_string(),
};
}
}
}
- PreprocessorError::ActionNotFound {
- action_name: action_name.to_string(),
- }
+ PreprocessorError::ActionNotFound { action_name }
}
}
@@ -168,7 +168,7 @@ impl Render for EditPredictionButton {
let account_status = agent.account_status.clone();
match account_status {
AccountStatus::NeedsActivation { activate_url } => {
- SupermavenButtonStatus::NeedsActivation(activate_url.clone())
+ SupermavenButtonStatus::NeedsActivation(activate_url)
}
AccountStatus::Unknown => SupermavenButtonStatus::Initializing,
AccountStatus::Ready => SupermavenButtonStatus::Ready,
@@ -514,7 +514,7 @@ impl CompletionsMenu {
// Expand the range to resolve more completions than are predicted to be visible, to reduce
// jank on navigation.
let entry_indices = util::expanded_and_wrapped_usize_range(
- entry_range.clone(),
+ entry_range,
RESOLVE_BEFORE_ITEMS,
RESOLVE_AFTER_ITEMS,
entries.len(),
@@ -2156,7 +2156,7 @@ mod tests {
}
let multi_buffer_snapshot = multi_buffer.read(cx).snapshot(cx);
- let (_, inlay_snapshot) = InlayMap::new(multi_buffer_snapshot.clone());
+ let (_, inlay_snapshot) = InlayMap::new(multi_buffer_snapshot);
let (_, fold_snapshot) = FoldMap::new(inlay_snapshot);
let (_, tab_snapshot) = TabMap::new(fold_snapshot, 4.try_into().unwrap());
let (_, wraps_snapshot) = WrapMap::new(tab_snapshot, font, font_size, Some(wrap_width), cx);
@@ -2275,7 +2275,7 @@ mod tests {
new_heights.insert(block_ids[0], 3);
block_map_writer.resize(new_heights);
- let snapshot = block_map.read(wraps_snapshot.clone(), Default::default());
+ let snapshot = block_map.read(wraps_snapshot, Default::default());
// Same height as before, should remain the same
assert_eq!(snapshot.text(), "aaa\n\n\n\n\n\nbbb\nccc\nddd\n\n\n");
}
@@ -2360,16 +2360,14 @@ mod tests {
buffer.edit([(Point::new(2, 0)..Point::new(3, 0), "")], None, cx);
buffer.snapshot(cx)
});
- let (inlay_snapshot, inlay_edits) = inlay_map.sync(
- buffer_snapshot.clone(),
- buffer_subscription.consume().into_inner(),
- );
+ let (inlay_snapshot, inlay_edits) =
+ inlay_map.sync(buffer_snapshot, buffer_subscription.consume().into_inner());
let (fold_snapshot, fold_edits) = fold_map.read(inlay_snapshot, inlay_edits);
let (tab_snapshot, tab_edits) = tab_map.sync(fold_snapshot, fold_edits, tab_size);
let (wraps_snapshot, wrap_edits) = wrap_map.update(cx, |wrap_map, cx| {
wrap_map.sync(tab_snapshot, tab_edits, cx)
});
- let blocks_snapshot = block_map.read(wraps_snapshot.clone(), wrap_edits);
+ let blocks_snapshot = block_map.read(wraps_snapshot, wrap_edits);
assert_eq!(blocks_snapshot.text(), "line1\n\n\n\n\nline5");
let buffer_snapshot = buffer.update(cx, |buffer, cx| {
@@ -2454,7 +2452,7 @@ mod tests {
// Removing the replace block shows all the hidden blocks again.
let mut writer = block_map.write(wraps_snapshot.clone(), Default::default());
writer.remove(HashSet::from_iter([replace_block_id]));
- let blocks_snapshot = block_map.read(wraps_snapshot.clone(), Default::default());
+ let blocks_snapshot = block_map.read(wraps_snapshot, Default::default());
assert_eq!(
blocks_snapshot.text(),
"\nline1\n\nline2\n\n\nline 2.1\nline2.2\nline 2.3\nline 2.4\n\nline4\n\nline5"
@@ -2793,7 +2791,7 @@ mod tests {
buffer.read_with(cx, |buffer, cx| {
writer.fold_buffers([buffer_id_3], buffer, cx);
});
- let blocks_snapshot = block_map.read(wrap_snapshot.clone(), Patch::default());
+ let blocks_snapshot = block_map.read(wrap_snapshot, Patch::default());
let blocks = blocks_snapshot
.blocks_in_range(0..u32::MAX)
.collect::<Vec<_>>();
@@ -2846,7 +2844,7 @@ mod tests {
assert_eq!(buffer_ids.len(), 1);
let buffer_id = buffer_ids[0];
- let (_, inlay_snapshot) = InlayMap::new(buffer_snapshot.clone());
+ let (_, inlay_snapshot) = InlayMap::new(buffer_snapshot);
let (_, fold_snapshot) = FoldMap::new(inlay_snapshot);
let (_, tab_snapshot) = TabMap::new(fold_snapshot, 4.try_into().unwrap());
let (_, wrap_snapshot) =
@@ -2860,7 +2858,7 @@ mod tests {
buffer.read_with(cx, |buffer, cx| {
writer.fold_buffers([buffer_id], buffer, cx);
});
- let blocks_snapshot = block_map.read(wrap_snapshot.clone(), Patch::default());
+ let blocks_snapshot = block_map.read(wrap_snapshot, Patch::default());
let blocks = blocks_snapshot
.blocks_in_range(0..u32::MAX)
.collect::<Vec<_>>();
@@ -3527,7 +3525,7 @@ mod tests {
..buffer_snapshot.anchor_after(Point::new(1, 0))],
false,
);
- let blocks_snapshot = block_map.read(wraps_snapshot.clone(), Default::default());
+ let blocks_snapshot = block_map.read(wraps_snapshot, Default::default());
assert_eq!(blocks_snapshot.text(), "abc\n\ndef\nghi\njkl\nmno");
}
@@ -1557,7 +1557,7 @@ mod tests {
let buffer = MultiBuffer::build_simple(&sample_text(5, 6, 'a'), cx);
let subscription = buffer.update(cx, |buffer, _| buffer.subscribe());
let buffer_snapshot = buffer.read(cx).snapshot(cx);
- let (mut inlay_map, inlay_snapshot) = InlayMap::new(buffer_snapshot.clone());
+ let (mut inlay_map, inlay_snapshot) = InlayMap::new(buffer_snapshot);
let mut map = FoldMap::new(inlay_snapshot.clone()).0;
let (mut writer, _, _) = map.write(inlay_snapshot, vec![]);
@@ -1636,7 +1636,7 @@ mod tests {
let buffer = MultiBuffer::build_simple("abcdefghijkl", cx);
let subscription = buffer.update(cx, |buffer, _| buffer.subscribe());
let buffer_snapshot = buffer.read(cx).snapshot(cx);
- let (mut inlay_map, inlay_snapshot) = InlayMap::new(buffer_snapshot.clone());
+ let (mut inlay_map, inlay_snapshot) = InlayMap::new(buffer_snapshot);
{
let mut map = FoldMap::new(inlay_snapshot.clone()).0;
@@ -1712,7 +1712,7 @@ mod tests {
let buffer = MultiBuffer::build_simple(&sample_text(5, 6, 'a'), cx);
let subscription = buffer.update(cx, |buffer, _| buffer.subscribe());
let buffer_snapshot = buffer.read(cx).snapshot(cx);
- let (mut inlay_map, inlay_snapshot) = InlayMap::new(buffer_snapshot.clone());
+ let (mut inlay_map, inlay_snapshot) = InlayMap::new(buffer_snapshot);
let mut map = FoldMap::new(inlay_snapshot.clone()).0;
let (mut writer, _, _) = map.write(inlay_snapshot.clone(), vec![]);
@@ -1720,7 +1720,7 @@ mod tests {
(Point::new(0, 2)..Point::new(2, 2), FoldPlaceholder::test()),
(Point::new(3, 1)..Point::new(4, 1), FoldPlaceholder::test()),
]);
- let (snapshot, _) = map.read(inlay_snapshot.clone(), vec![]);
+ let (snapshot, _) = map.read(inlay_snapshot, vec![]);
assert_eq!(snapshot.text(), "aa⋯cccc\nd⋯eeeee");
let buffer_snapshot = buffer.update(cx, |buffer, cx| {
@@ -1747,7 +1747,7 @@ mod tests {
(Point::new(1, 2)..Point::new(3, 2), FoldPlaceholder::test()),
(Point::new(3, 1)..Point::new(4, 1), FoldPlaceholder::test()),
]);
- let (snapshot, _) = map.read(inlay_snapshot.clone(), vec![]);
+ let (snapshot, _) = map.read(inlay_snapshot, vec![]);
let fold_ranges = snapshot
.folds_in_range(Point::new(1, 0)..Point::new(1, 3))
.map(|fold| {
@@ -1782,7 +1782,7 @@ mod tests {
let (mut inlay_map, inlay_snapshot) = InlayMap::new(buffer_snapshot.clone());
let mut map = FoldMap::new(inlay_snapshot.clone()).0;
- let (mut initial_snapshot, _) = map.read(inlay_snapshot.clone(), vec![]);
+ let (mut initial_snapshot, _) = map.read(inlay_snapshot, vec![]);
let mut snapshot_edits = Vec::new();
let mut next_inlay_id = 0;
@@ -116,7 +116,7 @@ impl TabMap {
state.new.end = edit.new.end;
Some(None) // Skip this edit, it's merged
} else {
- let new_state = edit.clone();
+ let new_state = edit;
let result = Some(Some(state.clone())); // Yield the previous edit
**state = new_state;
result
@@ -611,7 +611,7 @@ mod tests {
fn test_expand_tabs(cx: &mut gpui::App) {
let buffer = MultiBuffer::build_simple("", cx);
let buffer_snapshot = buffer.read(cx).snapshot(cx);
- let (_, inlay_snapshot) = InlayMap::new(buffer_snapshot.clone());
+ let (_, inlay_snapshot) = InlayMap::new(buffer_snapshot);
let (_, fold_snapshot) = FoldMap::new(inlay_snapshot);
let (_, tab_snapshot) = TabMap::new(fold_snapshot, 4.try_into().unwrap());
@@ -628,7 +628,7 @@ mod tests {
let buffer = MultiBuffer::build_simple(input, cx);
let buffer_snapshot = buffer.read(cx).snapshot(cx);
- let (_, inlay_snapshot) = InlayMap::new(buffer_snapshot.clone());
+ let (_, inlay_snapshot) = InlayMap::new(buffer_snapshot);
let (_, fold_snapshot) = FoldMap::new(inlay_snapshot);
let (_, mut tab_snapshot) = TabMap::new(fold_snapshot, 4.try_into().unwrap());
@@ -675,7 +675,7 @@ mod tests {
let buffer = MultiBuffer::build_simple(input, cx);
let buffer_snapshot = buffer.read(cx).snapshot(cx);
- let (_, inlay_snapshot) = InlayMap::new(buffer_snapshot.clone());
+ let (_, inlay_snapshot) = InlayMap::new(buffer_snapshot);
let (_, fold_snapshot) = FoldMap::new(inlay_snapshot);
let (_, mut tab_snapshot) = TabMap::new(fold_snapshot, 4.try_into().unwrap());
@@ -689,7 +689,7 @@ mod tests {
let buffer = MultiBuffer::build_simple(input, cx);
let buffer_snapshot = buffer.read(cx).snapshot(cx);
- let (_, inlay_snapshot) = InlayMap::new(buffer_snapshot.clone());
+ let (_, inlay_snapshot) = InlayMap::new(buffer_snapshot);
let (_, fold_snapshot) = FoldMap::new(inlay_snapshot);
let (_, tab_snapshot) = TabMap::new(fold_snapshot, 4.try_into().unwrap());
@@ -749,7 +749,7 @@ mod tests {
let buffer_snapshot = buffer.read(cx).snapshot(cx);
log::info!("Buffer text: {:?}", buffer_snapshot.text());
- let (mut inlay_map, inlay_snapshot) = InlayMap::new(buffer_snapshot.clone());
+ let (mut inlay_map, inlay_snapshot) = InlayMap::new(buffer_snapshot);
log::info!("InlayMap text: {:?}", inlay_snapshot.text());
let (mut fold_map, _) = FoldMap::new(inlay_snapshot.clone());
fold_map.randomly_mutate(&mut rng);
@@ -758,7 +758,7 @@ mod tests {
let (inlay_snapshot, _) = inlay_map.randomly_mutate(&mut 0, &mut rng);
log::info!("InlayMap text: {:?}", inlay_snapshot.text());
- let (mut tab_map, _) = TabMap::new(fold_snapshot.clone(), tab_size);
+ let (mut tab_map, _) = TabMap::new(fold_snapshot, tab_size);
let tabs_snapshot = tab_map.set_max_expansion_column(32);
let text = text::Rope::from(tabs_snapshot.text().as_str());
@@ -4528,7 +4528,7 @@ impl Editor {
let mut char_position = 0u32;
let mut end_tag_offset = None;
- 'outer: for chunk in snapshot.text_for_range(range.clone()) {
+ 'outer: for chunk in snapshot.text_for_range(range) {
if let Some(byte_pos) = chunk.find(&**end_tag) {
let chars_before_match =
chunk[..byte_pos].chars().count() as u32;
@@ -4881,7 +4881,7 @@ impl Editor {
let multibuffer = self.buffer.read(cx);
let Some(buffer) = position
.buffer_id
- .and_then(|buffer_id| multibuffer.buffer(buffer_id).clone())
+ .and_then(|buffer_id| multibuffer.buffer(buffer_id))
else {
return false;
};
@@ -6269,7 +6269,7 @@ impl Editor {
}))
}
CodeActionsItem::DebugScenario(scenario) => {
- let context = actions_menu.actions.context.clone();
+ let context = actions_menu.actions.context;
workspace.update(cx, |workspace, cx| {
dap::send_telemetry(&scenario, TelemetrySpawnLocation::Gutter, cx);
@@ -6469,7 +6469,7 @@ impl Editor {
fn refresh_code_actions(&mut self, window: &mut Window, cx: &mut Context<Self>) -> Option<()> {
let newest_selection = self.selections.newest_anchor().clone();
- let newest_selection_adjusted = self.selections.newest_adjusted(cx).clone();
+ let newest_selection_adjusted = self.selections.newest_adjusted(cx);
let buffer = self.buffer.read(cx);
if newest_selection.head().diff_base_anchor.is_some() {
return None;
@@ -8188,8 +8188,6 @@ impl Editor {
.icon_color(color)
.style(ButtonStyle::Transparent)
.on_click(cx.listener({
- let breakpoint = breakpoint.clone();
-
move |editor, event: &ClickEvent, window, cx| {
let edit_action = if event.modifiers().platform || breakpoint.is_disabled() {
BreakpointEditAction::InvertState
@@ -14837,7 +14835,7 @@ impl Editor {
if parent == child {
return None;
}
- let text = buffer.text_for_range(child.clone()).collect::<String>();
+ let text = buffer.text_for_range(child).collect::<String>();
Some((selection.id, parent, text))
})
.collect::<Vec<_>>();
@@ -15940,7 +15938,7 @@ impl Editor {
if !split
&& Some(&target.buffer) == editor.buffer.read(cx).as_singleton().as_ref()
{
- editor.go_to_singleton_buffer_range(range.clone(), window, cx);
+ editor.go_to_singleton_buffer_range(range, window, cx);
} else {
window.defer(cx, move |window, cx| {
let target_editor: Entity<Self> =
@@ -16198,14 +16196,14 @@ impl Editor {
let item_id = item.item_id();
if split {
- workspace.split_item(SplitDirection::Right, item.clone(), window, cx);
+ workspace.split_item(SplitDirection::Right, item, window, cx);
} else if PreviewTabsSettings::get_global(cx).enable_preview_from_code_navigation {
let (preview_item_id, preview_item_idx) =
workspace.active_pane().read_with(cx, |pane, _| {
(pane.preview_item_id(), pane.preview_item_idx())
});
- workspace.add_item_to_active_pane(item.clone(), preview_item_idx, true, window, cx);
+ workspace.add_item_to_active_pane(item, preview_item_idx, true, window, cx);
if let Some(preview_item_id) = preview_item_id {
workspace.active_pane().update(cx, |pane, cx| {
@@ -16213,7 +16211,7 @@ impl Editor {
});
}
} else {
- workspace.add_item_to_active_pane(item.clone(), None, true, window, cx);
+ workspace.add_item_to_active_pane(item, None, true, window, cx);
}
workspace.active_pane().update(cx, |pane, cx| {
pane.set_preview_item_id(Some(item_id), cx);
@@ -19004,10 +19002,7 @@ impl Editor {
let selection = text::ToPoint::to_point(&range.start, buffer).row
..text::ToPoint::to_point(&range.end, buffer).row;
- Some((
- multi_buffer.buffer(buffer.remote_id()).unwrap().clone(),
- selection,
- ))
+ Some((multi_buffer.buffer(buffer.remote_id()).unwrap(), selection))
});
let Some((buffer, selection)) = buffer_and_selection else {
@@ -19249,7 +19244,7 @@ impl Editor {
row_highlights.insert(
ix,
RowHighlight {
- range: range.clone(),
+ range,
index,
color,
options,
@@ -21676,7 +21671,7 @@ fn wrap_with_prefix(
let subsequent_lines_prefix_len =
char_len_with_expanded_tabs(0, &subsequent_lines_prefix, tab_size);
let mut wrapped_text = String::new();
- let mut current_line = first_line_prefix.clone();
+ let mut current_line = first_line_prefix;
let mut is_first_line = true;
let tokenizer = WordBreakingTokenizer::new(&unwrapped_text);
@@ -88,7 +88,7 @@ impl RenderOnce for BufferFontFamilyControl {
.child(Icon::new(IconName::Font))
.child(DropdownMenu::new(
"buffer-font-family",
- value.clone(),
+ value,
ContextMenu::build(window, cx, |mut menu, _, cx| {
let font_family_cache = FontFamilyCache::global(cx);
@@ -708,7 +708,7 @@ async fn test_navigation_history(cx: &mut TestAppContext) {
_ = workspace.update(cx, |_v, window, cx| {
cx.new(|cx| {
let buffer = MultiBuffer::build_simple(&sample_text(300, 5, 'a'), cx);
- let mut editor = build_editor(buffer.clone(), window, cx);
+ let mut editor = build_editor(buffer, window, cx);
let handle = cx.entity();
editor.set_nav_history(Some(pane.read(cx).nav_history_for_item(&handle)));
@@ -898,7 +898,7 @@ fn test_fold_action(cx: &mut TestAppContext) {
.unindent(),
cx,
);
- build_editor(buffer.clone(), window, cx)
+ build_editor(buffer, window, cx)
});
_ = editor.update(cx, |editor, window, cx| {
@@ -989,7 +989,7 @@ fn test_fold_action_whitespace_sensitive_language(cx: &mut TestAppContext) {
.unindent(),
cx,
);
- build_editor(buffer.clone(), window, cx)
+ build_editor(buffer, window, cx)
});
_ = editor.update(cx, |editor, window, cx| {
@@ -1074,7 +1074,7 @@ fn test_fold_action_multiple_line_breaks(cx: &mut TestAppContext) {
.unindent(),
cx,
);
- build_editor(buffer.clone(), window, cx)
+ build_editor(buffer, window, cx)
});
_ = editor.update(cx, |editor, window, cx| {
@@ -1173,7 +1173,7 @@ fn test_fold_at_level(cx: &mut TestAppContext) {
.unindent(),
cx,
);
- build_editor(buffer.clone(), window, cx)
+ build_editor(buffer, window, cx)
});
_ = editor.update(cx, |editor, window, cx| {
@@ -1335,7 +1335,7 @@ fn test_move_cursor_multibyte(cx: &mut TestAppContext) {
let editor = cx.add_window(|window, cx| {
let buffer = MultiBuffer::build_simple("🟥🟧🟨🟩🟦🟪\nabcde\nαβγδε", cx);
- build_editor(buffer.clone(), window, cx)
+ build_editor(buffer, window, cx)
});
assert_eq!('🟥'.len_utf8(), 4);
@@ -1452,7 +1452,7 @@ fn test_move_cursor_different_line_lengths(cx: &mut TestAppContext) {
let editor = cx.add_window(|window, cx| {
let buffer = MultiBuffer::build_simple("ⓐⓑⓒⓓⓔ\nabcd\nαβγ\nabcd\nⓐⓑⓒⓓⓔ\n", cx);
- build_editor(buffer.clone(), window, cx)
+ build_editor(buffer, window, cx)
});
_ = editor.update(cx, |editor, window, cx| {
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
@@ -2479,7 +2479,7 @@ fn test_delete_to_word_boundary(cx: &mut TestAppContext) {
let editor = cx.add_window(|window, cx| {
let buffer = MultiBuffer::build_simple("one two three four", cx);
- build_editor(buffer.clone(), window, cx)
+ build_editor(buffer, window, cx)
});
_ = editor.update(cx, |editor, window, cx| {
@@ -2527,7 +2527,7 @@ fn test_delete_to_previous_word_start_or_newline(cx: &mut TestAppContext) {
let editor = cx.add_window(|window, cx| {
let buffer = MultiBuffer::build_simple("one\n2\nthree\n4", cx);
- build_editor(buffer.clone(), window, cx)
+ build_editor(buffer, window, cx)
});
let del_to_prev_word_start = DeleteToPreviousWordStart {
ignore_newlines: false,
@@ -2563,7 +2563,7 @@ fn test_delete_to_next_word_end_or_newline(cx: &mut TestAppContext) {
let editor = cx.add_window(|window, cx| {
let buffer = MultiBuffer::build_simple("\none\n two\nthree\n four", cx);
- build_editor(buffer.clone(), window, cx)
+ build_editor(buffer, window, cx)
});
let del_to_next_word_end = DeleteToNextWordEnd {
ignore_newlines: false,
@@ -2608,7 +2608,7 @@ fn test_newline(cx: &mut TestAppContext) {
let editor = cx.add_window(|window, cx| {
let buffer = MultiBuffer::build_simple("aaaa\n bbbb\n", cx);
- build_editor(buffer.clone(), window, cx)
+ build_editor(buffer, window, cx)
});
_ = editor.update(cx, |editor, window, cx| {
@@ -2644,7 +2644,7 @@ fn test_newline_with_old_selections(cx: &mut TestAppContext) {
.as_str(),
cx,
);
- let mut editor = build_editor(buffer.clone(), window, cx);
+ let mut editor = build_editor(buffer, window, cx);
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
s.select_ranges([
Point::new(2, 4)..Point::new(2, 5),
@@ -3175,7 +3175,7 @@ fn test_insert_with_old_selections(cx: &mut TestAppContext) {
let editor = cx.add_window(|window, cx| {
let buffer = MultiBuffer::build_simple("a( X ), b( Y ), c( Z )", cx);
- let mut editor = build_editor(buffer.clone(), window, cx);
+ let mut editor = build_editor(buffer, window, cx);
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
s.select_ranges([3..4, 11..12, 19..20])
});
@@ -5562,7 +5562,7 @@ async fn test_rewrap(cx: &mut TestAppContext) {
# ˇThis is a long comment using a pound
# sign.
"},
- python_language.clone(),
+ python_language,
&mut cx,
);
@@ -5669,7 +5669,7 @@ async fn test_rewrap(cx: &mut TestAppContext) {
also very long and should not merge
with the numbered item.ˇ»
"},
- markdown_language.clone(),
+ markdown_language,
&mut cx,
);
@@ -5700,7 +5700,7 @@ async fn test_rewrap(cx: &mut TestAppContext) {
// This is the second long comment block
// to be wrapped.ˇ»
"},
- rust_language.clone(),
+ rust_language,
&mut cx,
);
@@ -5723,7 +5723,7 @@ async fn test_rewrap(cx: &mut TestAppContext) {
«\tThis is a very long indented line
\tthat will be wrapped.ˇ»
"},
- plaintext_language.clone(),
+ plaintext_language,
&mut cx,
);
@@ -8889,7 +8889,7 @@ async fn test_autoclose_with_embedded_language(cx: &mut TestAppContext) {
));
cx.language_registry().add(html_language.clone());
- cx.language_registry().add(javascript_language.clone());
+ cx.language_registry().add(javascript_language);
cx.executor().run_until_parked();
cx.update_buffer(|buffer, cx| {
@@ -9633,7 +9633,7 @@ async fn test_snippets(cx: &mut TestAppContext) {
.selections
.all(cx)
.iter()
- .map(|s| s.range().clone())
+ .map(|s| s.range())
.collect::<Vec<_>>();
editor
.insert_snippet(&insertion_ranges, snippet, window, cx)
@@ -9713,7 +9713,7 @@ async fn test_snippet_indentation(cx: &mut TestAppContext) {
.selections
.all(cx)
.iter()
- .map(|s| s.range().clone())
+ .map(|s| s.range())
.collect::<Vec<_>>();
editor
.insert_snippet(&insertion_ranges, snippet, window, cx)
@@ -10782,7 +10782,7 @@ async fn test_multiple_formatters(cx: &mut TestAppContext) {
kind: Some("code-action-2".into()),
edit: Some(lsp::WorkspaceEdit::new(
[(
- uri.clone(),
+ uri,
vec![lsp::TextEdit::new(
lsp::Range::new(lsp::Position::new(0, 0), lsp::Position::new(0, 0)),
"applied-code-action-2-edit\n".to_string(),
@@ -14366,7 +14366,7 @@ async fn test_toggle_block_comment(cx: &mut TestAppContext) {
));
cx.language_registry().add(html_language.clone());
- cx.language_registry().add(javascript_language.clone());
+ cx.language_registry().add(javascript_language);
cx.update_buffer(|buffer, cx| {
buffer.set_language(Some(html_language), cx);
});
@@ -14543,7 +14543,7 @@ fn test_editing_overlapping_excerpts(cx: &mut TestAppContext) {
);
let excerpt_ranges = markers.into_iter().map(|marker| {
let context = excerpt_ranges.remove(&marker).unwrap()[0].clone();
- ExcerptRange::new(context.clone())
+ ExcerptRange::new(context)
});
let buffer = cx.new(|cx| Buffer::local(initial_text, cx));
let multibuffer = cx.new(|cx| {
@@ -14828,7 +14828,7 @@ fn test_highlighted_ranges(cx: &mut TestAppContext) {
let editor = cx.add_window(|window, cx| {
let buffer = MultiBuffer::build_simple(&sample_text(16, 8, 'a'), cx);
- build_editor(buffer.clone(), window, cx)
+ build_editor(buffer, window, cx)
});
_ = editor.update(cx, |editor, window, cx| {
@@ -15750,8 +15750,7 @@ async fn test_on_type_formatting_is_applied_after_autoindent(cx: &mut TestAppCon
cx.simulate_keystroke("\n");
cx.run_until_parked();
- let buffer_cloned =
- cx.multibuffer(|multi_buffer, _| multi_buffer.as_singleton().unwrap().clone());
+ let buffer_cloned = cx.multibuffer(|multi_buffer, _| multi_buffer.as_singleton().unwrap());
let mut request =
cx.set_request_handler::<lsp::request::OnTypeFormatting, _, _>(move |_, _, mut cx| {
let buffer_cloned = buffer_cloned.clone();
@@ -19455,7 +19454,7 @@ async fn test_adjacent_diff_hunks(executor: BackgroundExecutor, cx: &mut TestApp
let buffer_id = hunks[0].buffer_id;
hunks
.into_iter()
- .map(|hunk| Anchor::range_in_buffer(excerpt_id, buffer_id, hunk.buffer_range.clone()))
+ .map(|hunk| Anchor::range_in_buffer(excerpt_id, buffer_id, hunk.buffer_range))
.collect::<Vec<_>>()
});
assert_eq!(hunk_ranges.len(), 2);
@@ -19546,7 +19545,7 @@ async fn test_adjacent_diff_hunks(executor: BackgroundExecutor, cx: &mut TestApp
let buffer_id = hunks[0].buffer_id;
hunks
.into_iter()
- .map(|hunk| Anchor::range_in_buffer(excerpt_id, buffer_id, hunk.buffer_range.clone()))
+ .map(|hunk| Anchor::range_in_buffer(excerpt_id, buffer_id, hunk.buffer_range))
.collect::<Vec<_>>()
});
assert_eq!(hunk_ranges.len(), 2);
@@ -19612,7 +19611,7 @@ async fn test_toggle_deletion_hunk_at_start_of_file(
let buffer_id = hunks[0].buffer_id;
hunks
.into_iter()
- .map(|hunk| Anchor::range_in_buffer(excerpt_id, buffer_id, hunk.buffer_range.clone()))
+ .map(|hunk| Anchor::range_in_buffer(excerpt_id, buffer_id, hunk.buffer_range))
.collect::<Vec<_>>()
});
assert_eq!(hunk_ranges.len(), 1);
@@ -19635,7 +19634,7 @@ async fn test_toggle_deletion_hunk_at_start_of_file(
});
executor.run_until_parked();
- cx.assert_state_with_diff(hunk_expanded.clone());
+ cx.assert_state_with_diff(hunk_expanded);
}
#[gpui::test]
@@ -21150,7 +21149,7 @@ async fn test_breakpoint_toggling(cx: &mut TestAppContext) {
let abs_path = project.read_with(cx, |project, cx| {
project
.absolute_path(&project_path, cx)
- .map(|path_buf| Arc::from(path_buf.to_owned()))
+ .map(Arc::from)
.unwrap()
});
@@ -21168,7 +21167,6 @@ async fn test_breakpoint_toggling(cx: &mut TestAppContext) {
.unwrap()
.read(cx)
.all_source_breakpoints(cx)
- .clone()
});
assert_eq!(1, breakpoints.len());
@@ -21193,7 +21191,6 @@ async fn test_breakpoint_toggling(cx: &mut TestAppContext) {
.unwrap()
.read(cx)
.all_source_breakpoints(cx)
- .clone()
});
assert_eq!(1, breakpoints.len());
@@ -21215,7 +21212,6 @@ async fn test_breakpoint_toggling(cx: &mut TestAppContext) {
.unwrap()
.read(cx)
.all_source_breakpoints(cx)
- .clone()
});
assert_eq!(0, breakpoints.len());
@@ -21267,7 +21263,7 @@ async fn test_log_breakpoint_editing(cx: &mut TestAppContext) {
let abs_path = project.read_with(cx, |project, cx| {
project
.absolute_path(&project_path, cx)
- .map(|path_buf| Arc::from(path_buf.to_owned()))
+ .map(Arc::from)
.unwrap()
});
@@ -21282,7 +21278,6 @@ async fn test_log_breakpoint_editing(cx: &mut TestAppContext) {
.unwrap()
.read(cx)
.all_source_breakpoints(cx)
- .clone()
});
assert_breakpoint(
@@ -21303,7 +21298,6 @@ async fn test_log_breakpoint_editing(cx: &mut TestAppContext) {
.unwrap()
.read(cx)
.all_source_breakpoints(cx)
- .clone()
});
assert_breakpoint(&breakpoints, &abs_path, vec![]);
@@ -21323,7 +21317,6 @@ async fn test_log_breakpoint_editing(cx: &mut TestAppContext) {
.unwrap()
.read(cx)
.all_source_breakpoints(cx)
- .clone()
});
assert_breakpoint(
@@ -21346,7 +21339,6 @@ async fn test_log_breakpoint_editing(cx: &mut TestAppContext) {
.unwrap()
.read(cx)
.all_source_breakpoints(cx)
- .clone()
});
assert_breakpoint(
@@ -21369,7 +21361,6 @@ async fn test_log_breakpoint_editing(cx: &mut TestAppContext) {
.unwrap()
.read(cx)
.all_source_breakpoints(cx)
- .clone()
});
assert_breakpoint(
@@ -21442,7 +21433,7 @@ async fn test_breakpoint_enabling_and_disabling(cx: &mut TestAppContext) {
let abs_path = project.read_with(cx, |project, cx| {
project
.absolute_path(&project_path, cx)
- .map(|path_buf| Arc::from(path_buf.to_owned()))
+ .map(Arc::from)
.unwrap()
});
@@ -21462,7 +21453,6 @@ async fn test_breakpoint_enabling_and_disabling(cx: &mut TestAppContext) {
.unwrap()
.read(cx)
.all_source_breakpoints(cx)
- .clone()
});
assert_eq!(1, breakpoints.len());
@@ -21494,7 +21484,6 @@ async fn test_breakpoint_enabling_and_disabling(cx: &mut TestAppContext) {
.unwrap()
.read(cx)
.all_source_breakpoints(cx)
- .clone()
});
let disable_breakpoint = {
@@ -21530,7 +21519,6 @@ async fn test_breakpoint_enabling_and_disabling(cx: &mut TestAppContext) {
.unwrap()
.read(cx)
.all_source_breakpoints(cx)
- .clone()
});
assert_eq!(1, breakpoints.len());
@@ -22509,10 +22497,7 @@ async fn test_html_linked_edits_on_completion(cx: &mut TestAppContext) {
let closing_range =
buffer.anchor_before(Point::new(0, 6))..buffer.anchor_after(Point::new(0, 8));
let mut linked_ranges = HashMap::default();
- linked_ranges.insert(
- buffer_id,
- vec![(opening_range.clone(), vec![closing_range.clone()])],
- );
+ linked_ranges.insert(buffer_id, vec![(opening_range, vec![closing_range])]);
editor.linked_edit_ranges = LinkedEditingRanges(linked_ranges);
});
let mut completion_handle =
@@ -7209,7 +7209,7 @@ fn render_blame_entry_popover(
) -> Option<AnyElement> {
let renderer = cx.global::<GlobalBlameRenderer>().0.clone();
let blame = blame.read(cx);
- let repository = blame.repository(cx)?.clone();
+ let repository = blame.repository(cx)?;
renderer.render_blame_entry_popover(
blame_entry,
scroll_handle,
@@ -9009,7 +9009,7 @@ impl Element for EditorElement {
.as_ref()
.map(|layout| (layout.bounds, layout.entry.clone())),
display_hunks: display_hunks.clone(),
- diff_hunk_control_bounds: diff_hunk_control_bounds.clone(),
+ diff_hunk_control_bounds,
});
self.editor.update(cx, |editor, _| {
@@ -9894,7 +9894,7 @@ impl CursorLayout {
.px_0p5()
.line_height(text_size + px(2.))
.text_color(cursor_name.color)
- .child(cursor_name.string.clone())
+ .child(cursor_name.string)
.into_any_element();
name_element.prepaint_as_root(name_origin, AvailableSpace::min_size(), window, cx);
@@ -623,7 +623,7 @@ pub fn hover_markdown_style(window: &Window, cx: &App) -> MarkdownStyle {
let mut base_text_style = window.text_style();
base_text_style.refine(&TextStyleRefinement {
- font_family: Some(ui_font_family.clone()),
+ font_family: Some(ui_font_family),
font_fallbacks: ui_font_fallbacks,
color: Some(cx.theme().colors().editor_foreground),
..Default::default()
@@ -672,7 +672,7 @@ pub fn diagnostics_markdown_style(window: &Window, cx: &App) -> MarkdownStyle {
let mut base_text_style = window.text_style();
base_text_style.refine(&TextStyleRefinement {
- font_family: Some(ui_font_family.clone()),
+ font_family: Some(ui_font_family),
font_fallbacks: ui_font_fallbacks,
color: Some(cx.theme().colors().editor_foreground),
..Default::default()
@@ -507,7 +507,7 @@ pub(crate) fn handle_from(
{
let selections = this
- .read_with(cx, |this, _| this.selections.disjoint_anchors().clone())
+ .read_with(cx, |this, _| this.selections.disjoint_anchors())
.ok()?;
for selection in selections.iter() {
let Some(selection_buffer_offset_head) =
@@ -119,13 +119,7 @@ impl EditorTestContext {
for excerpt in excerpts.into_iter() {
let (text, ranges) = marked_text_ranges(excerpt, false);
let buffer = cx.new(|cx| Buffer::local(text, cx));
- multibuffer.push_excerpts(
- buffer,
- ranges
- .into_iter()
- .map(|range| ExcerptRange::new(range.clone())),
- cx,
- );
+ multibuffer.push_excerpts(buffer, ranges.into_iter().map(ExcerptRange::new), cx);
}
multibuffer
});
@@ -103,7 +103,7 @@ fn main() {
let languages: HashSet<String> = args.languages.into_iter().collect();
let http_client = Arc::new(ReqwestClient::new());
- let app = Application::headless().with_http_client(http_client.clone());
+ let app = Application::headless().with_http_client(http_client);
let all_threads = examples::all(&examples_dir);
app.run(move |cx| {
@@ -416,11 +416,7 @@ pub fn init(cx: &mut App) -> Arc<AgentAppState> {
language::init(cx);
debug_adapter_extension::init(extension_host_proxy.clone(), cx);
- language_extension::init(
- LspAccess::Noop,
- extension_host_proxy.clone(),
- languages.clone(),
- );
+ language_extension::init(LspAccess::Noop, extension_host_proxy, languages.clone());
language_model::init(client.clone(), cx);
language_models::init(user_store.clone(), client.clone(), cx);
languages::init(languages.clone(), node_runtime.clone(), cx);
@@ -530,7 +526,7 @@ async fn judge_example(
example_name = example.name.clone(),
example_repetition = example.repetition,
diff_evaluation = judge_output.diff.clone(),
- thread_evaluation = judge_output.thread.clone(),
+ thread_evaluation = judge_output.thread,
tool_metrics = run_output.tool_metrics,
response_count = run_output.response_count,
token_usage = run_output.token_usage,
@@ -90,11 +90,8 @@ impl ExampleInstance {
worktrees_dir: &Path,
repetition: usize,
) -> Self {
- let name = thread.meta().name.to_string();
- let run_directory = run_dir
- .join(&name)
- .join(repetition.to_string())
- .to_path_buf();
+ let name = thread.meta().name;
+ let run_directory = run_dir.join(&name).join(repetition.to_string());
let repo_path = repo_path_for_url(repos_dir, &thread.meta().url);
@@ -772,7 +769,7 @@ pub async fn query_lsp_diagnostics(
}
fn parse_assertion_result(response: &str) -> Result<RanAssertionResult> {
- let analysis = get_tag("analysis", response)?.to_string();
+ let analysis = get_tag("analysis", response)?;
let passed = match get_tag("passed", response)?.to_lowercase().as_str() {
"true" => true,
"false" => false,
@@ -145,7 +145,7 @@ mod tests {
command: "*".to_string(),
args: vec!["**".to_string()],
})],
- manifest.clone(),
+ manifest,
);
assert!(granter.grant_exec("ls", &["-la"]).is_ok());
}
@@ -61,7 +61,6 @@ impl RenderOnce for FeatureUpsell {
.icon_size(IconSize::Small)
.icon_position(IconPosition::End)
.on_click({
- let docs_url = docs_url.clone();
move |_event, _window, cx| {
telemetry::event!(
"Documentation Viewed",
@@ -694,7 +694,7 @@ impl ExtensionsPage {
cx.open_url(&repository_url);
}
}))
- .tooltip(Tooltip::text(repository_url.clone()))
+ .tooltip(Tooltip::text(repository_url))
})),
)
}
@@ -827,7 +827,7 @@ impl ExtensionsPage {
cx.open_url(&repository_url);
}
}))
- .tooltip(Tooltip::text(repository_url.clone())),
+ .tooltip(Tooltip::text(repository_url)),
)
.child(
PopoverMenu::new(SharedString::from(format!(
@@ -31,7 +31,7 @@ impl SystemSpecs {
let architecture = env::consts::ARCH;
let commit_sha = match release_channel {
ReleaseChannel::Dev | ReleaseChannel::Nightly => {
- AppCommitSha::try_global(cx).map(|sha| sha.full().clone())
+ AppCommitSha::try_global(cx).map(|sha| sha.full())
}
_ => None,
};
@@ -1750,7 +1750,7 @@ impl PickerDelegate for FileFinderDelegate {
Some(ContextMenu::build(window, cx, {
let focus_handle = focus_handle.clone();
move |menu, _, _| {
- menu.context(focus_handle.clone())
+ menu.context(focus_handle)
.action(
"Split Left",
pane::SplitLeft.boxed_clone(),
@@ -653,7 +653,7 @@ impl PickerDelegate for OpenPathDelegate {
if parent_path == &self.prompt_root {
format!("{}{}", self.prompt_root, candidate.path.string)
} else {
- candidate.path.string.clone()
+ candidate.path.string
},
match_positions,
)),
@@ -684,7 +684,7 @@ impl PickerDelegate for OpenPathDelegate {
};
StyledText::new(label)
.with_default_highlights(
- &window.text_style().clone(),
+ &window.text_style(),
vec![(
delta..delta + label_len,
HighlightStyle::color(Color::Conflict.color(cx)),
@@ -694,7 +694,7 @@ impl PickerDelegate for OpenPathDelegate {
} else {
StyledText::new(format!("{label} (create)"))
.with_default_highlights(
- &window.text_style().clone(),
+ &window.text_style(),
vec![(
delta..delta + label_len,
HighlightStyle::color(Color::Created.color(cx)),
@@ -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(())
})
}
@@ -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, {
@@ -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)
}
@@ -172,7 +172,7 @@ impl BlameRenderer for GitBlameRenderer {
.clone()
.unwrap_or("<no name>".to_string())
.into(),
- author_email: blame.author_mail.clone().unwrap_or("".to_string()).into(),
+ author_email: blame.author_mail.unwrap_or("".to_string()).into(),
message: details,
};
@@ -186,7 +186,7 @@ impl BlameRenderer for GitBlameRenderer {
.get(0..8)
.map(|sha| sha.to_string().into())
.unwrap_or_else(|| commit_details.sha.clone());
- let full_sha = commit_details.sha.to_string().clone();
+ let full_sha = commit_details.sha.to_string();
let absolute_timestamp = format_local_timestamp(
commit_details.commit_time,
OffsetDateTime::now_utc(),
@@ -377,7 +377,7 @@ impl BlameRenderer for GitBlameRenderer {
has_parent: true,
},
repository.downgrade(),
- workspace.clone(),
+ workspace,
window,
cx,
)
@@ -48,7 +48,7 @@ pub fn open(
window: &mut Window,
cx: &mut Context<Workspace>,
) {
- let repository = workspace.project().read(cx).active_repository(cx).clone();
+ let repository = workspace.project().read(cx).active_repository(cx);
let style = BranchListStyle::Modal;
workspace.toggle_modal(window, cx, |window, cx| {
BranchList::new(repository, style, rems(34.), window, cx)
@@ -144,7 +144,7 @@ impl BranchList {
})
.detach_and_log_err(cx);
- let delegate = BranchListDelegate::new(repository.clone(), style);
+ let delegate = BranchListDelegate::new(repository, style);
let picker = cx.new(|cx| Picker::uniform_list(delegate, window, cx));
let _subscription = cx.subscribe(&picker, |_, _, _, cx| {
@@ -35,7 +35,7 @@ impl ModalContainerProperties {
// Calculate width based on character width
let mut modal_width = 460.0;
- let style = window.text_style().clone();
+ let style = window.text_style();
let font_id = window.text_system().resolve_font(&style.font());
let font_size = style.font_size.to_pixels(window.rem_size());
@@ -179,7 +179,7 @@ impl CommitModal {
let commit_editor = git_panel.update(cx, |git_panel, cx| {
git_panel.set_modal_open(true, cx);
- let buffer = git_panel.commit_message_buffer(cx).clone();
+ let buffer = git_panel.commit_message_buffer(cx);
let panel_editor = git_panel.commit_editor.clone();
let project = git_panel.project.clone();
@@ -285,7 +285,7 @@ impl CommitModal {
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)
})
.when(has_previous_commit, |this| {
this.toggleable_entry(
@@ -482,7 +482,7 @@ impl CommitModal {
}),
self.render_git_commit_menu(
ElementId::Name(format!("split-button-right-{}", commit_label).into()),
- Some(focus_handle.clone()),
+ Some(focus_handle),
)
.into_any_element(),
)),
@@ -181,7 +181,7 @@ impl Render for CommitTooltip {
.get(0..8)
.map(|sha| sha.to_string().into())
.unwrap_or_else(|| self.commit.sha.clone());
- let full_sha = self.commit.sha.to_string().clone();
+ let full_sha = self.commit.sha.to_string();
let absolute_timestamp = format_local_timestamp(
self.commit.commit_time,
OffsetDateTime::now_utc(),
@@ -55,7 +55,7 @@ pub fn register_editor(editor: &mut Editor, buffer: Entity<MultiBuffer>, cx: &mu
buffers: Default::default(),
});
- let buffers = buffer.read(cx).all_buffers().clone();
+ let buffers = buffer.read(cx).all_buffers();
for buffer in buffers {
buffer_added(editor, buffer, cx);
}
@@ -129,7 +129,7 @@ fn buffer_added(editor: &mut Editor, buffer: Entity<Buffer>, cx: &mut Context<Ed
let subscription = cx.subscribe(&conflict_set, conflicts_updated);
BufferConflicts {
block_ids: Vec::new(),
- conflict_set: conflict_set.clone(),
+ conflict_set,
_subscription: subscription,
}
});
@@ -437,7 +437,6 @@ fn render_conflict_buttons(
Button::new("both", "Use Both")
.label_size(LabelSize::Small)
.on_click({
- let editor = editor.clone();
let conflict = conflict.clone();
let ours = conflict.ours.clone();
let theirs = conflict.theirs.clone();
@@ -1467,7 +1467,6 @@ impl GitPanel {
.read(cx)
.as_singleton()
.unwrap()
- .clone()
}
fn toggle_staged_for_selected(
@@ -3207,7 +3206,7 @@ impl GitPanel {
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)
})
.when(has_previous_commit, |this| {
this.toggleable_entry(
@@ -3387,7 +3386,7 @@ impl GitPanel {
let enable_coauthors = self.render_co_authors(cx);
let editor_focus_handle = self.commit_editor.focus_handle(cx);
- let expand_tooltip_focus_handle = editor_focus_handle.clone();
+ let expand_tooltip_focus_handle = editor_focus_handle;
let branch = active_repository.read(cx).branch.clone();
let head_commit = active_repository.read(cx).head_commit.clone();
@@ -3416,7 +3415,7 @@ impl GitPanel {
display_name,
branch,
head_commit,
- Some(git_panel.clone()),
+ Some(git_panel),
))
.child(
panel_editor_container(window, cx)
@@ -3567,7 +3566,7 @@ impl GitPanel {
}),
self.render_git_commit_menu(
ElementId::Name(format!("split-button-right-{}", title).into()),
- Some(commit_tooltip_focus_handle.clone()),
+ Some(commit_tooltip_focus_handle),
cx,
)
.into_any_element(),
@@ -3633,7 +3632,7 @@ impl GitPanel {
CommitView::open(
commit.clone(),
repo.clone(),
- workspace.clone().clone(),
+ workspace.clone(),
window,
cx,
);
@@ -4341,7 +4340,7 @@ impl GitPanel {
}
})
.child(
- self.entry_label(display_name.clone(), label_color)
+ self.entry_label(display_name, label_color)
.when(status.is_deleted(), |this| this.strikethrough()),
),
)
@@ -4690,7 +4689,7 @@ impl GitPanelMessageTooltip {
author_email: details.author_email.clone(),
commit_time: OffsetDateTime::from_unix_timestamp(details.commit_timestamp)?,
message: Some(ParsedCommitMessage {
- message: details.message.clone(),
+ message: details.message,
..Default::default()
}),
};
@@ -4823,7 +4822,7 @@ impl RenderOnce for PanelRepoFooter {
};
let truncated_branch_name = if branch_actual_len <= branch_display_len {
- branch_name.to_string()
+ branch_name
} else {
util::truncate_and_trailoff(branch_name.trim_ascii(), branch_display_len)
};
@@ -4836,7 +4835,7 @@ impl RenderOnce for PanelRepoFooter {
let repo_selector = PopoverMenu::new("repository-switcher")
.menu({
- let project = project.clone();
+ let project = project;
move |window, cx| {
let project = project.clone()?;
Some(cx.new(|cx| RepositorySelector::new(project, rems(16.), window, cx)))
@@ -5007,10 +5006,7 @@ impl Component for PanelRepoFooter {
div()
.w(example_width)
.overflow_hidden()
- .child(PanelRepoFooter::new_preview(
- active_repository(1).clone(),
- None,
- ))
+ .child(PanelRepoFooter::new_preview(active_repository(1), None))
.into_any_element(),
),
single_example(
@@ -5019,7 +5015,7 @@ impl Component for PanelRepoFooter {
.w(example_width)
.overflow_hidden()
.child(PanelRepoFooter::new_preview(
- active_repository(2).clone(),
+ active_repository(2),
Some(branch(unknown_upstream)),
))
.into_any_element(),
@@ -5030,7 +5026,7 @@ impl Component for PanelRepoFooter {
.w(example_width)
.overflow_hidden()
.child(PanelRepoFooter::new_preview(
- active_repository(3).clone(),
+ active_repository(3),
Some(branch(no_remote_upstream)),
))
.into_any_element(),
@@ -5041,7 +5037,7 @@ impl Component for PanelRepoFooter {
.w(example_width)
.overflow_hidden()
.child(PanelRepoFooter::new_preview(
- active_repository(4).clone(),
+ active_repository(4),
Some(branch(not_ahead_or_behind_upstream)),
))
.into_any_element(),
@@ -5052,7 +5048,7 @@ impl Component for PanelRepoFooter {
.w(example_width)
.overflow_hidden()
.child(PanelRepoFooter::new_preview(
- active_repository(5).clone(),
+ active_repository(5),
Some(branch(behind_upstream)),
))
.into_any_element(),
@@ -5063,7 +5059,7 @@ impl Component for PanelRepoFooter {
.w(example_width)
.overflow_hidden()
.child(PanelRepoFooter::new_preview(
- active_repository(6).clone(),
+ active_repository(6),
Some(branch(ahead_of_upstream)),
))
.into_any_element(),
@@ -5074,7 +5070,7 @@ impl Component for PanelRepoFooter {
.w(example_width)
.overflow_hidden()
.child(PanelRepoFooter::new_preview(
- active_repository(7).clone(),
+ active_repository(7),
Some(branch(ahead_and_behind_upstream)),
))
.into_any_element(),
@@ -245,12 +245,12 @@ fn render_remote_button(
}
(0, 0) => None,
(ahead, 0) => Some(remote_button::render_push_button(
- keybinding_target.clone(),
+ keybinding_target,
id,
ahead,
)),
(ahead, behind) => Some(remote_button::render_pull_button(
- keybinding_target.clone(),
+ keybinding_target,
id,
ahead,
behind,
@@ -425,16 +425,9 @@ mod remote_button {
let command = command.into();
if let Some(handle) = focus_handle {
- Tooltip::with_meta_in(
- label.clone(),
- Some(action),
- command.clone(),
- &handle,
- window,
- cx,
- )
+ Tooltip::with_meta_in(label, Some(action), command, &handle, window, cx)
} else {
- Tooltip::with_meta(label.clone(), Some(action), command.clone(), window, cx)
+ Tooltip::with_meta(label, Some(action), command, window, cx)
}
}
@@ -457,7 +450,7 @@ mod remote_button {
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("Fetch", git::Fetch.boxed_clone())
.action("Fetch From", git::FetchFrom.boxed_clone())
@@ -242,7 +242,7 @@ impl ProjectDiff {
TRACKED_NAMESPACE
};
- let path_key = PathKey::namespaced(namespace, entry.repo_path.0.clone());
+ let path_key = PathKey::namespaced(namespace, entry.repo_path.0);
self.move_to_path(path_key, window, cx)
}
@@ -448,10 +448,10 @@ impl ProjectDiff {
let diff = diff.read(cx);
let diff_hunk_ranges = diff
.hunks_intersecting_range(Anchor::MIN..Anchor::MAX, &snapshot, cx)
- .map(|diff_hunk| diff_hunk.buffer_range.clone());
+ .map(|diff_hunk| diff_hunk.buffer_range);
let conflicts = conflict_addon
.conflict_set(snapshot.remote_id())
- .map(|conflict_set| conflict_set.read(cx).snapshot().conflicts.clone())
+ .map(|conflict_set| conflict_set.read(cx).snapshot().conflicts)
.unwrap_or_default();
let conflicts = conflicts.iter().map(|conflict| conflict.range.clone());
@@ -737,7 +737,7 @@ impl Render for ProjectDiff {
} else {
None
};
- let keybinding_focus_handle = self.focus_handle(cx).clone();
+ let keybinding_focus_handle = self.focus_handle(cx);
el.child(
v_flex()
.gap_1()
@@ -48,7 +48,7 @@ impl TextDiffView {
let selection_data = source_editor.update(cx, |editor, cx| {
let multibuffer = editor.buffer().read(cx);
- let source_buffer = multibuffer.as_singleton()?.clone();
+ let source_buffer = multibuffer.as_singleton()?;
let selections = editor.selections.all::<Point>(cx);
let buffer_snapshot = source_buffer.read(cx);
let first_selection = selections.first()?;
@@ -259,7 +259,7 @@ async fn update_diff_buffer(
let source_buffer_snapshot = source_buffer.read_with(cx, |buffer, _| buffer.snapshot())?;
let base_buffer_snapshot = clipboard_buffer.read_with(cx, |buffer, _| buffer.snapshot())?;
- let base_text = base_buffer_snapshot.text().to_string();
+ let base_text = base_buffer_snapshot.text();
let diff_snapshot = cx
.update(|cx| {
@@ -712,7 +712,7 @@ mod tests {
) -> Entity<GoToLine> {
cx.dispatch_action(editor::actions::ToggleGoToLine);
workspace.update(cx, |workspace, cx| {
- workspace.active_modal::<GoToLine>(cx).unwrap().clone()
+ workspace.active_modal::<GoToLine>(cx).unwrap()
})
}
@@ -446,7 +446,7 @@ impl Element for TextElement {
let (display_text, text_color) = if content.is_empty() {
(input.placeholder.clone(), hsla(0., 0., 0., 0.2))
} else {
- (content.clone(), style.color)
+ (content, style.color)
};
let run = TextRun {
@@ -474,7 +474,7 @@ impl Element for TextElement {
},
TextRun {
len: display_text.len() - marked_range.end,
- ..run.clone()
+ ..run
},
]
.into_iter()
@@ -155,7 +155,7 @@ impl RenderOnce for Specimen {
.text_size(px(font_size * scale))
.line_height(relative(line_height))
.p(px(10.0))
- .child(self.string.clone())
+ .child(self.string)
}
}
@@ -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);
})
}
}
@@ -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,
}
}
@@ -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()
}
@@ -475,7 +475,7 @@ impl Element for Img {
.paint_image(
new_bounds,
corner_radii,
- data.clone(),
+ data,
layout_state.frame_index,
self.style.grayscale,
)
@@ -1046,7 +1046,7 @@ where
size: self.size.clone()
+ size(
amount.left.clone() + amount.right.clone(),
- amount.top.clone() + amount.bottom.clone(),
+ amount.top.clone() + amount.bottom,
),
}
}
@@ -1159,10 +1159,10 @@ where
/// Computes the space available within outer bounds.
pub fn space_within(&self, outer: &Self) -> Edges<T> {
Edges {
- top: self.top().clone() - outer.top().clone(),
- right: outer.right().clone() - self.right().clone(),
- bottom: outer.bottom().clone() - self.bottom().clone(),
- left: self.left().clone() - outer.left().clone(),
+ top: self.top() - outer.top(),
+ right: outer.right() - self.right(),
+ bottom: outer.bottom() - self.bottom(),
+ left: self.left() - outer.left(),
}
}
}
@@ -1712,7 +1712,7 @@ where
top: self.top.clone() * rhs.top,
right: self.right.clone() * rhs.right,
bottom: self.bottom.clone() * rhs.bottom,
- left: self.left.clone() * rhs.left,
+ left: self.left * rhs.left,
}
}
}
@@ -2411,7 +2411,7 @@ where
top_left: self.top_left.clone() * rhs.top_left,
top_right: self.top_right.clone() * rhs.top_right,
bottom_right: self.bottom_right.clone() * rhs.bottom_right,
- bottom_left: self.bottom_left.clone() * rhs.bottom_left,
+ bottom_left: self.bottom_left * rhs.bottom_left,
}
}
}
@@ -264,7 +264,7 @@ mod tests {
];
let mut keymap = Keymap::default();
- keymap.add_bindings(bindings.clone());
+ keymap.add_bindings(bindings);
let (result, pending) = keymap.bindings_for_input(
&[Keystroke::parse("ctrl-a").unwrap()],
@@ -290,7 +290,7 @@ mod tests {
];
let mut keymap = Keymap::default();
- keymap.add_bindings(bindings.clone());
+ keymap.add_bindings(bindings);
// binding is only enabled in a specific context
assert!(
@@ -344,7 +344,7 @@ mod tests {
];
let mut keymap = Keymap::default();
- keymap.add_bindings(bindings.clone());
+ keymap.add_bindings(bindings);
let space = || Keystroke::parse("space").unwrap();
let w = || Keystroke::parse("w").unwrap();
@@ -396,7 +396,7 @@ mod tests {
KeyBinding::new("space w x", ActionAlpha {}, Some("editor")),
];
let mut keymap = Keymap::default();
- keymap.add_bindings(bindings.clone());
+ keymap.add_bindings(bindings);
let space_editor = keymap.bindings_for_input(&[space()], &editor_workspace_context());
assert!(space_editor.0.is_empty());
@@ -410,7 +410,7 @@ mod tests {
KeyBinding::new("space w w", NoAction {}, Some("editor")),
];
let mut keymap = Keymap::default();
- keymap.add_bindings(bindings.clone());
+ keymap.add_bindings(bindings);
let space_editor = keymap.bindings_for_input(&[space()], &editor_workspace_context());
assert!(space_editor.0.is_empty());
@@ -424,7 +424,7 @@ mod tests {
KeyBinding::new("space w w", NoAction {}, Some("editor")),
];
let mut keymap = Keymap::default();
- keymap.add_bindings(bindings.clone());
+ keymap.add_bindings(bindings);
let space_editor = keymap.bindings_for_input(&[space()], &editor_workspace_context());
assert!(space_editor.0.is_empty());
@@ -439,7 +439,7 @@ mod tests {
];
let mut keymap = Keymap::default();
- keymap.add_bindings(bindings.clone());
+ keymap.add_bindings(bindings);
// Ensure `space` results in pending input on the workspace, but not editor
let (result, pending) = keymap.bindings_for_input(
@@ -455,7 +455,7 @@ mod tests {
];
let mut keymap = Keymap::default();
- keymap.add_bindings(bindings.clone());
+ keymap.add_bindings(bindings);
// Ensure `space` results in pending input on the workspace, but not editor
let (result, pending) = keymap.bindings_for_input(
@@ -474,7 +474,7 @@ mod tests {
];
let mut keymap = Keymap::default();
- keymap.add_bindings(bindings.clone());
+ keymap.add_bindings(bindings);
// Ensure `space` results in pending input on the workspace, but not editor
let (result, pending) = keymap.bindings_for_input(
@@ -494,7 +494,7 @@ mod tests {
];
let mut keymap = Keymap::default();
- keymap.add_bindings(bindings.clone());
+ keymap.add_bindings(bindings);
// Ensure `space` results in pending input on the workspace, but not editor
let (result, pending) = keymap.bindings_for_input(
@@ -516,7 +516,7 @@ mod tests {
];
let mut keymap = Keymap::default();
- keymap.add_bindings(bindings.clone());
+ keymap.add_bindings(bindings);
// Ensure `space` results in pending input on the workspace, but not editor
let (result, pending) = keymap.bindings_for_input(
@@ -537,7 +537,7 @@ mod tests {
KeyBinding::new("ctrl-x 0", ActionAlpha, Some("Workspace")),
];
let mut keymap = Keymap::default();
- keymap.add_bindings(bindings.clone());
+ keymap.add_bindings(bindings);
let matched = keymap.bindings_for_input(
&[Keystroke::parse("ctrl-x")].map(Result::unwrap),
@@ -560,7 +560,7 @@ mod tests {
KeyBinding::new("ctrl-x 0", NoAction, Some("Workspace")),
];
let mut keymap = Keymap::default();
- keymap.add_bindings(bindings.clone());
+ keymap.add_bindings(bindings);
let matched = keymap.bindings_for_input(
&[Keystroke::parse("ctrl-x")].map(Result::unwrap),
@@ -579,7 +579,7 @@ mod tests {
KeyBinding::new("ctrl-x 0", NoAction, Some("vim_mode == normal")),
];
let mut keymap = Keymap::default();
- keymap.add_bindings(bindings.clone());
+ keymap.add_bindings(bindings);
let matched = keymap.bindings_for_input(
&[Keystroke::parse("ctrl-x")].map(Result::unwrap),
@@ -602,7 +602,7 @@ mod tests {
KeyBinding::new("ctrl-x", ActionBeta, Some("vim_mode == normal")),
];
let mut keymap = Keymap::default();
- keymap.add_bindings(bindings.clone());
+ keymap.add_bindings(bindings);
let matched = keymap.bindings_for_input(
&[Keystroke::parse("ctrl-x")].map(Result::unwrap),
@@ -629,7 +629,7 @@ mod tests {
];
let mut keymap = Keymap::default();
- keymap.add_bindings(bindings.clone());
+ keymap.add_bindings(bindings);
assert_bindings(&keymap, &ActionAlpha {}, &["ctrl-a"]);
assert_bindings(&keymap, &ActionBeta {}, &[]);
@@ -668,11 +668,7 @@ mod tests {
let contexts = vec![other_context.clone(), child_context.clone()];
assert!(!predicate.eval(&contexts));
- let contexts = vec![
- parent_context.clone(),
- other_context.clone(),
- child_context.clone(),
- ];
+ let contexts = vec![parent_context.clone(), other_context, child_context.clone()];
assert!(predicate.eval(&contexts));
assert!(!predicate.eval(&[]));
@@ -681,7 +677,7 @@ mod tests {
let zany_predicate = KeyBindingContextPredicate::parse("child > child").unwrap();
assert!(!zany_predicate.eval(slice::from_ref(&child_context)));
- assert!(zany_predicate.eval(&[child_context.clone(), child_context.clone()]));
+ assert!(zany_predicate.eval(&[child_context.clone(), child_context]));
}
#[test]
@@ -718,7 +714,7 @@ mod tests {
let not_descendant = KeyBindingContextPredicate::parse("parent > !child").unwrap();
assert!(!not_descendant.eval(slice::from_ref(&parent_context)));
assert!(!not_descendant.eval(slice::from_ref(&child_context)));
- assert!(!not_descendant.eval(&[parent_context.clone(), child_context.clone()]));
+ assert!(!not_descendant.eval(&[parent_context, child_context]));
let double_not = KeyBindingContextPredicate::parse("!!editor").unwrap();
assert!(double_not.eval(slice::from_ref(&editor_context)));
@@ -108,13 +108,13 @@ impl LinuxCommon {
let callbacks = PlatformHandlers::default();
- let dispatcher = Arc::new(LinuxDispatcher::new(main_sender.clone()));
+ let dispatcher = Arc::new(LinuxDispatcher::new(main_sender));
let background_executor = BackgroundExecutor::new(dispatcher.clone());
let common = LinuxCommon {
background_executor,
- foreground_executor: ForegroundExecutor::new(dispatcher.clone()),
+ foreground_executor: ForegroundExecutor::new(dispatcher),
text_system,
appearance: WindowAppearance::Light,
auto_hide_scrollbars: false,
@@ -1280,7 +1280,6 @@ impl Dispatch<wl_keyboard::WlKeyboard, ()> for WaylandClientStatePtr {
let Some(focused_window) = focused_window else {
return;
};
- let focused_window = focused_window.clone();
let keymap_state = state.keymap_state.as_ref().unwrap();
let keycode = Keycode::from(key + MIN_KEYCODE);
@@ -67,7 +67,7 @@ impl Cursor {
{
self.loaded_theme = Some(LoadedTheme {
theme,
- name: theme_name.map(|name| name.to_string()),
+ name: theme_name,
scaled_size: self.scaled_size,
});
}
@@ -1329,7 +1329,7 @@ impl X11Client {
state.composing = false;
drop(state);
if let Some(mut keystroke) = keystroke {
- keystroke.key_char = Some(text.clone());
+ keystroke.key_char = Some(text);
window.handle_input(PlatformInput::KeyDown(crate::KeyDownEvent {
keystroke,
is_held: false,
@@ -332,7 +332,7 @@ impl MetalRenderer {
self.path_intermediate_texture = Some(self.device.new_texture(&texture_descriptor));
if self.path_sample_count > 1 {
- let mut msaa_descriptor = texture_descriptor.clone();
+ let mut msaa_descriptor = texture_descriptor;
msaa_descriptor.set_texture_type(metal::MTLTextureType::D2Multisample);
msaa_descriptor.set_storage_mode(metal::MTLStorageMode::Private);
msaa_descriptor.set_sample_count(self.path_sample_count as _);
@@ -187,14 +187,14 @@ impl TestPlatform {
.push_back(TestPrompt {
msg: msg.to_string(),
detail: detail.map(|s| s.to_string()),
- answers: answers.clone(),
+ answers,
tx,
});
rx
}
pub(crate) fn set_active_window(&self, window: Option<TestWindow>) {
- let executor = self.foreground_executor().clone();
+ let executor = self.foreground_executor();
let previous_window = self.active_window.borrow_mut().take();
self.active_window.borrow_mut().clone_from(&window);
@@ -956,7 +956,7 @@ impl WindowsWindowInner {
click_count,
first_mouse: false,
});
- let result = func(input.clone());
+ let result = func(input);
let handled = !result.propagate || result.default_prevented;
self.state.borrow_mut().callbacks.input = Some(func);
@@ -108,7 +108,7 @@ impl From<SharedString> for Arc<str> {
fn from(val: SharedString) -> Self {
match val.0 {
ArcCow::Borrowed(borrowed) => Arc::from(borrowed),
- ArcCow::Owned(owned) => owned.clone(),
+ ArcCow::Owned(owned) => owned,
}
}
}
@@ -2453,7 +2453,7 @@ impl Window {
/// time.
pub fn get_asset<A: Asset>(&mut self, source: &A::Source, cx: &mut App) -> Option<A::Output> {
let (task, _) = cx.fetch_asset::<A>(source);
- task.clone().now_or_never()
+ task.now_or_never()
}
/// Obtain the current element offset. This method should only be called during the
/// prepaint phase of element drawing.
@@ -3044,7 +3044,7 @@ impl Window {
let tile = self
.sprite_atlas
- .get_or_insert_with(¶ms.clone().into(), &mut || {
+ .get_or_insert_with(¶ms.into(), &mut || {
Ok(Some((
data.size(frame_index),
Cow::Borrowed(
@@ -3731,7 +3731,7 @@ impl Window {
self.dispatch_keystroke_observers(
event,
Some(binding.action),
- match_result.context_stack.clone(),
+ match_result.context_stack,
cx,
);
self.pending_input_changed(cx);
@@ -4442,7 +4442,7 @@ impl Window {
if let Some((_, inspector_id)) =
self.hovered_inspector_hitbox(inspector, &self.rendered_frame)
{
- inspector.set_active_element_id(inspector_id.clone(), self);
+ inspector.set_active_element_id(inspector_id, self);
}
}
});
@@ -4583,7 +4583,7 @@ impl<V: 'static + Render> WindowHandle<V> {
where
C: AppContext,
{
- cx.read_window(self, |root_view, _cx| root_view.clone())
+ cx.read_window(self, |root_view, _cx| root_view)
}
/// Check if this window is 'active'.
@@ -106,9 +106,7 @@ fn test_derive_inspector_reflection() {
.invoke(num.clone());
assert_eq!(incremented, Number(6));
- let quadrupled = find_method::<Number>("quadruple")
- .unwrap()
- .invoke(num.clone());
+ let quadrupled = find_method::<Number>("quadruple").unwrap().invoke(num);
assert_eq!(quadrupled, Number(20));
// Try to invoke a non-existent method
@@ -40,7 +40,7 @@ impl AsyncBody {
}
pub fn from_bytes(bytes: Bytes) -> Self {
- Self(Inner::Bytes(Cursor::new(bytes.clone())))
+ Self(Inner::Bytes(Cursor::new(bytes)))
}
}
@@ -123,7 +123,7 @@ pub fn new_journal_entry(workspace: &Workspace, window: &mut Window, cx: &mut Ap
}
let app_state = workspace.app_state().clone();
- let view_snapshot = workspace.weak_handle().clone();
+ let view_snapshot = workspace.weak_handle();
window
.spawn(cx, async move |cx| {
@@ -974,8 +974,6 @@ impl Buffer {
TextBuffer::new_normalized(0, buffer_id, Default::default(), text).snapshot();
let mut syntax = SyntaxMap::new(&text).snapshot();
if let Some(language) = language.clone() {
- let text = text.clone();
- let language = language.clone();
let language_registry = language_registry.clone();
syntax.reparse(&text, language_registry, language);
}
@@ -1020,9 +1018,6 @@ impl Buffer {
let text = TextBuffer::new_normalized(0, buffer_id, Default::default(), text).snapshot();
let mut syntax = SyntaxMap::new(&text).snapshot();
if let Some(language) = language.clone() {
- let text = text.clone();
- let language = language.clone();
- let language_registry = language_registry.clone();
syntax.reparse(&text, language_registry, language);
}
BufferSnapshot {
@@ -2206,7 +2201,7 @@ impl Buffer {
self.remote_selections.insert(
AGENT_REPLICA_ID,
SelectionSet {
- selections: selections.clone(),
+ selections,
lamport_timestamp,
line_mode,
cursor_shape,
@@ -3006,9 +3001,9 @@ impl BufferSnapshot {
}
let mut error_ranges = Vec::<Range<Point>>::new();
- let mut matches = self.syntax.matches(range.clone(), &self.text, |grammar| {
- grammar.error_query.as_ref()
- });
+ let mut matches = self
+ .syntax
+ .matches(range, &self.text, |grammar| grammar.error_query.as_ref());
while let Some(mat) = matches.peek() {
let node = mat.captures[0].node;
let start = Point::from_ts_point(node.start_position());
@@ -4075,7 +4070,7 @@ impl BufferSnapshot {
// Get the ranges of the innermost pair of brackets.
let mut result: Option<(Range<usize>, Range<usize>)> = None;
- for pair in self.enclosing_bracket_ranges(range.clone()) {
+ for pair in self.enclosing_bracket_ranges(range) {
if let Some(range_filter) = range_filter
&& !range_filter(pair.open_range.clone(), pair.close_range.clone())
{
@@ -4248,7 +4243,7 @@ impl BufferSnapshot {
.map(|(range, name)| {
(
name.to_string(),
- self.text_for_range(range.clone()).collect::<String>(),
+ self.text_for_range(range).collect::<String>(),
)
})
.collect();
@@ -1744,7 +1744,7 @@ fn test_autoindent_block_mode(cx: &mut App) {
buffer.edit(
[(Point::new(2, 8)..Point::new(2, 8), inserted_text)],
Some(AutoindentMode::Block {
- original_indent_columns: original_indent_columns.clone(),
+ original_indent_columns,
}),
cx,
);
@@ -1790,9 +1790,9 @@ fn test_autoindent_block_mode_with_newline(cx: &mut App) {
"#
.unindent();
buffer.edit(
- [(Point::new(2, 0)..Point::new(2, 0), inserted_text.clone())],
+ [(Point::new(2, 0)..Point::new(2, 0), inserted_text)],
Some(AutoindentMode::Block {
- original_indent_columns: original_indent_columns.clone(),
+ original_indent_columns,
}),
cx,
);
@@ -1843,7 +1843,7 @@ fn test_autoindent_block_mode_without_original_indent_columns(cx: &mut App) {
buffer.edit(
[(Point::new(2, 0)..Point::new(2, 0), inserted_text)],
Some(AutoindentMode::Block {
- original_indent_columns: original_indent_columns.clone(),
+ original_indent_columns,
}),
cx,
);
@@ -2030,7 +2030,7 @@ fn test_autoindent_with_injected_languages(cx: &mut App) {
let language_registry = Arc::new(LanguageRegistry::test(cx.background_executor().clone()));
language_registry.add(html_language.clone());
- language_registry.add(javascript_language.clone());
+ language_registry.add(javascript_language);
cx.new(|cx| {
let (text, ranges) = marked_text_ranges(
@@ -206,7 +206,7 @@ impl CachedLspAdapter {
}
pub fn name(&self) -> LanguageServerName {
- self.adapter.name().clone()
+ self.adapter.name()
}
pub async fn get_language_server_command(
@@ -432,7 +432,7 @@ impl LanguageRegistry {
let mut state = self.state.write();
state
.lsp_adapters
- .entry(language_name.clone())
+ .entry(language_name)
.or_default()
.push(adapter.clone());
state.all_lsp_adapters.insert(adapter.name(), adapter);
@@ -454,7 +454,7 @@ impl LanguageRegistry {
let cached_adapter = CachedLspAdapter::new(Arc::new(adapter));
state
.lsp_adapters
- .entry(language_name.clone())
+ .entry(language_name)
.or_default()
.push(cached_adapter.clone());
state
@@ -1167,8 +1167,7 @@ impl LanguageRegistryState {
soft_wrap: language.config.soft_wrap,
auto_indent_on_paste: language.config.auto_indent_on_paste,
..Default::default()
- }
- .clone(),
+ },
);
self.languages.push(language);
self.version += 1;
@@ -199,7 +199,7 @@ impl LanguageSettings {
if language_server.0.as_ref() == Self::REST_OF_LANGUAGE_SERVERS {
rest.clone()
} else {
- vec![language_server.clone()]
+ vec![language_server]
}
})
.collect::<Vec<_>>()
@@ -1793,7 +1793,7 @@ mod tests {
assert!(!settings.enabled_for_file(&dot_env_file, &cx));
// Test tilde expansion
- let home = shellexpand::tilde("~").into_owned().to_string();
+ let home = shellexpand::tilde("~").into_owned();
let home_file = make_test_file(&[&home, "test.rs"]);
let settings = build_settings(&["~/test.rs"]);
assert!(!settings.enabled_for_file(&home_file, &cx));
@@ -832,7 +832,7 @@ impl SyntaxSnapshot {
query: fn(&Grammar) -> Option<&Query>,
) -> SyntaxMapCaptures<'a> {
SyntaxMapCaptures::new(
- range.clone(),
+ range,
text,
[SyntaxLayer {
language,
@@ -58,8 +58,7 @@ fn test_splice_included_ranges() {
assert_eq!(change, 0..1);
// does not create overlapping ranges
- let (new_ranges, change) =
- splice_included_ranges(ranges.clone(), &[0..18], &[ts_range(20..32)]);
+ let (new_ranges, change) = splice_included_ranges(ranges, &[0..18], &[ts_range(20..32)]);
assert_eq!(
new_ranges,
&[ts_range(20..32), ts_range(50..60), ts_range(80..90)]
@@ -104,7 +103,7 @@ fn test_syntax_map_layers_for_range(cx: &mut App) {
);
let mut syntax_map = SyntaxMap::new(&buffer);
- syntax_map.set_language_registry(registry.clone());
+ syntax_map.set_language_registry(registry);
syntax_map.reparse(language.clone(), &buffer);
assert_layers_for_range(
@@ -165,7 +164,7 @@ fn test_syntax_map_layers_for_range(cx: &mut App) {
// Put the vec! macro back, adding back the syntactic layer.
buffer.undo();
syntax_map.interpolate(&buffer);
- syntax_map.reparse(language.clone(), &buffer);
+ syntax_map.reparse(language, &buffer);
assert_layers_for_range(
&syntax_map,
@@ -252,8 +251,8 @@ fn test_dynamic_language_injection(cx: &mut App) {
assert!(syntax_map.contains_unknown_injections());
registry.add(Arc::new(html_lang()));
- syntax_map.reparse(markdown.clone(), &buffer);
- syntax_map.reparse(markdown_inline.clone(), &buffer);
+ syntax_map.reparse(markdown, &buffer);
+ syntax_map.reparse(markdown_inline, &buffer);
assert_layers_for_range(
&syntax_map,
&buffer,
@@ -862,7 +861,7 @@ fn test_syntax_map_languages_loading_with_erb(cx: &mut App) {
log::info!("editing");
buffer.edit_via_marked_text(&text);
syntax_map.interpolate(&buffer);
- syntax_map.reparse(language.clone(), &buffer);
+ syntax_map.reparse(language, &buffer);
assert_capture_ranges(
&syntax_map,
@@ -986,7 +985,7 @@ fn test_random_edits(
syntax_map.reparse(language.clone(), &buffer);
let mut reference_syntax_map = SyntaxMap::new(&buffer);
- reference_syntax_map.set_language_registry(registry.clone());
+ reference_syntax_map.set_language_registry(registry);
log::info!("initial text:\n{}", buffer.text());
@@ -88,11 +88,11 @@ pub fn text_diff_with_options(
let new_offset = new_byte_range.start;
hunk_input.clear();
hunk_input.update_before(tokenize(
- &old_text[old_byte_range.clone()],
+ &old_text[old_byte_range],
options.language_scope.clone(),
));
hunk_input.update_after(tokenize(
- &new_text[new_byte_range.clone()],
+ &new_text[new_byte_range],
options.language_scope.clone(),
));
diff_internal(&hunk_input, |old_byte_range, new_byte_range, _, _| {
@@ -103,7 +103,7 @@ pub fn text_diff_with_options(
let replacement_text = if new_byte_range.is_empty() {
empty.clone()
} else {
- new_text[new_byte_range.clone()].into()
+ new_text[new_byte_range].into()
};
edits.push((old_byte_range, replacement_text));
});
@@ -111,9 +111,9 @@ pub fn text_diff_with_options(
let replacement_text = if new_byte_range.is_empty() {
empty.clone()
} else {
- new_text[new_byte_range.clone()].into()
+ new_text[new_byte_range].into()
};
- edits.push((old_byte_range.clone(), replacement_text));
+ edits.push((old_byte_range, replacement_text));
}
},
);
@@ -54,7 +54,7 @@ pub const ZED_CLOUD_PROVIDER_NAME: LanguageModelProviderName =
pub fn init(client: Arc<Client>, cx: &mut App) {
init_settings(cx);
- RefreshLlmTokenListener::register(client.clone(), cx);
+ RefreshLlmTokenListener::register(client, cx);
}
pub fn init_settings(cx: &mut App) {
@@ -538,7 +538,7 @@ pub trait LanguageModel: Send + Sync {
if let Some(first_event) = events.next().await {
match first_event {
Ok(LanguageModelCompletionEvent::StartMessage { message_id: id }) => {
- message_id = Some(id.clone());
+ message_id = Some(id);
}
Ok(LanguageModelCompletionEvent::Text(text)) => {
first_item_text = Some(text);
@@ -82,7 +82,7 @@ impl LlmApiToken {
let response = client.cloud_client().create_llm_token(system_id).await?;
*lock = Some(response.token.0.clone());
- Ok(response.token.0.clone())
+ Ok(response.token.0)
}
}
@@ -104,7 +104,7 @@ fn register_language_model_providers(
cx: &mut Context<LanguageModelRegistry>,
) {
registry.register_provider(
- CloudLanguageModelProvider::new(user_store.clone(), client.clone(), cx),
+ CloudLanguageModelProvider::new(user_store, client.clone(), cx),
cx,
);
@@ -917,7 +917,7 @@ pub fn map_to_language_model_completion_events(
Some(ContentBlockDelta::ReasoningContent(thinking)) => match thinking {
ReasoningContentBlockDelta::Text(thoughts) => {
Some(Ok(LanguageModelCompletionEvent::Thinking {
- text: thoughts.clone(),
+ text: thoughts,
signature: None,
}))
}
@@ -968,7 +968,7 @@ pub fn map_to_language_model_completion_events(
id: tool_use.id.into(),
name: tool_use.name.into(),
is_input_complete: true,
- raw_input: tool_use.input_json.clone(),
+ raw_input: tool_use.input_json,
input,
},
))
@@ -1086,21 +1086,18 @@ impl ConfigurationView {
.access_key_id_editor
.read(cx)
.text(cx)
- .to_string()
.trim()
.to_string();
let secret_access_key = self
.secret_access_key_editor
.read(cx)
.text(cx)
- .to_string()
.trim()
.to_string();
let session_token = self
.session_token_editor
.read(cx)
.text(cx)
- .to_string()
.trim()
.to_string();
let session_token = if session_token.is_empty() {
@@ -1108,13 +1105,7 @@ impl ConfigurationView {
} else {
Some(session_token)
};
- let region = self
- .region_editor
- .read(cx)
- .text(cx)
- .to_string()
- .trim()
- .to_string();
+ let region = self.region_editor.read(cx).text(cx).trim().to_string();
let region = if region.is_empty() {
"us-east-1".to_string()
} else {
@@ -140,7 +140,7 @@ impl State {
Self {
client: client.clone(),
llm_api_token: LlmApiToken::default(),
- user_store: user_store.clone(),
+ user_store,
status,
accept_terms_of_service_task: None,
models: Vec::new(),
@@ -307,7 +307,7 @@ impl CloudLanguageModelProvider {
Self {
client,
- state: state.clone(),
+ state,
_maintain_client_status: maintain_client_status,
}
}
@@ -320,7 +320,7 @@ impl CloudLanguageModelProvider {
Arc::new(CloudLanguageModel {
id: LanguageModelId(SharedString::from(model.id.0.clone())),
model,
- llm_api_token: llm_api_token.clone(),
+ llm_api_token,
client: self.client.clone(),
request_limiter: RateLimiter::new(4),
})
@@ -387,7 +387,7 @@ impl LanguageModel for GoogleLanguageModel {
cx: &App,
) -> BoxFuture<'static, Result<u64>> {
let model_id = self.model.request_id().to_string();
- let request = into_google(request, model_id.clone(), self.model.mode());
+ let request = into_google(request, model_id, self.model.mode());
let http_client = self.http_client.clone();
let api_key = self.state.read(cx).api_key.clone();
@@ -210,7 +210,7 @@ impl LanguageModelProvider for LmStudioLanguageModelProvider {
.map(|model| {
Arc::new(LmStudioLanguageModel {
id: LanguageModelId::from(model.name.clone()),
- model: model.clone(),
+ model,
http_client: self.http_client.clone(),
request_limiter: RateLimiter::new(4),
}) as Arc<dyn LanguageModel>
@@ -237,7 +237,7 @@ impl LanguageModelProvider for OllamaLanguageModelProvider {
.map(|model| {
Arc::new(OllamaLanguageModel {
id: LanguageModelId::from(model.name.clone()),
- model: model.clone(),
+ model,
http_client: self.http_client.clone(),
request_limiter: RateLimiter::new(4),
}) as Arc<dyn LanguageModel>
@@ -37,7 +37,7 @@ impl IntoElement for InstructionListItem {
let item_content = if let (Some(button_label), Some(button_link)) =
(self.button_label, self.button_link)
{
- let link = button_link.clone();
+ let link = button_link;
let unique_id = SharedString::from(format!("{}-button", self.label));
h_flex()
@@ -406,10 +406,7 @@ impl LogStore {
server_state.worktree_id = Some(worktree_id);
}
- if let Some(server) = server
- .clone()
- .filter(|_| server_state.io_logs_subscription.is_none())
- {
+ if let Some(server) = server.filter(|_| server_state.io_logs_subscription.is_none()) {
let io_tx = self.io_tx.clone();
let server_id = server.server_id();
server_state.io_logs_subscription = Some(server.on_io(move |io_kind, message| {
@@ -930,7 +927,7 @@ impl LspLogView {
let state = log_store.language_servers.get(&server_id)?;
Some(LogMenuItem {
server_id,
- server_name: name.clone(),
+ server_name: name,
server_kind: state.kind.clone(),
worktree_root_name: "supplementary".to_string(),
rpc_trace_enabled: state.rpc_state.is_some(),
@@ -1527,7 +1524,7 @@ impl Render for LspLogToolbarItemView {
.icon_color(Color::Muted),
)
.menu({
- let log_view = log_view.clone();
+ let log_view = log_view;
move |window, cx| {
let id = log_view.read(cx).current_server_id?;
@@ -1595,7 +1592,7 @@ impl Render for LspLogToolbarItemView {
.icon_color(Color::Muted),
)
.menu({
- let log_view = log_view.clone();
+ let log_view = log_view;
move |window, cx| {
let id = log_view.read(cx).current_server_id?;
@@ -156,7 +156,7 @@ impl SyntaxTreeView {
.buffer_snapshot
.range_to_buffer_ranges(selection_range)
.pop()?;
- let buffer = multi_buffer.buffer(buffer.remote_id()).unwrap().clone();
+ let buffer = multi_buffer.buffer(buffer.remote_id()).unwrap();
Some((buffer, range, excerpt_id))
})?;
@@ -22,7 +22,7 @@ impl CLspAdapter {
#[async_trait(?Send)]
impl super::LspAdapter for CLspAdapter {
fn name(&self) -> LanguageServerName {
- Self::SERVER_NAME.clone()
+ Self::SERVER_NAME
}
async fn check_if_user_installed(
@@ -253,8 +253,7 @@ impl super::LspAdapter for CLspAdapter {
.grammar()
.and_then(|g| g.highlight_id_for_name(highlight_name?))
{
- let mut label =
- CodeLabel::plain(label.to_string(), completion.filter_text.as_deref());
+ let mut label = CodeLabel::plain(label, completion.filter_text.as_deref());
label.runs.push((
0..label.text.rfind('(').unwrap_or(label.text.len()),
highlight_id,
@@ -264,10 +263,7 @@ impl super::LspAdapter for CLspAdapter {
}
_ => {}
}
- Some(CodeLabel::plain(
- label.to_string(),
- completion.filter_text.as_deref(),
- ))
+ Some(CodeLabel::plain(label, completion.filter_text.as_deref()))
}
async fn label_for_symbol(
@@ -53,7 +53,7 @@ const BINARY: &str = if cfg!(target_os = "windows") {
#[async_trait(?Send)]
impl super::LspAdapter for GoLspAdapter {
fn name(&self) -> LanguageServerName {
- Self::SERVER_NAME.clone()
+ Self::SERVER_NAME
}
async fn fetch_latest_server_version(
@@ -525,7 +525,7 @@ impl ContextProvider for GoContextProvider {
})
.unwrap_or_else(|| format!("{}", buffer_dir.to_string_lossy()));
- (GO_PACKAGE_TASK_VARIABLE.clone(), package_name.to_string())
+ (GO_PACKAGE_TASK_VARIABLE.clone(), package_name)
});
let go_module_root_variable = local_abs_path
@@ -702,7 +702,7 @@ impl ContextProvider for GoContextProvider {
label: format!("go generate {}", GO_PACKAGE_TASK_VARIABLE.template_value()),
command: "go".into(),
args: vec!["generate".into()],
- cwd: package_cwd.clone(),
+ cwd: package_cwd,
tags: vec!["go-generate".to_owned()],
..TaskTemplate::default()
},
@@ -710,7 +710,7 @@ impl ContextProvider for GoContextProvider {
label: "go generate ./...".into(),
command: "go".into(),
args: vec!["generate".into(), "./...".into()],
- cwd: module_cwd.clone(),
+ cwd: module_cwd,
..TaskTemplate::default()
},
])))
@@ -488,7 +488,7 @@ impl NodeVersionAdapter {
#[async_trait(?Send)]
impl LspAdapter for NodeVersionAdapter {
fn name(&self) -> LanguageServerName {
- Self::SERVER_NAME.clone()
+ Self::SERVER_NAME
}
async fn fetch_latest_server_version(
@@ -104,7 +104,7 @@ pub fn init(languages: Arc<LanguageRegistry>, node: NodeRuntime, cx: &mut App) {
let typescript_context = Arc::new(typescript::TypeScriptContextProvider::new());
let typescript_lsp_adapter = Arc::new(typescript::TypeScriptLspAdapter::new(node.clone()));
let vtsls_adapter = Arc::new(vtsls::VtslsLspAdapter::new(node.clone()));
- let yaml_lsp_adapter = Arc::new(yaml::YamlLspAdapter::new(node.clone()));
+ let yaml_lsp_adapter = Arc::new(yaml::YamlLspAdapter::new(node));
let built_in_languages = [
LanguageInfo {
@@ -119,12 +119,12 @@ pub fn init(languages: Arc<LanguageRegistry>, node: NodeRuntime, cx: &mut App) {
},
LanguageInfo {
name: "cpp",
- adapters: vec![c_lsp_adapter.clone()],
+ adapters: vec![c_lsp_adapter],
..Default::default()
},
LanguageInfo {
name: "css",
- adapters: vec![css_lsp_adapter.clone()],
+ adapters: vec![css_lsp_adapter],
..Default::default()
},
LanguageInfo {
@@ -146,20 +146,20 @@ pub fn init(languages: Arc<LanguageRegistry>, node: NodeRuntime, cx: &mut App) {
},
LanguageInfo {
name: "gowork",
- adapters: vec![go_lsp_adapter.clone()],
- context: Some(go_context_provider.clone()),
+ adapters: vec![go_lsp_adapter],
+ context: Some(go_context_provider),
..Default::default()
},
LanguageInfo {
name: "json",
- adapters: vec![json_lsp_adapter.clone(), node_version_lsp_adapter.clone()],
+ adapters: vec![json_lsp_adapter.clone(), node_version_lsp_adapter],
context: Some(json_context_provider.clone()),
..Default::default()
},
LanguageInfo {
name: "jsonc",
- adapters: vec![json_lsp_adapter.clone()],
- context: Some(json_context_provider.clone()),
+ adapters: vec![json_lsp_adapter],
+ context: Some(json_context_provider),
..Default::default()
},
LanguageInfo {
@@ -174,7 +174,7 @@ pub fn init(languages: Arc<LanguageRegistry>, node: NodeRuntime, cx: &mut App) {
},
LanguageInfo {
name: "python",
- adapters: vec![python_lsp_adapter.clone(), py_lsp_adapter.clone()],
+ adapters: vec![python_lsp_adapter, py_lsp_adapter],
context: Some(python_context_provider),
toolchain: Some(python_toolchain_provider),
manifest_name: Some(SharedString::new_static("pyproject.toml").into()),
@@ -201,7 +201,7 @@ pub fn init(languages: Arc<LanguageRegistry>, node: NodeRuntime, cx: &mut App) {
LanguageInfo {
name: "javascript",
adapters: vec![typescript_lsp_adapter.clone(), vtsls_adapter.clone()],
- context: Some(typescript_context.clone()),
+ context: Some(typescript_context),
..Default::default()
},
LanguageInfo {
@@ -277,13 +277,13 @@ pub fn init(languages: Arc<LanguageRegistry>, node: NodeRuntime, cx: &mut App) {
move || adapter.clone()
});
languages.register_available_lsp_adapter(LanguageServerName("vtsls".into()), {
- let adapter = vtsls_adapter.clone();
+ let adapter = vtsls_adapter;
move || adapter.clone()
});
languages.register_available_lsp_adapter(
LanguageServerName("typescript-language-server".into()),
{
- let adapter = typescript_lsp_adapter.clone();
+ let adapter = typescript_lsp_adapter;
move || adapter.clone()
},
);
@@ -103,7 +103,7 @@ impl PythonLspAdapter {
#[async_trait(?Send)]
impl LspAdapter for PythonLspAdapter {
fn name(&self) -> LanguageServerName {
- Self::SERVER_NAME.clone()
+ Self::SERVER_NAME
}
async fn initialization_options(
@@ -1026,7 +1026,7 @@ const BINARY_DIR: &str = if cfg!(target_os = "windows") {
#[async_trait(?Send)]
impl LspAdapter for PyLspAdapter {
fn name(&self) -> LanguageServerName {
- Self::SERVER_NAME.clone()
+ Self::SERVER_NAME
}
async fn check_if_user_installed(
@@ -1318,7 +1318,7 @@ impl BasedPyrightLspAdapter {
#[async_trait(?Send)]
impl LspAdapter for BasedPyrightLspAdapter {
fn name(&self) -> LanguageServerName {
- Self::SERVER_NAME.clone()
+ Self::SERVER_NAME
}
async fn initialization_options(
@@ -106,7 +106,7 @@ impl ManifestProvider for CargoManifestProvider {
#[async_trait(?Send)]
impl LspAdapter for RustLspAdapter {
fn name(&self) -> LanguageServerName {
- SERVER_NAME.clone()
+ SERVER_NAME
}
async fn check_if_user_installed(
@@ -659,7 +659,7 @@ impl ContextProvider for RustContextProvider {
.variables
.get(CUSTOM_TARGET_DIR)
.cloned();
- let run_task_args = if let Some(package_to_run) = package_to_run.clone() {
+ let run_task_args = if let Some(package_to_run) = package_to_run {
vec!["run".into(), "-p".into(), package_to_run]
} else {
vec!["run".into()]
@@ -1019,8 +1019,8 @@ async fn get_cached_server_binary(container_dir: PathBuf) -> Option<LanguageServ
let path = last.context("no cached binary")?;
let path = match RustLspAdapter::GITHUB_ASSET_KIND {
- AssetKind::TarGz | AssetKind::Gz => path.clone(), // Tar and gzip extract in place.
- AssetKind::Zip => path.clone().join("rust-analyzer.exe"), // zip contains a .exe
+ AssetKind::TarGz | AssetKind::Gz => path, // Tar and gzip extract in place.
+ AssetKind::Zip => path.join("rust-analyzer.exe"), // zip contains a .exe
};
anyhow::Ok(LanguageServerBinary {
@@ -44,7 +44,7 @@ impl TailwindLspAdapter {
#[async_trait(?Send)]
impl LspAdapter for TailwindLspAdapter {
fn name(&self) -> LanguageServerName {
- Self::SERVER_NAME.clone()
+ Self::SERVER_NAME
}
async fn check_if_user_installed(
@@ -557,7 +557,7 @@ struct TypeScriptVersions {
#[async_trait(?Send)]
impl LspAdapter for TypeScriptLspAdapter {
fn name(&self) -> LanguageServerName {
- Self::SERVER_NAME.clone()
+ Self::SERVER_NAME
}
async fn fetch_latest_server_version(
@@ -879,7 +879,7 @@ impl LspAdapter for EsLintLspAdapter {
}
fn name(&self) -> LanguageServerName {
- Self::SERVER_NAME.clone()
+ Self::SERVER_NAME
}
async fn fetch_latest_server_version(
@@ -67,7 +67,7 @@ const SERVER_NAME: LanguageServerName = LanguageServerName::new_static("vtsls");
#[async_trait(?Send)]
impl LspAdapter for VtslsLspAdapter {
fn name(&self) -> LanguageServerName {
- SERVER_NAME.clone()
+ SERVER_NAME
}
async fn fetch_latest_server_version(
@@ -38,7 +38,7 @@ impl YamlLspAdapter {
#[async_trait(?Send)]
impl LspAdapter for YamlLspAdapter {
fn name(&self) -> LanguageServerName {
- Self::SERVER_NAME.clone()
+ Self::SERVER_NAME
}
async fn fetch_latest_server_version(
@@ -183,7 +183,7 @@ impl LivekitWindow {
match track {
livekit_client::RemoteTrack::Audio(track) => {
output.audio_output_stream = Some((
- publication.clone(),
+ publication,
room.play_remote_audio_track(&track, cx).unwrap(),
));
}
@@ -117,7 +117,6 @@ impl AudioStack {
let (frame_tx, mut frame_rx) = futures::channel::mpsc::unbounded();
let transmit_task = self.executor.spawn({
- let source = source.clone();
async move {
while let Some(frame) = frame_rx.next().await {
source.capture_frame(&frame).await.log_err();
@@ -132,12 +131,12 @@ impl AudioStack {
drop(transmit_task);
drop(capture_task);
});
- return Ok((
+ Ok((
super::LocalAudioTrack(track),
AudioStream::Output {
_drop: Box::new(on_drop),
},
- ));
+ ))
}
fn start_output(&self) -> Arc<Task<()>> {
@@ -30,7 +30,7 @@ pub fn main() {
let node_runtime = NodeRuntime::unavailable();
let language_registry = Arc::new(LanguageRegistry::new(cx.background_executor().clone()));
- languages::init(language_registry.clone(), node_runtime, cx);
+ languages::init(language_registry, node_runtime, cx);
theme::init(LoadThemes::JustBase, cx);
Assets.load_fonts(cx).unwrap();
@@ -1323,8 +1323,7 @@ fn render_copy_code_block_button(
.shape(ui::IconButtonShape::Square)
.tooltip(Tooltip::text("Copy Code"))
.on_click({
- let id = id.clone();
- let markdown = markdown.clone();
+ let markdown = markdown;
move |_event, _window, cx| {
let id = id.clone();
markdown.update(cx, |this, cx| {
@@ -178,7 +178,6 @@ impl<'a> MarkdownParser<'a> {
_ => None,
},
Event::Rule => {
- let source_range = source_range.clone();
self.cursor += 1;
Some(vec![ParsedMarkdownElement::HorizontalRule(source_range)])
}
@@ -401,7 +400,7 @@ impl<'a> MarkdownParser<'a> {
}
if !text.is_empty() {
markdown_text_like.push(MarkdownParagraphChunk::Text(ParsedMarkdownText {
- source_range: source_range.clone(),
+ source_range,
contents: text,
highlights,
regions,
@@ -420,7 +419,7 @@ impl<'a> MarkdownParser<'a> {
self.cursor += 1;
ParsedMarkdownHeading {
- source_range: source_range.clone(),
+ source_range,
level: match level {
pulldown_cmark::HeadingLevel::H1 => HeadingLevel::H1,
pulldown_cmark::HeadingLevel::H2 => HeadingLevel::H2,
@@ -115,8 +115,7 @@ impl MarkdownPreviewView {
pane.activate_item(existing_follow_view_idx, true, true, window, cx);
});
} else {
- let view =
- Self::create_following_markdown_view(workspace, editor.clone(), window, cx);
+ let view = Self::create_following_markdown_view(workspace, editor, window, cx);
workspace.active_pane().update(cx, |pane, cx| {
pane.add_item(Box::new(view.clone()), true, true, None, window, cx)
});
@@ -20,14 +20,14 @@ fn replace_deprecated_settings_values(
.nodes_for_capture_index(parent_object_capture_ix)
.next()?
.byte_range();
- let parent_object_name = contents.get(parent_object_range.clone())?;
+ let parent_object_name = contents.get(parent_object_range)?;
let setting_name_ix = query.capture_index_for_name("setting_name")?;
let setting_name_range = mat
.nodes_for_capture_index(setting_name_ix)
.next()?
.byte_range();
- let setting_name = contents.get(setting_name_range.clone())?;
+ let setting_name = contents.get(setting_name_range)?;
let setting_value_ix = query.capture_index_for_name("setting_value")?;
let setting_value_range = mat
@@ -279,7 +279,7 @@ fn rename_context_key(
new_predicate = new_predicate.replace(old_key, new_key);
}
if new_predicate != old_predicate {
- Some((context_predicate_range, new_predicate.to_string()))
+ Some((context_predicate_range, new_predicate))
} else {
None
}
@@ -57,7 +57,7 @@ pub fn replace_edit_prediction_provider_setting(
.nodes_for_capture_index(parent_object_capture_ix)
.next()?
.byte_range();
- let parent_object_name = contents.get(parent_object_range.clone())?;
+ let parent_object_name = contents.get(parent_object_range)?;
let setting_name_ix = query.capture_index_for_name("setting_name")?;
let setting_range = mat
@@ -25,7 +25,7 @@ fn replace_tab_close_button_setting_key(
.nodes_for_capture_index(parent_object_capture_ix)
.next()?
.byte_range();
- let parent_object_name = contents.get(parent_object_range.clone())?;
+ let parent_object_name = contents.get(parent_object_range)?;
let setting_name_ix = query.capture_index_for_name("setting_name")?;
let setting_range = mat
@@ -51,14 +51,14 @@ fn replace_tab_close_button_setting_value(
.nodes_for_capture_index(parent_object_capture_ix)
.next()?
.byte_range();
- let parent_object_name = contents.get(parent_object_range.clone())?;
+ let parent_object_name = contents.get(parent_object_range)?;
let setting_name_ix = query.capture_index_for_name("setting_name")?;
let setting_name_range = mat
.nodes_for_capture_index(setting_name_ix)
.next()?
.byte_range();
- let setting_name = contents.get(setting_name_range.clone())?;
+ let setting_name = contents.get(setting_name_range)?;
let setting_value_ix = query.capture_index_for_name("setting_value")?;
let setting_value_range = mat
@@ -19,7 +19,7 @@ fn replace_setting_value(
.nodes_for_capture_index(setting_capture_ix)
.next()?
.byte_range();
- let setting_name = contents.get(setting_name_range.clone())?;
+ let setting_name = contents.get(setting_name_range)?;
if setting_name != "hide_mouse_while_typing" {
return None;
@@ -19,7 +19,7 @@ fn replace_preferred_completion_mode_value(
.nodes_for_capture_index(parent_object_capture_ix)
.next()?
.byte_range();
- let parent_object_name = contents.get(parent_object_range.clone())?;
+ let parent_object_name = contents.get(parent_object_range)?;
if parent_object_name != "agent" {
return None;
@@ -30,7 +30,7 @@ fn replace_preferred_completion_mode_value(
.nodes_for_capture_index(setting_name_capture_ix)
.next()?
.byte_range();
- let setting_name = contents.get(setting_name_range.clone())?;
+ let setting_name = contents.get(setting_name_range)?;
if setting_name != "preferred_completion_mode" {
return None;
@@ -2427,7 +2427,7 @@ impl MultiBuffer {
cx.emit(match event {
language::BufferEvent::Edited => Event::Edited {
singleton_buffer_edited: true,
- edited_buffer: Some(buffer.clone()),
+ edited_buffer: Some(buffer),
},
language::BufferEvent::DirtyChanged => Event::DirtyChanged,
language::BufferEvent::Saved => Event::Saved,
@@ -3560,9 +3560,7 @@ impl MultiBuffer {
let multi = cx.new(|_| Self::new(Capability::ReadWrite));
for (text, ranges) in excerpts {
let buffer = cx.new(|cx| Buffer::local(text, cx));
- let excerpt_ranges = ranges
- .into_iter()
- .map(|range| ExcerptRange::new(range.clone()));
+ let excerpt_ranges = ranges.into_iter().map(ExcerptRange::new);
multi.update(cx, |multi, cx| {
multi.push_excerpts(buffer, excerpt_ranges, cx)
});
@@ -126,7 +126,7 @@ fn render_theme_section(tab_index: &mut isize, cx: &mut App) -> impl IntoElement
.gap_1()
.child(
h_flex()
- .id(name.clone())
+ .id(name)
.relative()
.w_full()
.border_2()
@@ -201,7 +201,7 @@ fn render_theme_section(tab_index: &mut isize, cx: &mut App) -> impl IntoElement
});
} else {
let appearance = *SystemAppearance::global(cx);
- settings.set_theme(theme.clone(), appearance);
+ settings.set_theme(theme, appearance);
}
});
}
@@ -104,7 +104,7 @@ fn write_ui_font_family(font: SharedString, cx: &mut App) {
"Welcome Font Changed",
type = "ui font",
old = theme_settings.ui_font_family,
- new = font.clone()
+ new = font
);
theme_settings.ui_font_family = Some(FontFamilyName(font.into()));
});
@@ -134,7 +134,7 @@ fn write_buffer_font_family(font_family: SharedString, cx: &mut App) {
"Welcome Font Changed",
type = "editor font",
old = theme_settings.buffer_font_family,
- new = font_family.clone()
+ new = font_family
);
theme_settings.buffer_font_family = Some(FontFamilyName(font_family.into()));
@@ -314,7 +314,7 @@ fn render_font_customization_section(
.child(
PopoverMenu::new("ui-font-picker")
.menu({
- let ui_font_picker = ui_font_picker.clone();
+ let ui_font_picker = ui_font_picker;
move |_window, _cx| Some(ui_font_picker.clone())
})
.trigger(
@@ -378,7 +378,7 @@ fn render_font_customization_section(
.child(
PopoverMenu::new("buffer-font-picker")
.menu({
- let buffer_font_picker = buffer_font_picker.clone();
+ let buffer_font_picker = buffer_font_picker;
move |_window, _cx| Some(buffer_font_picker.clone())
})
.trigger(
@@ -206,7 +206,7 @@ impl ThemePreviewTile {
sidebar_width,
skeleton_height.clone(),
))
- .child(Self::render_pane(seed, theme, skeleton_height.clone()))
+ .child(Self::render_pane(seed, theme, skeleton_height))
}
fn render_borderless(seed: f32, theme: Arc<Theme>) -> impl IntoElement {
@@ -260,7 +260,7 @@ impl ThemePreviewTile {
.overflow_hidden()
.child(div().size_full().child(Self::render_editor(
seed,
- theme.clone(),
+ theme,
sidebar_width,
Self::SKELETON_HEIGHT_DEFAULT,
)))
@@ -329,9 +329,9 @@ impl Component for ThemePreviewTile {
let themes_to_preview = vec![
one_dark.clone().ok(),
- one_light.clone().ok(),
- gruvbox_dark.clone().ok(),
- gruvbox_light.clone().ok(),
+ one_light.ok(),
+ gruvbox_dark.ok(),
+ gruvbox_light.ok(),
]
.into_iter()
.flatten()
@@ -348,7 +348,7 @@ impl Component for ThemePreviewTile {
div()
.w(px(240.))
.h(px(180.))
- .child(ThemePreviewTile::new(one_dark.clone(), 0.42))
+ .child(ThemePreviewTile::new(one_dark, 0.42))
.into_any_element(),
)])]
} else {
@@ -5091,7 +5091,7 @@ impl Panel for OutlinePanel {
impl Focusable for OutlinePanel {
fn focus_handle(&self, cx: &App) -> FocusHandle {
- self.filter_editor.focus_handle(cx).clone()
+ self.filter_editor.focus_handle(cx)
}
}
@@ -52,7 +52,7 @@ impl RenderOnce for PanelTab {
pub fn panel_button(label: impl Into<SharedString>) -> ui::Button {
let label = label.into();
- let id = ElementId::Name(label.clone().to_lowercase().replace(' ', "_").into());
+ let id = ElementId::Name(label.to_lowercase().replace(' ', "_").into());
ui::Button::new(id, label)
.label_size(ui::LabelSize::Small)
.icon_size(ui::IconSize::Small)
@@ -85,7 +85,7 @@ where
.menu(move |_window, _cx| Some(picker.clone()))
.trigger_with_tooltip(self.trigger, self.tooltip)
.anchor(self.anchor)
- .when_some(self.handle.clone(), |menu, handle| menu.with_handle(handle))
+ .when_some(self.handle, |menu, handle| menu.with_handle(handle))
.offset(gpui::Point {
x: px(0.0),
y: px(-2.0),
@@ -168,7 +168,7 @@ impl RemoteBufferStore {
.with_context(|| {
format!("no worktree found for id {}", file.worktree_id)
})?;
- buffer_file = Some(Arc::new(File::from_proto(file, worktree.clone(), cx)?)
+ buffer_file = Some(Arc::new(File::from_proto(file, worktree, cx)?)
as Arc<dyn language::File>);
}
Buffer::from_proto(replica_id, capability, state, buffer_file)
@@ -591,7 +591,7 @@ impl LocalBufferStore {
else {
return Task::ready(Err(anyhow!("no such worktree")));
};
- self.save_local_buffer(buffer, worktree, path.path.clone(), true, cx)
+ self.save_local_buffer(buffer, worktree, path.path, true, cx)
}
fn open_buffer(
@@ -845,7 +845,7 @@ impl BufferStore {
) -> Task<Result<()>> {
match &mut self.state {
BufferStoreState::Local(this) => this.save_buffer(buffer, cx),
- BufferStoreState::Remote(this) => this.save_remote_buffer(buffer.clone(), None, cx),
+ BufferStoreState::Remote(this) => this.save_remote_buffer(buffer, None, cx),
}
}
@@ -1138,7 +1138,7 @@ impl BufferStore {
envelope: TypedEnvelope<proto::UpdateBuffer>,
mut cx: AsyncApp,
) -> Result<proto::Ack> {
- let payload = envelope.payload.clone();
+ let payload = envelope.payload;
let buffer_id = BufferId::new(payload.buffer_id)?;
let ops = payload
.operations
@@ -760,7 +760,7 @@ mod tests {
&store,
vec![
(server_1_id.clone(), ContextServerStatus::Starting),
- (server_1_id.clone(), ContextServerStatus::Running),
+ (server_1_id, ContextServerStatus::Running),
(server_2_id.clone(), ContextServerStatus::Starting),
(server_2_id.clone(), ContextServerStatus::Running),
(server_2_id.clone(), ContextServerStatus::Stopped),
@@ -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();
}
@@ -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
})
}
@@ -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>) {
@@ -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)
}
@@ -769,7 +769,7 @@ impl GitStore {
.as_ref()
.and_then(|weak| weak.upgrade())
{
- let conflict_set = conflict_set.clone();
+ let conflict_set = conflict_set;
let buffer_snapshot = buffer.read(cx).text_snapshot();
git_state.update(cx, |state, cx| {
@@ -912,7 +912,7 @@ impl GitStore {
return Task::ready(Err(anyhow!("failed to find a git repository for buffer")));
};
let content = match &version {
- Some(version) => buffer.rope_for_version(version).clone(),
+ Some(version) => buffer.rope_for_version(version),
None => buffer.as_rope().clone(),
};
let version = version.unwrap_or(buffer.version());
@@ -1506,10 +1506,7 @@ impl GitStore {
let mut update = envelope.payload;
let id = RepositoryId::from_proto(update.id);
- let client = this
- .upstream_client()
- .context("no upstream client")?
- .clone();
+ let client = this.upstream_client().context("no upstream client")?;
let mut is_new = false;
let repo = this.repositories.entry(id).or_insert_with(|| {
@@ -3418,7 +3415,6 @@ impl Repository {
reset_mode: ResetMode,
_cx: &mut App,
) -> oneshot::Receiver<Result<()>> {
- let commit = commit.to_string();
let id = self.id;
self.send_job(None, move |git_repo, _| async move {
@@ -3644,7 +3640,7 @@ impl Repository {
let to_stage = self
.cached_status()
.filter(|entry| !entry.status.staging().is_fully_staged())
- .map(|entry| entry.repo_path.clone())
+ .map(|entry| entry.repo_path)
.collect();
self.stage_entries(to_stage, cx)
}
@@ -3653,16 +3649,13 @@ impl Repository {
let to_unstage = self
.cached_status()
.filter(|entry| entry.status.staging().has_staged())
- .map(|entry| entry.repo_path.clone())
+ .map(|entry| entry.repo_path)
.collect();
self.unstage_entries(to_unstage, cx)
}
pub fn stash_all(&mut self, cx: &mut Context<Self>) -> Task<anyhow::Result<()>> {
- let to_stash = self
- .cached_status()
- .map(|entry| entry.repo_path.clone())
- .collect();
+ let to_stash = self.cached_status().map(|entry| entry.repo_path).collect();
self.stash_entries(to_stash, cx)
}
@@ -369,7 +369,7 @@ mod tests {
.unindent();
let buffer_id = BufferId::new(1).unwrap();
- let buffer = Buffer::new(0, buffer_id, test_content.to_string());
+ let buffer = Buffer::new(0, buffer_id, test_content);
let snapshot = buffer.snapshot();
let conflict_snapshot = ConflictSet::parse(&snapshot);
@@ -400,7 +400,7 @@ mod tests {
>>>>>>> "#
.unindent();
let buffer_id = BufferId::new(1).unwrap();
- let buffer = Buffer::new(0, buffer_id, test_content.to_string());
+ let buffer = Buffer::new(0, buffer_id, test_content);
let snapshot = buffer.snapshot();
let conflict_snapshot = ConflictSet::parse(&snapshot);
@@ -244,7 +244,7 @@ impl ProjectItem for ImageItem {
}
fn project_path(&self, cx: &App) -> Option<ProjectPath> {
- Some(self.project_path(cx).clone())
+ Some(self.project_path(cx))
}
fn is_dirty(&self) -> bool {
@@ -375,7 +375,6 @@ impl ImageStore {
let (mut tx, rx) = postage::watch::channel();
entry.insert(rx.clone());
- let project_path = project_path.clone();
let load_image = self
.state
.open_image(project_path.path.clone(), worktree, cx);
@@ -2739,7 +2739,7 @@ impl GetCodeActions {
Some(lsp::CodeActionProviderCapability::Options(CodeActionOptions {
code_action_kinds: Some(supported_action_kinds),
..
- })) => Some(supported_action_kinds.clone()),
+ })) => Some(supported_action_kinds),
_ => capabilities.code_action_kinds,
}
}
@@ -3793,7 +3793,7 @@ impl GetDocumentDiagnostics {
},
uri: lsp::Url::parse(&info.location_url.unwrap()).unwrap(),
},
- message: info.message.clone(),
+ message: info.message,
}
})
.collect::<Vec<_>>();
@@ -4491,9 +4491,8 @@ mod tests {
data: Some(json!({"detail": "test detail"})),
};
- let proto_diagnostic =
- GetDocumentDiagnostics::serialize_lsp_diagnostic(lsp_diagnostic.clone())
- .expect("Failed to serialize diagnostic");
+ let proto_diagnostic = GetDocumentDiagnostics::serialize_lsp_diagnostic(lsp_diagnostic)
+ .expect("Failed to serialize diagnostic");
let start = proto_diagnostic.start.unwrap();
let end = proto_diagnostic.end.unwrap();
@@ -917,7 +917,7 @@ impl LocalLspStore {
message: params.message,
actions: vec![],
response_channel: tx,
- lsp_name: name.clone(),
+ lsp_name: name,
};
let _ = this.update(&mut cx, |_, cx| {
@@ -2954,7 +2954,7 @@ impl LocalLspStore {
.update(cx, |this, cx| {
let path = buffer_to_edit.read(cx).project_path(cx);
let active_entry = this.active_entry;
- let is_active_entry = path.clone().is_some_and(|project_path| {
+ let is_active_entry = path.is_some_and(|project_path| {
this.worktree_store
.read(cx)
.entry_for_path(&project_path, cx)
@@ -5688,10 +5688,7 @@ impl LspStore {
let all_actions_task = self.request_multiple_lsp_locally(
buffer,
Some(range.start),
- GetCodeActions {
- range: range.clone(),
- kinds: kinds.clone(),
- },
+ GetCodeActions { range, kinds },
cx,
);
cx.background_spawn(async move {
@@ -7221,7 +7218,7 @@ impl LspStore {
worktree = tree;
path = rel_path;
} else {
- worktree = source_worktree.clone();
+ worktree = source_worktree;
path = relativize_path(&result.worktree_abs_path, &abs_path);
}
@@ -10338,7 +10335,7 @@ impl LspStore {
let name = self
.language_server_statuses
.remove(&server_id)
- .map(|status| status.name.clone())
+ .map(|status| status.name)
.or_else(|| {
if let Some(LanguageServerState::Running { adapter, .. }) = server_state.as_ref() {
Some(adapter.name())
@@ -58,7 +58,7 @@ pub fn register_notifications(
language_server
.on_notification::<InactiveRegions, _>({
- let adapter = adapter.clone();
+ let adapter = adapter;
let this = lsp_store;
move |params: InactiveRegionsParams, cx| {
@@ -34,7 +34,6 @@ pub fn register_notifications(lsp_store: WeakEntity<LspStore>, language_server:
language_server
.on_notification::<ServerStatus, _>({
- let name = name.clone();
move |params, cx| {
let message = params.message;
let log_message = message.as_ref().map(|message| {
@@ -2502,7 +2502,7 @@ impl Project {
path: ProjectPath,
cx: &mut Context<Self>,
) -> Task<Result<(Option<ProjectEntryId>, Entity<Buffer>)>> {
- let task = self.open_buffer(path.clone(), cx);
+ let task = self.open_buffer(path, cx);
cx.spawn(async move |_project, cx| {
let buffer = task.await?;
let project_entry_id = buffer.read_with(cx, |buffer, cx| {
@@ -3170,7 +3170,7 @@ impl Project {
if let ImageItemEvent::ReloadNeeded = event
&& !self.is_via_collab()
{
- self.reload_images([image.clone()].into_iter().collect(), cx)
+ self.reload_images([image].into_iter().collect(), cx)
.detach_and_log_err(cx);
}
@@ -3652,7 +3652,7 @@ impl Project {
cx: &mut Context<Self>,
) -> Task<Result<Vec<CodeAction>>> {
let snapshot = buffer.read(cx).snapshot();
- let range = range.clone().to_owned().to_point(&snapshot);
+ let range = range.to_point(&snapshot);
let range_start = snapshot.anchor_before(range.start);
let range_end = if range.start == range.end {
range_start
@@ -1818,7 +1818,7 @@ async fn test_restarting_server_with_diagnostics_published(cx: &mut gpui::TestAp
buffer
.snapshot()
.diagnostics_in_range::<_, usize>(0..1, false)
- .map(|entry| entry.diagnostic.message.clone())
+ .map(|entry| entry.diagnostic.message)
.collect::<Vec<_>>(),
["the message".to_string()]
);
@@ -1844,7 +1844,7 @@ async fn test_restarting_server_with_diagnostics_published(cx: &mut gpui::TestAp
buffer
.snapshot()
.diagnostics_in_range::<_, usize>(0..1, false)
- .map(|entry| entry.diagnostic.message.clone())
+ .map(|entry| entry.diagnostic.message)
.collect::<Vec<_>>(),
Vec::<String>::new(),
);
@@ -3712,7 +3712,7 @@ async fn test_save_file_spawns_language_server(cx: &mut gpui::TestAppContext) {
async fn test_file_changes_multiple_times_on_disk(cx: &mut gpui::TestAppContext) {
init_test(cx);
- let fs = FakeFs::new(cx.executor().clone());
+ let fs = FakeFs::new(cx.executor());
fs.insert_tree(
path!("/dir"),
json!({
@@ -3767,7 +3767,7 @@ async fn test_file_changes_multiple_times_on_disk(cx: &mut gpui::TestAppContext)
async fn test_edit_buffer_while_it_reloads(cx: &mut gpui::TestAppContext) {
init_test(cx);
- let fs = FakeFs::new(cx.executor().clone());
+ let fs = FakeFs::new(cx.executor());
fs.insert_tree(
path!("/dir"),
json!({
@@ -5897,7 +5897,7 @@ async fn test_search_with_unicode(cx: &mut gpui::TestAppContext) {
async fn test_create_entry(cx: &mut gpui::TestAppContext) {
init_test(cx);
- let fs = FakeFs::new(cx.executor().clone());
+ let fs = FakeFs::new(cx.executor());
fs.insert_tree(
"/one/two",
json!({
@@ -760,7 +760,7 @@ impl Inventory {
TaskSettingsLocation::Global(path) => {
previously_existing_scenarios = parsed_scenarios
.global_scenarios()
- .map(|(_, scenario)| scenario.label.clone())
+ .map(|(_, scenario)| scenario.label)
.collect::<HashSet<_>>();
parsed_scenarios
.global
@@ -770,7 +770,7 @@ impl Inventory {
TaskSettingsLocation::Worktree(location) => {
previously_existing_scenarios = parsed_scenarios
.worktree_scenarios(location.worktree_id)
- .map(|(_, scenario)| scenario.label.clone())
+ .map(|(_, scenario)| scenario.label)
.collect::<HashSet<_>>();
if new_templates.is_empty() {
@@ -89,7 +89,7 @@ impl Project {
let ssh_client = ssh_client.read(cx);
if let Some((SshArgs { arguments, envs }, path_style)) = ssh_client.ssh_info() {
return Some(SshDetails {
- host: ssh_client.connection_options().host.clone(),
+ host: ssh_client.connection_options().host,
ssh_command: SshCommand { arguments },
envs,
path_style,
@@ -457,7 +457,7 @@ impl WorktreeStore {
})
.collect::<HashMap<_, _>>();
- let (client, project_id) = self.upstream_client().clone().context("invalid project")?;
+ let (client, project_id) = self.upstream_client().context("invalid project")?;
for worktree in worktrees {
if let Some(old_worktree) =
@@ -447,7 +447,7 @@ impl ProjectPanel {
cx.subscribe(&project, |this, project, event, cx| match event {
project::Event::ActiveEntryChanged(Some(entry_id)) => {
if ProjectPanelSettings::get_global(cx).auto_reveal_entries {
- this.reveal_entry(project.clone(), *entry_id, true, cx).ok();
+ this.reveal_entry(project, *entry_id, true, cx).ok();
}
}
project::Event::ActiveEntryChanged(None) => {
@@ -462,10 +462,7 @@ impl ProjectPanel {
}
}
project::Event::RevealInProjectPanel(entry_id) => {
- if let Some(()) = this
- .reveal_entry(project.clone(), *entry_id, false, cx)
- .log_err()
- {
+ if let Some(()) = this.reveal_entry(project, *entry_id, false, cx).log_err() {
cx.emit(PanelEvent::Activate);
}
}
@@ -813,7 +810,7 @@ impl ProjectPanel {
diagnostic_severity: DiagnosticSeverity,
) {
diagnostics
- .entry((project_path.worktree_id, path_buffer.clone()))
+ .entry((project_path.worktree_id, path_buffer))
.and_modify(|strongest_diagnostic_severity| {
*strongest_diagnostic_severity =
cmp::min(*strongest_diagnostic_severity, diagnostic_severity);
@@ -2780,7 +2777,7 @@ impl ProjectPanel {
let destination_worktree = self.project.update(cx, |project, cx| {
let entry_path = project.path_for_entry(entry_to_move, cx)?;
- let destination_entry_path = project.path_for_entry(destination, cx)?.path.clone();
+ let destination_entry_path = project.path_for_entry(destination, cx)?.path;
let mut destination_path = destination_entry_path.as_ref();
if destination_is_file {
@@ -4023,8 +4020,8 @@ impl ProjectPanel {
.as_ref()
.map_or(ValidationState::None, |e| e.validation_state.clone())
{
- ValidationState::Error(msg) => Some((Color::Error.color(cx), msg.clone())),
- ValidationState::Warning(msg) => Some((Color::Warning.color(cx), msg.clone())),
+ ValidationState::Error(msg) => Some((Color::Error.color(cx), msg)),
+ ValidationState::Warning(msg) => Some((Color::Warning.color(cx), msg)),
ValidationState::None => None,
}
} else {
@@ -5505,7 +5502,7 @@ impl Render for ProjectPanel {
.with_priority(3)
}))
} else {
- let focus_handle = self.focus_handle(cx).clone();
+ let focus_handle = self.focus_handle(cx);
v_flex()
.id("empty-project_panel")
@@ -17,7 +17,7 @@ use workspace::{
async fn test_visible_list(cx: &mut gpui::TestAppContext) {
init_test(cx);
- let fs = FakeFs::new(cx.executor().clone());
+ let fs = FakeFs::new(cx.executor());
fs.insert_tree(
"/root1",
json!({
@@ -106,7 +106,7 @@ async fn test_visible_list(cx: &mut gpui::TestAppContext) {
async fn test_opening_file(cx: &mut gpui::TestAppContext) {
init_test_with_editor(cx);
- let fs = FakeFs::new(cx.executor().clone());
+ let fs = FakeFs::new(cx.executor());
fs.insert_tree(
path!("/src"),
json!({
@@ -276,7 +276,7 @@ async fn test_exclusions_in_visible_list(cx: &mut gpui::TestAppContext) {
async fn test_auto_collapse_dir_paths(cx: &mut gpui::TestAppContext) {
init_test(cx);
- let fs = FakeFs::new(cx.executor().clone());
+ let fs = FakeFs::new(cx.executor());
fs.insert_tree(
path!("/root1"),
json!({
@@ -459,7 +459,7 @@ async fn test_auto_collapse_dir_paths(cx: &mut gpui::TestAppContext) {
async fn test_editing_files(cx: &mut gpui::TestAppContext) {
init_test(cx);
- let fs = FakeFs::new(cx.executor().clone());
+ let fs = FakeFs::new(cx.executor());
fs.insert_tree(
"/root1",
json!({
@@ -877,7 +877,7 @@ async fn test_editing_files(cx: &mut gpui::TestAppContext) {
async fn test_adding_directories_via_file(cx: &mut gpui::TestAppContext) {
init_test(cx);
- let fs = FakeFs::new(cx.executor().clone());
+ let fs = FakeFs::new(cx.executor());
fs.insert_tree(
"/root1",
json!({
@@ -1010,7 +1010,7 @@ async fn test_adding_directories_via_file(cx: &mut gpui::TestAppContext) {
async fn test_adding_directory_via_file(cx: &mut gpui::TestAppContext) {
init_test(cx);
- let fs = FakeFs::new(cx.executor().clone());
+ let fs = FakeFs::new(cx.executor());
fs.insert_tree(
path!("/root1"),
json!({
@@ -1137,7 +1137,7 @@ async fn test_adding_directory_via_file(cx: &mut gpui::TestAppContext) {
async fn test_copy_paste(cx: &mut gpui::TestAppContext) {
init_test(cx);
- let fs = FakeFs::new(cx.executor().clone());
+ let fs = FakeFs::new(cx.executor());
fs.insert_tree(
"/root1",
json!({
@@ -1235,7 +1235,7 @@ async fn test_copy_paste(cx: &mut gpui::TestAppContext) {
async fn test_cut_paste(cx: &mut gpui::TestAppContext) {
init_test(cx);
- let fs = FakeFs::new(cx.executor().clone());
+ let fs = FakeFs::new(cx.executor());
fs.insert_tree(
"/root",
json!({
@@ -1320,7 +1320,7 @@ async fn test_cut_paste(cx: &mut gpui::TestAppContext) {
async fn test_cut_paste_between_different_worktrees(cx: &mut gpui::TestAppContext) {
init_test(cx);
- let fs = FakeFs::new(cx.executor().clone());
+ let fs = FakeFs::new(cx.executor());
fs.insert_tree(
"/root1",
json!({
@@ -1416,7 +1416,7 @@ async fn test_cut_paste_between_different_worktrees(cx: &mut gpui::TestAppContex
async fn test_copy_paste_between_different_worktrees(cx: &mut gpui::TestAppContext) {
init_test(cx);
- let fs = FakeFs::new(cx.executor().clone());
+ let fs = FakeFs::new(cx.executor());
fs.insert_tree(
"/root1",
json!({
@@ -1551,7 +1551,7 @@ async fn test_copy_paste_between_different_worktrees(cx: &mut gpui::TestAppConte
async fn test_copy_paste_directory(cx: &mut gpui::TestAppContext) {
init_test(cx);
- let fs = FakeFs::new(cx.executor().clone());
+ let fs = FakeFs::new(cx.executor());
fs.insert_tree(
"/root",
json!({
@@ -1692,7 +1692,7 @@ async fn test_copy_paste_directory(cx: &mut gpui::TestAppContext) {
async fn test_copy_paste_directory_with_sibling_file(cx: &mut gpui::TestAppContext) {
init_test(cx);
- let fs = FakeFs::new(cx.executor().clone());
+ let fs = FakeFs::new(cx.executor());
fs.insert_tree(
"/test",
json!({
@@ -1797,7 +1797,7 @@ async fn test_copy_paste_directory_with_sibling_file(cx: &mut gpui::TestAppConte
async fn test_copy_paste_nested_and_root_entries(cx: &mut gpui::TestAppContext) {
init_test(cx);
- let fs = FakeFs::new(cx.executor().clone());
+ let fs = FakeFs::new(cx.executor());
fs.insert_tree(
"/test",
json!({
@@ -1876,7 +1876,7 @@ async fn test_copy_paste_nested_and_root_entries(cx: &mut gpui::TestAppContext)
async fn test_remove_opened_file(cx: &mut gpui::TestAppContext) {
init_test_with_editor(cx);
- let fs = FakeFs::new(cx.executor().clone());
+ let fs = FakeFs::new(cx.executor());
fs.insert_tree(
path!("/src"),
json!({
@@ -1968,7 +1968,7 @@ async fn test_remove_opened_file(cx: &mut gpui::TestAppContext) {
async fn test_create_duplicate_items(cx: &mut gpui::TestAppContext) {
init_test_with_editor(cx);
- let fs = FakeFs::new(cx.executor().clone());
+ let fs = FakeFs::new(cx.executor());
fs.insert_tree(
"/src",
json!({
@@ -2161,7 +2161,7 @@ async fn test_create_duplicate_items(cx: &mut gpui::TestAppContext) {
async fn test_select_git_entry(cx: &mut gpui::TestAppContext) {
init_test_with_editor(cx);
- let fs = FakeFs::new(cx.executor().clone());
+ let fs = FakeFs::new(cx.executor());
fs.insert_tree(
path!("/root"),
json!({
@@ -2440,7 +2440,7 @@ async fn test_select_git_entry(cx: &mut gpui::TestAppContext) {
async fn test_select_directory(cx: &mut gpui::TestAppContext) {
init_test_with_editor(cx);
- let fs = FakeFs::new(cx.executor().clone());
+ let fs = FakeFs::new(cx.executor());
fs.insert_tree(
"/project_root",
json!({
@@ -2541,7 +2541,7 @@ async fn test_select_directory(cx: &mut gpui::TestAppContext) {
async fn test_select_first_last(cx: &mut gpui::TestAppContext) {
init_test_with_editor(cx);
- let fs = FakeFs::new(cx.executor().clone());
+ let fs = FakeFs::new(cx.executor());
fs.insert_tree(
"/project_root",
json!({
@@ -2651,7 +2651,7 @@ async fn test_select_first_last(cx: &mut gpui::TestAppContext) {
async fn test_dir_toggle_collapse(cx: &mut gpui::TestAppContext) {
init_test_with_editor(cx);
- let fs = FakeFs::new(cx.executor().clone());
+ let fs = FakeFs::new(cx.executor());
fs.insert_tree(
"/project_root",
json!({
@@ -2693,7 +2693,7 @@ async fn test_dir_toggle_collapse(cx: &mut gpui::TestAppContext) {
async fn test_collapse_all_entries(cx: &mut gpui::TestAppContext) {
init_test_with_editor(cx);
- let fs = FakeFs::new(cx.executor().clone());
+ let fs = FakeFs::new(cx.executor());
fs.insert_tree(
"/project_root",
json!({
@@ -2751,7 +2751,7 @@ async fn test_collapse_all_entries(cx: &mut gpui::TestAppContext) {
async fn test_new_file_move(cx: &mut gpui::TestAppContext) {
init_test(cx);
- let fs = FakeFs::new(cx.executor().clone());
+ let fs = FakeFs::new(cx.executor());
fs.as_fake().insert_tree(path!("/root"), json!({})).await;
let project = Project::test(fs, [path!("/root").as_ref()], cx).await;
let workspace = cx.add_window(|window, cx| Workspace::test_new(project.clone(), window, cx));
@@ -2819,7 +2819,7 @@ async fn test_new_file_move(cx: &mut gpui::TestAppContext) {
async fn test_rename_root_of_worktree(cx: &mut gpui::TestAppContext) {
init_test_with_editor(cx);
- let fs = FakeFs::new(cx.executor().clone());
+ let fs = FakeFs::new(cx.executor());
fs.insert_tree(
"/root1",
json!({
@@ -2895,7 +2895,7 @@ async fn test_rename_root_of_worktree(cx: &mut gpui::TestAppContext) {
async fn test_rename_with_hide_root(cx: &mut gpui::TestAppContext) {
init_test_with_editor(cx);
- let fs = FakeFs::new(cx.executor().clone());
+ let fs = FakeFs::new(cx.executor());
fs.insert_tree(
"/root1",
json!({
@@ -2989,7 +2989,7 @@ async fn test_rename_with_hide_root(cx: &mut gpui::TestAppContext) {
#[gpui::test]
async fn test_multiple_marked_entries(cx: &mut gpui::TestAppContext) {
init_test_with_editor(cx);
- let fs = FakeFs::new(cx.executor().clone());
+ let fs = FakeFs::new(cx.executor());
fs.insert_tree(
"/project_root",
json!({
@@ -3731,7 +3731,7 @@ async fn test_creating_excluded_entries(cx: &mut gpui::TestAppContext) {
register_project_item::<TestProjectItemView>(cx);
});
- let fs = FakeFs::new(cx.executor().clone());
+ let fs = FakeFs::new(cx.executor());
fs.insert_tree(
"/root1",
json!({
@@ -3914,7 +3914,7 @@ async fn test_creating_excluded_entries(cx: &mut gpui::TestAppContext) {
async fn test_selection_restored_when_creation_cancelled(cx: &mut gpui::TestAppContext) {
init_test_with_editor(cx);
- let fs = FakeFs::new(cx.executor().clone());
+ let fs = FakeFs::new(cx.executor());
fs.insert_tree(
"/src",
json!({
@@ -3982,7 +3982,7 @@ async fn test_selection_restored_when_creation_cancelled(cx: &mut gpui::TestAppC
async fn test_basic_file_deletion_scenarios(cx: &mut gpui::TestAppContext) {
init_test_with_editor(cx);
- let fs = FakeFs::new(cx.executor().clone());
+ let fs = FakeFs::new(cx.executor());
fs.insert_tree(
"/root",
json!({
@@ -4105,7 +4105,7 @@ async fn test_basic_file_deletion_scenarios(cx: &mut gpui::TestAppContext) {
async fn test_deletion_gitignored(cx: &mut gpui::TestAppContext) {
init_test_with_editor(cx);
- let fs = FakeFs::new(cx.executor().clone());
+ let fs = FakeFs::new(cx.executor());
fs.insert_tree(
path!("/root"),
json!({
@@ -4206,7 +4206,7 @@ async fn test_deletion_gitignored(cx: &mut gpui::TestAppContext) {
async fn test_nested_deletion_gitignore(cx: &mut gpui::TestAppContext) {
init_test_with_editor(cx);
- let fs = FakeFs::new(cx.executor().clone());
+ let fs = FakeFs::new(cx.executor());
fs.insert_tree(
path!("/root"),
json!({
@@ -4271,7 +4271,7 @@ async fn test_nested_deletion_gitignore(cx: &mut gpui::TestAppContext) {
async fn test_complex_selection_scenarios(cx: &mut gpui::TestAppContext) {
init_test_with_editor(cx);
- let fs = FakeFs::new(cx.executor().clone());
+ let fs = FakeFs::new(cx.executor());
fs.insert_tree(
"/root",
json!({
@@ -4382,7 +4382,7 @@ async fn test_complex_selection_scenarios(cx: &mut gpui::TestAppContext) {
async fn test_delete_all_files_and_directories(cx: &mut gpui::TestAppContext) {
init_test_with_editor(cx);
- let fs = FakeFs::new(cx.executor().clone());
+ let fs = FakeFs::new(cx.executor());
fs.insert_tree(
"/root",
json!({
@@ -4457,7 +4457,7 @@ async fn test_delete_all_files_and_directories(cx: &mut gpui::TestAppContext) {
async fn test_nested_selection_deletion(cx: &mut gpui::TestAppContext) {
init_test_with_editor(cx);
- let fs = FakeFs::new(cx.executor().clone());
+ let fs = FakeFs::new(cx.executor());
fs.insert_tree(
"/root",
json!({
@@ -4523,7 +4523,7 @@ async fn test_nested_selection_deletion(cx: &mut gpui::TestAppContext) {
async fn test_multiple_worktrees_deletion(cx: &mut gpui::TestAppContext) {
init_test_with_editor(cx);
- let fs = FakeFs::new(cx.executor().clone());
+ let fs = FakeFs::new(cx.executor());
// First worktree
fs.insert_tree(
"/root1",
@@ -4666,7 +4666,7 @@ async fn test_multiple_worktrees_deletion(cx: &mut gpui::TestAppContext) {
async fn test_selection_vs_marked_entries_priority(cx: &mut gpui::TestAppContext) {
init_test_with_editor(cx);
- let fs = FakeFs::new(cx.executor().clone());
+ let fs = FakeFs::new(cx.executor());
fs.insert_tree(
"/root",
json!({
@@ -4766,7 +4766,7 @@ async fn test_selection_vs_marked_entries_priority(cx: &mut gpui::TestAppContext
async fn test_selection_fallback_to_next_highest_worktree(cx: &mut gpui::TestAppContext) {
init_test_with_editor(cx);
- let fs = FakeFs::new(cx.executor().clone());
+ let fs = FakeFs::new(cx.executor());
fs.insert_tree(
"/root_b",
json!({
@@ -4859,7 +4859,7 @@ fn toggle_expand_dir(
async fn test_expand_all_for_entry(cx: &mut gpui::TestAppContext) {
init_test_with_editor(cx);
- let fs = FakeFs::new(cx.executor().clone());
+ let fs = FakeFs::new(cx.executor());
fs.insert_tree(
path!("/root"),
json!({
@@ -5050,7 +5050,7 @@ async fn test_expand_all_for_entry(cx: &mut gpui::TestAppContext) {
async fn test_collapse_all_for_entry(cx: &mut gpui::TestAppContext) {
init_test(cx);
- let fs = FakeFs::new(cx.executor().clone());
+ let fs = FakeFs::new(cx.executor());
fs.insert_tree(
path!("/root"),
json!({
@@ -5234,7 +5234,7 @@ async fn test_collapse_all_for_entry(cx: &mut gpui::TestAppContext) {
async fn test_create_entries_without_selection(cx: &mut gpui::TestAppContext) {
init_test(cx);
- let fs = FakeFs::new(cx.executor().clone());
+ let fs = FakeFs::new(cx.executor());
fs.insert_tree(
path!("/root"),
json!({
@@ -5299,7 +5299,7 @@ async fn test_create_entries_without_selection(cx: &mut gpui::TestAppContext) {
async fn test_create_entries_without_selection_hide_root(cx: &mut gpui::TestAppContext) {
init_test(cx);
- let fs = FakeFs::new(cx.executor().clone());
+ let fs = FakeFs::new(cx.executor());
fs.insert_tree(
path!("/root"),
json!({
@@ -5448,7 +5448,7 @@ async fn test_create_entries_without_selection_hide_root(cx: &mut gpui::TestAppC
async fn test_highlight_entry_for_external_drag(cx: &mut gpui::TestAppContext) {
init_test(cx);
- let fs = FakeFs::new(cx.executor().clone());
+ let fs = FakeFs::new(cx.executor());
fs.insert_tree(
"/root",
json!({
@@ -5516,7 +5516,7 @@ async fn test_highlight_entry_for_external_drag(cx: &mut gpui::TestAppContext) {
async fn test_highlight_entry_for_selection_drag(cx: &mut gpui::TestAppContext) {
init_test(cx);
- let fs = FakeFs::new(cx.executor().clone());
+ let fs = FakeFs::new(cx.executor());
fs.insert_tree(
"/root",
json!({
@@ -5647,7 +5647,7 @@ async fn test_highlight_entry_for_selection_drag(cx: &mut gpui::TestAppContext)
async fn test_hide_root(cx: &mut gpui::TestAppContext) {
init_test(cx);
- let fs = FakeFs::new(cx.executor().clone());
+ let fs = FakeFs::new(cx.executor());
fs.insert_tree(
"/root1",
json!({
@@ -5825,7 +5825,7 @@ async fn test_hide_root(cx: &mut gpui::TestAppContext) {
async fn test_compare_selected_files(cx: &mut gpui::TestAppContext) {
init_test_with_editor(cx);
- let fs = FakeFs::new(cx.executor().clone());
+ let fs = FakeFs::new(cx.executor());
fs.insert_tree(
"/root",
json!({
@@ -5923,7 +5923,7 @@ async fn test_compare_selected_files(cx: &mut gpui::TestAppContext) {
async fn test_compare_files_context_menu(cx: &mut gpui::TestAppContext) {
init_test_with_editor(cx);
- let fs = FakeFs::new(cx.executor().clone());
+ let fs = FakeFs::new(cx.executor());
fs.insert_tree(
"/root",
json!({
@@ -6152,7 +6152,7 @@ fn init_test_with_editor(cx: &mut TestAppContext) {
language::init(cx);
editor::init(cx);
crate::init(cx);
- workspace::init(app_state.clone(), cx);
+ workspace::init(app_state, cx);
Project::init_settings(cx);
cx.update_global::<SettingsStore, _>(|store, cx| {
@@ -233,7 +233,7 @@ impl PickerDelegate for ProjectSymbolsDelegate {
}
}
let label = symbol.label.text.clone();
- let path = path.to_string().clone();
+ let path = path.to_string();
let highlights = gpui::combine_highlights(
string_match
@@ -257,10 +257,8 @@ impl PickerDelegate for ProjectSymbolsDelegate {
v_flex()
.child(
LabelLike::new().child(
- StyledText::new(label).with_default_highlights(
- &window.text_style().clone(),
- highlights,
- ),
+ StyledText::new(label)
+ .with_default_highlights(&window.text_style(), highlights),
),
)
.child(Label::new(path).color(Color::Muted)),
@@ -403,7 +403,7 @@ impl PromptBuilder {
ContentPromptDiagnosticContext {
line_number: (start.row + 1) as usize,
error_message: entry.diagnostic.message.clone(),
- code_content: buffer.text_for_range(entry.range.clone()).collect(),
+ code_content: buffer.text_for_range(entry.range).collect(),
}
})
.collect();
@@ -119,7 +119,7 @@ impl EditNicknameState {
let starting_text = SshSettings::get_global(cx)
.ssh_connections()
.nth(index)
- .and_then(|state| state.nickname.clone())
+ .and_then(|state| state.nickname)
.filter(|text| !text.is_empty());
this.editor.update(cx, |this, cx| {
this.set_placeholder_text("Add a nickname for this server", cx);
@@ -165,7 +165,7 @@ impl ProjectPicker {
let nickname = connection.nickname.clone().map(|nick| nick.into());
let _path_task = cx
.spawn_in(window, {
- let workspace = workspace.clone();
+ let workspace = workspace;
async move |this, cx| {
let Ok(Some(paths)) = rx.await else {
workspace
@@ -520,7 +520,7 @@ impl RemoteServerProjects {
self.mode = Mode::CreateRemoteServer(CreateRemoteServer {
address_editor: editor,
address_error: None,
- ssh_prompt: Some(ssh_prompt.clone()),
+ ssh_prompt: Some(ssh_prompt),
_creating: Some(creating),
});
}
@@ -843,7 +843,7 @@ impl RemoteServerProjects {
.start_slot(Icon::new(IconName::Plus).color(Color::Muted))
.child(Label::new("Open Folder"))
.on_click(cx.listener({
- let ssh_connection = connection.clone();
+ let ssh_connection = connection;
let host = host.clone();
move |this, _, window, cx| {
let new_ix = this.create_host_from_ssh_config(&host, cx);
@@ -1376,7 +1376,7 @@ impl RemoteServerProjects {
};
let connection_string = connection.host.clone();
- let nickname = connection.nickname.clone().map(|s| s.into());
+ let nickname = connection.nickname.map(|s| s.into());
v_flex()
.id("ssh-edit-nickname")
@@ -681,7 +681,7 @@ pub async fn open_ssh_project(
window
.update(cx, |workspace, _, cx| {
- if let Some(client) = workspace.project().read(cx).ssh_client().clone() {
+ if let Some(client) = workspace.project().read(cx).ssh_client() {
ExtensionStore::global(cx)
.update(cx, |store, cx| store.register_ssh_client(client, cx));
}
@@ -233,8 +233,8 @@ impl SshConnectionOptions {
};
Ok(Self {
- host: hostname.to_string(),
- username: username.clone(),
+ host: hostname,
+ username,
port,
port_forwards,
args: Some(args),
@@ -1363,7 +1363,7 @@ impl ConnectionPool {
impl From<SshRemoteClient> for AnyProtoClient {
fn from(client: SshRemoteClient) -> Self {
- AnyProtoClient::new(client.client.clone())
+ AnyProtoClient::new(client.client)
}
}
@@ -237,11 +237,11 @@ impl HeadlessProject {
session.add_entity_message_handler(BufferStore::handle_close_buffer);
session.add_request_handler(
- extensions.clone().downgrade(),
+ extensions.downgrade(),
HeadlessExtensionStore::handle_sync_extensions,
);
session.add_request_handler(
- extensions.clone().downgrade(),
+ extensions.downgrade(),
HeadlessExtensionStore::handle_install_extension,
);
@@ -160,7 +160,7 @@ fn init_panic_hook(session_id: String) {
let panic_data = telemetry_events::Panic {
thread: thread_name.into(),
- payload: payload.clone(),
+ payload,
location_data: info.location().map(|location| LocationData {
file: location.file().into(),
line: location.line(),
@@ -799,7 +799,6 @@ fn initialize_settings(
watch_config_file(cx.background_executor(), fs, paths::settings_file().clone());
handle_settings_file_changes(user_settings_file_rx, cx, {
- let session = session.clone();
move |err, _cx| {
if let Some(e) = err {
log::info!("Server settings failed to change: {}", e);
@@ -187,7 +187,7 @@ impl PickerDelegate for KernelPickerDelegate {
.size(LabelSize::Default),
),
)
- .when_some(path_or_url.clone(), |flex, path| {
+ .when_some(path_or_url, |flex, path| {
flex.text_ellipsis().child(
Label::new(path)
.size(LabelSize::Small)
@@ -95,7 +95,7 @@ pub async fn list_remote_kernelspecs(
.kernelspecs
.into_iter()
.map(|(name, spec)| RemoteKernelSpecification {
- name: name.clone(),
+ name,
url: remote_server.base_url.clone(),
token: remote_server.token.clone(),
kernelspec: spec.spec,
@@ -103,7 +103,7 @@ pub async fn list_remote_kernelspecs(
.collect::<Vec<RemoteKernelSpecification>>();
anyhow::ensure!(!remote_kernelspecs.is_empty(), "No kernel specs found");
- Ok(remote_kernelspecs.clone())
+ Ok(remote_kernelspecs)
}
impl PartialEq for RemoteKernelSpecification {
@@ -228,26 +228,23 @@ impl Output {
.child(div().flex_1().children(content))
.children(match self {
Self::Plain { content, .. } => {
- Self::render_output_controls(content.clone(), workspace.clone(), window, cx)
+ Self::render_output_controls(content.clone(), workspace, window, cx)
}
Self::Markdown { content, .. } => {
- Self::render_output_controls(content.clone(), workspace.clone(), window, cx)
+ Self::render_output_controls(content.clone(), workspace, window, cx)
}
Self::Stream { content, .. } => {
- Self::render_output_controls(content.clone(), workspace.clone(), window, cx)
+ Self::render_output_controls(content.clone(), workspace, window, cx)
}
Self::Image { content, .. } => {
- Self::render_output_controls(content.clone(), workspace.clone(), window, cx)
+ Self::render_output_controls(content.clone(), workspace, window, cx)
+ }
+ Self::ErrorOutput(err) => {
+ Self::render_output_controls(err.traceback.clone(), workspace, window, cx)
}
- Self::ErrorOutput(err) => Self::render_output_controls(
- err.traceback.clone(),
- workspace.clone(),
- window,
- cx,
- ),
Self::Message(_) => None,
Self::Table { content, .. } => {
- Self::render_output_controls(content.clone(), workspace.clone(), window, cx)
+ Self::render_output_controls(content.clone(), workspace, window, cx)
}
Self::ClearOutputWaitMarker => None,
})
@@ -35,7 +35,7 @@ impl MarkdownView {
});
Self {
- raw_text: text.clone(),
+ raw_text: text,
image_cache: RetainAllImageCache::new(cx),
contents: None,
parsing_markdown_task: Some(task),
@@ -202,7 +202,7 @@ pub fn session(editor: WeakEntity<Editor>, cx: &mut App) -> SessionSupport {
return SessionSupport::Unsupported;
};
- let worktree_id = worktree_id_for_editor(editor.clone(), cx);
+ let worktree_id = worktree_id_for_editor(editor, cx);
let Some(worktree_id) = worktree_id else {
return SessionSupport::Unsupported;
@@ -216,7 +216,7 @@ pub fn session(editor: WeakEntity<Editor>, cx: &mut App) -> SessionSupport {
Some(kernelspec) => SessionSupport::Inactive(kernelspec),
None => {
// For language_supported, need to check available kernels for language
- if language_supported(&language.clone(), cx) {
+ if language_supported(&language, cx) {
SessionSupport::RequiresSetup(language.name())
} else {
SessionSupport::Unsupported
@@ -326,7 +326,7 @@ pub fn setup_editor_session_actions(editor: &mut Editor, editor_handle: WeakEnti
editor
.register_action({
- let editor_handle = editor_handle.clone();
+ let editor_handle = editor_handle;
move |_: &Restart, window, cx| {
if !JupyterSettings::enabled(cx) {
return;
@@ -420,7 +420,7 @@ fn runnable_ranges(
if let Some(language) = buffer.language()
&& language.name() == "Markdown".into()
{
- return (markdown_code_blocks(buffer, range.clone(), cx), None);
+ return (markdown_code_blocks(buffer, range, cx), None);
}
let (jupytext_snippets, next_cursor) = jupytext_cells(buffer, range.clone());
@@ -685,8 +685,8 @@ mod tests {
let python = languages::language("python", tree_sitter_python::LANGUAGE.into());
let language_registry = Arc::new(LanguageRegistry::new(cx.background_executor().clone()));
language_registry.add(markdown.clone());
- language_registry.add(typescript.clone());
- language_registry.add(python.clone());
+ language_registry.add(typescript);
+ language_registry.add(python);
// Two code blocks intersecting with selection
let buffer = cx.new(|cx| {
@@ -129,7 +129,6 @@ pub fn init(cx: &mut App) {
editor
.register_action({
- let editor_handle = editor_handle.clone();
move |_: &RunInPlace, window, cx| {
if !JupyterSettings::enabled(cx) {
return;
@@ -460,7 +460,6 @@ impl Session {
Kernel::StartingKernel(task) => {
// Queue up the execution as a task to run after the kernel starts
let task = task.clone();
- let message = message.clone();
cx.spawn(async move |this, cx| {
task.await;
@@ -568,7 +567,7 @@ impl Session {
match kernel {
Kernel::RunningKernel(mut kernel) => {
- let mut request_tx = kernel.request_tx().clone();
+ let mut request_tx = kernel.request_tx();
let forced = kernel.force_shutdown(window, cx);
@@ -605,7 +604,7 @@ impl Session {
// Do nothing if already restarting
}
Kernel::RunningKernel(mut kernel) => {
- let mut request_tx = kernel.request_tx().clone();
+ let mut request_tx = kernel.request_tx();
let forced = kernel.force_shutdown(window, cx);
@@ -408,7 +408,7 @@ impl<'a> ChunkSlice<'a> {
}
let row_offset_range = self.offset_range_for_row(point.0.row);
- let line = self.slice(row_offset_range.clone());
+ let line = self.slice(row_offset_range);
if point.0.column == 0 {
Point::new(point.0.row, 0)
} else if point.0.column >= line.len_utf16().0 as u32 {
@@ -80,7 +80,6 @@ impl Connection {
});
let rx = rx.then({
- let executor = executor.clone();
move |msg| {
let killed = killed.clone();
let executor = executor.clone();
@@ -378,7 +378,6 @@ impl Peer {
impl Future<Output = anyhow::Result<()>> + Send + use<>,
BoxStream<'static, Box<dyn AnyTypedEnvelope>>,
) {
- let executor = executor.clone();
self.add_connection(connection, move |duration| executor.timer(duration))
}
@@ -418,7 +418,7 @@ impl RulesLibrary {
} else {
None
},
- store: store.clone(),
+ store,
language_registry,
rule_editors: HashMap::default(),
active_rule_id: None,
@@ -1136,7 +1136,7 @@ impl RulesLibrary {
.child(
Label::new(format!(
"{} tokens",
- label_token_count.clone()
+ label_token_count
))
.color(Color::Muted),
)
@@ -716,10 +716,10 @@ impl BufferSearchBar {
self.replace_enabled = deploy.replace_enabled;
self.selection_search_enabled = deploy.selection_search_enabled;
if deploy.focus {
- let mut handle = self.query_editor.focus_handle(cx).clone();
+ let mut handle = self.query_editor.focus_handle(cx);
let mut select_query = true;
if deploy.replace_enabled && handle.is_focused(window) {
- handle = self.replacement_editor.focus_handle(cx).clone();
+ handle = self.replacement_editor.focus_handle(cx);
select_query = false;
};
@@ -42,7 +42,6 @@ impl<T: 'static> SearchActionsRegistrar for DivRegistrar<'_, '_, T> {
self.div = self.div.take().map(|div| {
div.on_action(self.cx.listener(move |this, action, window, cx| {
let should_notify = (getter)(this, window, cx)
- .clone()
.map(|search_bar| {
search_bar.update(cx, |search_bar, cx| {
callback.execute(search_bar, action, window, cx)
@@ -3716,7 +3716,7 @@ pub mod tests {
window
.update(cx, |_, _, cx| {
search_view.update(cx, |search_view, cx| {
- search_view.query_editor.read(cx).text(cx).to_string()
+ search_view.query_editor.read(cx).text(cx)
})
})
.unwrap()
@@ -3883,7 +3883,6 @@ pub mod tests {
// Add a project search item to the second pane
window
.update(cx, {
- let search_bar = search_bar.clone();
|workspace, window, cx| {
assert_eq!(workspace.panes().len(), 2);
second_pane.update(cx, |pane, cx| {
@@ -35,7 +35,7 @@ fn main() {
None,
));
let client = client::Client::new(clock, http.clone(), cx);
- Client::set_global(client.clone(), cx);
+ Client::set_global(client, cx);
let args: Vec<String> = std::env::args().collect();
if args.len() < 2 {
@@ -49,7 +49,7 @@ fn main() {
let api_key = std::env::var("OPENAI_API_KEY").expect("OPENAI_API_KEY not set");
let embedding_provider = Arc::new(OpenAiEmbeddingProvider::new(
- http.clone(),
+ http,
OpenAiEmbeddingModel::TextEmbedding3Small,
open_ai::OPEN_AI_API_URL.to_string(),
api_key,
@@ -88,7 +88,7 @@ impl EmbeddingIndex {
let worktree = self.worktree.read(cx).snapshot();
let worktree_abs_path = worktree.abs_path().clone();
- let scan = self.scan_updated_entries(worktree, updated_entries.clone(), cx);
+ let scan = self.scan_updated_entries(worktree, updated_entries, cx);
let chunk = self.chunk_files(worktree_abs_path, scan.updated_entries, cx);
let embed = Self::embed_files(self.embedding_provider.clone(), chunk.files, cx);
let persist = self.persist_embeddings(scan.deleted_entry_ranges, embed.files, cx);
@@ -406,7 +406,7 @@ impl EmbeddingIndex {
.context("failed to create read transaction")?;
let result = db
.iter(&tx)?
- .map(|entry| Ok(entry?.1.path.clone()))
+ .map(|entry| Ok(entry?.1.path))
.collect::<Result<Vec<Arc<Path>>>>();
drop(tx);
result
@@ -423,8 +423,7 @@ impl EmbeddingIndex {
Ok(db
.get(&tx, &db_key_for_path(&path))?
.context("no such path")?
- .chunks
- .clone())
+ .chunks)
})
}
}
@@ -434,7 +434,7 @@ mod tests {
.await;
let range = search_result.range.clone();
- let content = content[range.clone()].to_owned();
+ let content = content[range].to_owned();
assert!(content.contains("garbage in, garbage out"));
}
@@ -205,7 +205,7 @@ impl SummaryIndex {
let worktree = self.worktree.read(cx).snapshot();
let worktree_abs_path = worktree.abs_path().clone();
- backlogged = self.scan_updated_entries(worktree, updated_entries.clone(), cx);
+ backlogged = self.scan_updated_entries(worktree, updated_entries, cx);
digest = self.digest_files(backlogged.paths_to_digest, worktree_abs_path, cx);
needs_summary = self.check_summary_cache(digest.files, cx);
summaries = self.summarize_files(needs_summary.files, cx);
@@ -361,7 +361,7 @@ pub fn replace_top_level_array_value_in_json_text(
let needs_indent = range.start_point.row > 0;
if new_value.is_none() && key_path.is_empty() {
- let mut remove_range = text_range.clone();
+ let mut remove_range = text_range;
if index == 0 {
while cursor.goto_next_sibling()
&& (cursor.node().is_extra() || cursor.node().is_missing())
@@ -582,7 +582,7 @@ mod tests {
expected: String,
) {
let result = replace_value_in_json_text(&input, key_path, 4, value.as_ref(), None);
- let mut result_str = input.to_string();
+ let mut result_str = input;
result_str.replace_range(result.0, &result.1);
pretty_assertions::assert_eq!(expected, result_str);
}
@@ -135,7 +135,7 @@ impl SettingsProfileSelectorDelegate {
) -> Option<String> {
if let Some(profile_name) = profile_name {
cx.set_global(ActiveSettingsProfileName(profile_name.clone()));
- return Some(profile_name.clone());
+ return Some(profile_name);
}
if cx.has_global::<ActiveSettingsProfileName>() {
@@ -83,7 +83,7 @@ impl RenderOnce for ThemeControl {
DropdownMenu::new(
"theme",
- value.clone(),
+ value,
ContextMenu::build(window, cx, |mut menu, _, cx| {
let theme_registry = ThemeRegistry::global(cx);
@@ -204,7 +204,7 @@ impl RenderOnce for UiFontFamilyControl {
.child(Icon::new(IconName::Font))
.child(DropdownMenu::new(
"ui-font-family",
- value.clone(),
+ value,
ContextMenu::build(window, cx, |mut menu, _, cx| {
let font_family_cache = FontFamilyCache::global(cx);
@@ -1182,8 +1182,8 @@ impl KeymapEditor {
return;
};
- telemetry::event!("Keybinding Context Copied", context = context.clone());
- cx.write_to_clipboard(gpui::ClipboardItem::new_string(context.clone()));
+ telemetry::event!("Keybinding Context Copied", context = context);
+ cx.write_to_clipboard(gpui::ClipboardItem::new_string(context));
}
fn copy_action_to_clipboard(
@@ -1199,8 +1199,8 @@ impl KeymapEditor {
return;
};
- telemetry::event!("Keybinding Action Copied", action = action.clone());
- cx.write_to_clipboard(gpui::ClipboardItem::new_string(action.clone()));
+ telemetry::event!("Keybinding Action Copied", action = action);
+ cx.write_to_clipboard(gpui::ClipboardItem::new_string(action));
}
fn toggle_conflict_filter(
@@ -1464,7 +1464,7 @@ impl RenderOnce for KeybindContextString {
fn render(self, _window: &mut Window, cx: &mut App) -> impl IntoElement {
match self {
KeybindContextString::Global => {
- muted_styled_text(KeybindContextString::GLOBAL.clone(), cx).into_any_element()
+ muted_styled_text(KeybindContextString::GLOBAL, cx).into_any_element()
}
KeybindContextString::Local(name, language) => {
SyntaxHighlightedText::new(name, language).into_any_element()
@@ -1748,7 +1748,7 @@ impl Render for KeymapEditor {
} else {
const NULL: SharedString =
SharedString::new_static("<null>");
- muted_styled_text(NULL.clone(), cx)
+ muted_styled_text(NULL, cx)
.into_any_element()
}
})
@@ -194,7 +194,7 @@ impl RenderOnce for StorySection {
// Section title
.py_2()
// Section description
- .when_some(self.description.clone(), |section, description| {
+ .when_some(self.description, |section, description| {
section.child(Story::description(description, cx))
})
.child(div().flex().flex_col().gap_2().children(children))
@@ -384,9 +384,7 @@ impl SupermavenAgent {
match message {
SupermavenMessage::ActivationRequest(request) => {
self.account_status = match request.activate_url {
- Some(activate_url) => AccountStatus::NeedsActivation {
- activate_url: activate_url.clone(),
- },
+ Some(activate_url) => AccountStatus::NeedsActivation { activate_url },
None => AccountStatus::Ready,
};
}
@@ -45,9 +45,7 @@ fn completion_from_diff(
position: Anchor,
delete_range: Range<Anchor>,
) -> EditPrediction {
- let buffer_text = snapshot
- .text_for_range(delete_range.clone())
- .collect::<String>();
+ let buffer_text = snapshot.text_for_range(delete_range).collect::<String>();
let mut edits: Vec<(Range<language::Anchor>, String)> = Vec::new();
@@ -75,7 +75,6 @@ impl<T: PartialEq + 'static + Sync> TrackedFile<T> {
{
let parsed_contents: Arc<RwLock<T>> = Arc::default();
cx.background_spawn({
- let parsed_contents = parsed_contents.clone();
async move {
while let Some(new_contents) = tracker.next().await {
if Arc::strong_count(&parsed_contents) == 1 {
@@ -100,7 +100,7 @@ impl SpawnInTerminal {
command: proto.command.clone(),
args: proto.args.clone(),
env: proto.env.into_iter().collect(),
- cwd: proto.cwd.map(PathBuf::from).clone(),
+ cwd: proto.cwd.map(PathBuf::from),
..Default::default()
}
}
@@ -183,6 +183,10 @@ impl TaskTemplate {
&mut substituted_variables,
)?
} else {
+ #[allow(
+ clippy::redundant_clone,
+ reason = "We want to clone the full_label to avoid borrowing it in the fold closure"
+ )]
full_label.clone()
}
.lines()
@@ -453,7 +457,7 @@ mod tests {
TaskTemplate {
label: "".to_string(),
command: "".to_string(),
- ..task_with_all_properties.clone()
+ ..task_with_all_properties
},
] {
assert_eq!(
@@ -521,7 +525,7 @@ mod tests {
);
let cx = TaskContext {
- cwd: Some(context_cwd.clone()),
+ cwd: Some(context_cwd),
task_variables: TaskVariables::default(),
project_env: HashMap::default(),
};
@@ -768,7 +772,7 @@ mod tests {
"test_env_key".to_string(),
format!("test_env_var_{}", VariableName::Symbol.template_value()),
)]),
- ..task_with_all_properties.clone()
+ ..task_with_all_properties
},
]
.into_iter()
@@ -871,7 +875,7 @@ mod tests {
let context = TaskContext {
cwd: None,
- task_variables: TaskVariables::from_iter(all_variables.clone()),
+ task_variables: TaskVariables::from_iter(all_variables),
project_env,
};
@@ -434,7 +434,7 @@ mod tests {
)
.await;
let project = Project::test(fs, [path!("/dir").as_ref()], cx).await;
- let worktree_store = project.read_with(cx, |project, _| project.worktree_store().clone());
+ let worktree_store = project.read_with(cx, |project, _| project.worktree_store());
let rust_language = Arc::new(
Language::new(
LanguageConfig::default(),
@@ -486,7 +486,7 @@ impl TerminalBuilder {
//And connect them together
let event_loop = EventLoop::new(
term.clone(),
- ZedListener(events_tx.clone()),
+ ZedListener(events_tx),
pty,
pty_options.drain_on_exit,
false,
@@ -1661,7 +1661,7 @@ impl Terminal {
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
MouseButton::Middle => {
if let Some(item) = _cx.read_from_primary() {
- let text = item.text().unwrap_or_default().to_string();
+ let text = item.text().unwrap_or_default();
self.input(text.into_bytes());
}
}
@@ -653,7 +653,7 @@ impl TerminalElement {
let terminal = self.terminal.clone();
let hitbox = hitbox.clone();
let focus = focus.clone();
- let terminal_view = terminal_view.clone();
+ let terminal_view = terminal_view;
move |e: &MouseMoveEvent, phase, window, cx| {
if phase != DispatchPhase::Bubble {
return;
@@ -1838,8 +1838,7 @@ mod tests {
};
let font_size = AbsoluteLength::Pixels(px(12.0));
- let batch =
- BatchedTextRun::new_from_char(AlacPoint::new(0, 0), 'a', style1.clone(), font_size);
+ let batch = BatchedTextRun::new_from_char(AlacPoint::new(0, 0), 'a', style1, font_size);
// Should be able to append same style
assert!(batch.can_append(&style2));
@@ -181,7 +181,6 @@ impl TerminalPanel {
.anchor(Corner::TopRight)
.with_handle(pane.split_item_context_menu_handle.clone())
.menu({
- let split_context = split_context.clone();
move |window, cx| {
ContextMenu::build(window, cx, |menu, _, _| {
menu.when_some(
@@ -257,9 +257,9 @@ pub fn refine_theme_family(theme_family_content: ThemeFamilyContent) -> ThemeFam
let author = theme_family_content.author.clone();
let mut theme_family = ThemeFamily {
- id: id.clone(),
- name: name.clone().into(),
- author: author.clone().into(),
+ id,
+ name: name.into(),
+ author: author.into(),
themes: vec![],
scales: default_color_scales(),
};
@@ -158,7 +158,7 @@ impl VsCodeThemeConverter {
.tab
.active_background
.clone()
- .or(vscode_tab_inactive_background.clone()),
+ .or(vscode_tab_inactive_background),
search_match_background: vscode_colors.editor.find_match_background.clone(),
panel_background: vscode_colors.panel.background.clone(),
pane_group_border: vscode_colors.editor_group.border.clone(),
@@ -171,22 +171,20 @@ impl VsCodeThemeConverter {
.scrollbar_slider
.active_background
.clone(),
- scrollbar_thumb_border: vscode_scrollbar_slider_background.clone(),
+ scrollbar_thumb_border: vscode_scrollbar_slider_background,
scrollbar_track_background: vscode_editor_background.clone(),
scrollbar_track_border: vscode_colors.editor_overview_ruler.border.clone(),
minimap_thumb_background: vscode_colors.minimap_slider.background.clone(),
minimap_thumb_hover_background: vscode_colors.minimap_slider.hover_background.clone(),
minimap_thumb_active_background: vscode_colors.minimap_slider.active_background.clone(),
- editor_foreground: vscode_editor_foreground
- .clone()
- .or(vscode_token_colors_foreground.clone()),
+ editor_foreground: vscode_editor_foreground.or(vscode_token_colors_foreground),
editor_background: vscode_editor_background.clone(),
- editor_gutter_background: vscode_editor_background.clone(),
+ editor_gutter_background: vscode_editor_background,
editor_active_line_background: vscode_colors.editor.line_highlight_background.clone(),
editor_line_number: vscode_colors.editor_line_number.foreground.clone(),
editor_active_line_number: vscode_colors.editor.foreground.clone(),
editor_wrap_guide: vscode_panel_border.clone(),
- editor_active_wrap_guide: vscode_panel_border.clone(),
+ editor_active_wrap_guide: vscode_panel_border,
editor_document_highlight_bracket_background: vscode_colors
.editor_bracket_match
.background
@@ -186,7 +186,7 @@ impl ApplicationMenu {
.trigger(
Button::new(
SharedString::from(format!("{}-menu-trigger", menu_name)),
- menu_name.clone(),
+ menu_name,
)
.style(ButtonStyle::Subtle)
.label_size(LabelSize::Small),
@@ -155,7 +155,7 @@ impl TitleBar {
.gap_1()
.overflow_x_scroll()
.when_some(
- current_user.clone().zip(client.peer_id()).zip(room.clone()),
+ current_user.zip(client.peer_id()).zip(room),
|this, ((current_user, peer_id), room)| {
let player_colors = cx.theme().players();
let room = room.read(cx);
@@ -305,7 +305,6 @@ impl TitleBar {
let nickname = options
.nickname
- .clone()
.map(|nick| nick.into())
.unwrap_or_else(|| host.clone());
@@ -351,11 +350,7 @@ impl TitleBar {
.indicator_border_color(Some(cx.theme().colors().title_bar_background))
.into_any_element(),
)
- .child(
- Label::new(nickname.clone())
- .size(LabelSize::Small)
- .truncate(),
- ),
+ .child(Label::new(nickname).size(LabelSize::Small).truncate()),
)
.tooltip(move |window, cx| {
Tooltip::with_meta(
@@ -167,7 +167,6 @@ impl ToolchainSelectorDelegate {
cx: &mut Context<Picker<Self>>,
) -> Self {
let _fetch_candidates_task = cx.spawn_in(window, {
- let project = project.clone();
async move |this, cx| {
let term = project
.read_with(cx, |this, _| {
@@ -96,7 +96,7 @@ impl RenderOnce for DropdownMenu {
.style(self.style),
)
.attach(Corner::BottomLeft)
- .when_some(self.handle.clone(), |el, handle| el.with_handle(handle))
+ .when_some(self.handle, |el, handle| el.with_handle(handle))
}
}
@@ -169,7 +169,7 @@ impl Component for DropdownMenu {
"States",
vec![single_example(
"Disabled",
- DropdownMenu::new("disabled", "Disabled Dropdown", menu.clone())
+ DropdownMenu::new("disabled", "Disabled Dropdown", menu)
.disabled(true)
.into_any_element(),
)],
@@ -195,7 +195,7 @@ mod uniform_list {
impl UniformListDecoration for IndentGuides {
fn compute(
&self,
- visible_range: Range<usize>,
+ mut visible_range: Range<usize>,
bounds: Bounds<Pixels>,
_scroll_offset: Point<Pixels>,
item_height: Pixels,
@@ -203,7 +203,6 @@ mod uniform_list {
window: &mut Window,
cx: &mut App,
) -> AnyElement {
- let mut visible_range = visible_range.clone();
let includes_trailing_indent = visible_range.end < item_count;
// Check if we have entries after the visible range,
// if so extend the visible range so we can fetch a trailing indent,
@@ -325,7 +325,7 @@ impl RenderOnce for Key {
.text_size(size)
.line_height(relative(1.))
.text_color(self.color.unwrap_or(Color::Muted).color(cx))
- .child(self.key.clone())
+ .child(self.key)
}
}
@@ -269,7 +269,7 @@ impl Component for KeybindingHint {
),
single_example(
"Large",
- KeybindingHint::new(enter.clone(), bg_color)
+ KeybindingHint::new(enter, bg_color)
.size(Pixels::from(20.0))
.prefix("Large:")
.suffix("Size")
@@ -64,7 +64,7 @@ impl RenderOnce for AlertModal {
)
.child(Button::new(
self.primary_action.clone(),
- self.primary_action.clone(),
+ self.primary_action,
)),
),
)
@@ -28,7 +28,7 @@ where
T: StickyCandidate + Clone + 'static,
{
let entity_compute = entity.clone();
- let entity_render = entity.clone();
+ let entity_render = entity;
let compute_fn = Rc::new(
move |range: Range<usize>, window: &mut Window, cx: &mut App| -> SmallVec<[T; 8]> {
@@ -159,7 +159,6 @@ fn distance_string(
} else {
format!("about {} hours", hours)
}
- .to_string()
} else if distance < 172_800 {
"1 day".to_string()
} else if distance < 2_592_000 {
@@ -206,21 +205,16 @@ fn distance_string(
} else {
format!("about {} years", years)
}
- .to_string()
} else if remaining_months < 9 {
if hide_prefix {
format!("{} years", years)
} else {
format!("over {} years", years)
}
- .to_string()
+ } else if hide_prefix {
+ format!("{} years", years + 1)
} else {
- if hide_prefix {
- format!("{} years", years + 1)
- } else {
- format!("almost {} years", years + 1)
- }
- .to_string()
+ format!("almost {} years", years + 1)
}
};
@@ -202,11 +202,11 @@ impl Component for SingleLineInput {
.children(vec![example_group(vec![
single_example(
"Small Label (Default)",
- div().child(input_small.clone()).into_any_element(),
+ div().child(input_small).into_any_element(),
),
single_example(
"Regular Label",
- div().child(input_regular.clone()).into_any_element(),
+ div().child(input_regular).into_any_element(),
),
])])
.into_any_element(),
@@ -1648,7 +1648,7 @@ impl OnMatchingLines {
});
window.dispatch_action(action, cx);
cx.defer_in(window, move |editor, window, cx| {
- let newest = editor.selections.newest::<Point>(cx).clone();
+ let newest = editor.selections.newest::<Point>(cx);
editor.change_selections(
SelectionEffects::no_scroll(),
window,
@@ -74,11 +74,7 @@ impl ModeIndicator {
.map(|count| format!("{}", count)),
)
.chain(vim.selected_register.map(|reg| format!("\"{reg}")))
- .chain(
- vim.operator_stack
- .iter()
- .map(|item| item.status().to_string()),
- )
+ .chain(vim.operator_stack.iter().map(|item| item.status()))
.chain(
cx.global::<VimGlobals>()
.post_count
@@ -719,21 +719,14 @@ impl Vim {
target: Some(SurroundsType::Motion(motion)),
});
} else {
- self.normal_motion(
- motion.clone(),
- active_operator.clone(),
- count,
- forced_motion,
- window,
- cx,
- )
+ self.normal_motion(motion, active_operator, count, forced_motion, window, cx)
}
}
Mode::Visual | Mode::VisualLine | Mode::VisualBlock => {
- self.visual_motion(motion.clone(), count, window, cx)
+ self.visual_motion(motion, count, window, cx)
}
- Mode::HelixNormal => self.helix_normal_motion(motion.clone(), count, window, cx),
+ Mode::HelixNormal => self.helix_normal_motion(motion, count, window, cx),
}
self.clear_operator(window, cx);
if let Some(operator) = waiting_operator {
@@ -1327,7 +1320,7 @@ impl Motion {
pub fn range(
&self,
map: &DisplaySnapshot,
- selection: Selection<DisplayPoint>,
+ mut selection: Selection<DisplayPoint>,
times: Option<usize>,
text_layout_details: &TextLayoutDetails,
forced_motion: bool,
@@ -1372,7 +1365,6 @@ impl Motion {
(None, true) => Some((selection.head(), selection.goal)),
}?;
- let mut selection = selection.clone();
selection.set_head(new_head, goal);
let mut kind = match (self.default_kind(), forced_motion) {
@@ -2401,9 +2393,7 @@ fn matching(map: &DisplaySnapshot, display_point: DisplayPoint) -> DisplayPoint
let line_range = map.prev_line_boundary(point).0..line_end;
let visible_line_range =
line_range.start..Point::new(line_range.end.row, line_range.end.column.saturating_sub(1));
- let ranges = map
- .buffer_snapshot
- .bracket_ranges(visible_line_range.clone());
+ let ranges = map.buffer_snapshot.bracket_ranges(visible_line_range);
if let Some(ranges) = ranges {
let line_range = line_range.start.to_offset(&map.buffer_snapshot)
..line_range.end.to_offset(&map.buffer_snapshot);
@@ -474,8 +474,7 @@ mod test {
Mode::Normal,
);
assert_eq!(
- cx.read_from_clipboard()
- .map(|item| item.text().unwrap().to_string()),
+ cx.read_from_clipboard().map(|item| item.text().unwrap()),
Some("jumps".into())
);
cx.simulate_keystrokes("d d p");
@@ -487,8 +486,7 @@ mod test {
Mode::Normal,
);
assert_eq!(
- cx.read_from_clipboard()
- .map(|item| item.text().unwrap().to_string()),
+ cx.read_from_clipboard().map(|item| item.text().unwrap()),
Some("jumps".into())
);
cx.write_to_clipboard(ClipboardItem::new_string("test-copy".to_string()));
@@ -187,9 +187,7 @@ fn find_mini_delimiters(
};
// Try to find delimiters in visible range first
- let ranges = map
- .buffer_snapshot
- .bracket_ranges(visible_line_range.clone());
+ let ranges = map.buffer_snapshot.bracket_ranges(visible_line_range);
if let Some(candidate) = cover_or_next(ranges, display_point, map, Some(&bracket_filter)) {
return Some(
DelimiterRange {
@@ -400,7 +400,7 @@ impl MarksState {
} else {
HashMap::default()
};
- let old_points = self.serialized_marks.get(&path.clone());
+ let old_points = self.serialized_marks.get(&path);
if old_points == Some(&new_points) {
return;
}
@@ -543,7 +543,7 @@ impl MarksState {
.insert(name.clone(), anchors);
if self.is_global_mark(&name) {
self.global_marks
- .insert(name.clone(), MarkLocation::Buffer(multibuffer.entity_id()));
+ .insert(name, MarkLocation::Buffer(multibuffer.entity_id()));
}
if let Some(buffer) = buffer {
let buffer_id = buffer.read(cx).remote_id();
@@ -559,7 +559,7 @@ impl MarksState {
let buffer_id = buffer.read(cx).remote_id();
self.buffer_marks.entry(buffer_id).or_default().insert(
- name.clone(),
+ name,
anchors
.into_iter()
.map(|anchor| anchor.text_anchor)
@@ -654,9 +654,9 @@ impl MarksState {
return;
}
};
- self.global_marks.remove(&mark_name.clone());
+ self.global_marks.remove(&mark_name);
self.serialized_marks
- .get_mut(&path.clone())
+ .get_mut(&path)
.map(|m| m.remove(&mark_name.clone()));
if let Some(workspace_id) = self.workspace_id(cx) {
cx.background_spawn(async move { DB.delete_mark(workspace_id, path, mark_name).await })
@@ -1282,7 +1282,7 @@ impl RegistersView {
if let Some(register) = register {
matches.push(RegisterMatch {
name: '%',
- contents: register.text.clone(),
+ contents: register.text,
})
}
}
@@ -1374,7 +1374,7 @@ impl PickerDelegate for MarksViewDelegate {
_: &mut Window,
cx: &mut Context<Picker<Self>>,
) -> gpui::Task<()> {
- let Some(workspace) = self.workspace.upgrade().clone() else {
+ let Some(workspace) = self.workspace.upgrade() else {
return Task::ready(());
};
cx.spawn(async move |picker, cx| {
@@ -292,12 +292,7 @@ impl NeovimBackedTestContext {
register: '"',
state: self.shared_state().await,
neovim: self.neovim.read_register('"').await,
- editor: self
- .read_from_clipboard()
- .unwrap()
- .text()
- .unwrap()
- .to_owned(),
+ editor: self.read_from_clipboard().unwrap().text().unwrap(),
}
}
@@ -453,7 +453,7 @@ impl NeovimConnection {
};
if self.data.back() != Some(&state) {
- self.data.push_back(state.clone());
+ self.data.push_back(state);
}
(mode, ranges)
@@ -225,7 +225,7 @@ impl VimTestContext {
VimClipboard {
editor: self
.read_from_clipboard()
- .map(|item| item.text().unwrap().to_string())
+ .map(|item| item.text().unwrap())
.unwrap_or_default(),
}
}
@@ -1693,7 +1693,7 @@ impl Vim {
}) {
editor.do_paste(
®ister.text.to_string(),
- register.clipboard_selections.clone(),
+ register.clipboard_selections,
false,
window,
cx,
@@ -1203,7 +1203,7 @@ mod test {
the lazy dog"});
assert_eq!(
cx.read_from_clipboard()
- .map(|item| item.text().unwrap().to_string())
+ .map(|item| item.text().unwrap())
.unwrap(),
"The q"
);
@@ -218,7 +218,7 @@ mod tests {
let mut tasks = Vec::new();
tasks.push(cx.background_spawn({
- let executor = cx.executor().clone();
+ let executor = cx.executor();
let next_id = next_id.clone();
let closed = closed.clone();
async move {
@@ -57,7 +57,7 @@ impl WebSearchRegistry {
) {
let id = provider.id();
let provider = Arc::new(provider);
- self.providers.insert(id.clone(), provider.clone());
+ self.providers.insert(id, provider.clone());
if self.active_provider.is_none() {
self.active_provider = Some(provider);
}
@@ -171,7 +171,7 @@ where
}
fn panel_focus_handle(&self, cx: &App) -> FocusHandle {
- self.read(cx).focus_handle(cx).clone()
+ self.read(cx).focus_handle(cx)
}
fn activation_priority(&self, cx: &App) -> u32 {
@@ -340,7 +340,7 @@ impl Dock {
pub fn panel<T: Panel>(&self) -> Option<Entity<T>> {
self.panel_entries
.iter()
- .find_map(|entry| entry.panel.to_any().clone().downcast().ok())
+ .find_map(|entry| entry.panel.to_any().downcast().ok())
}
pub fn panel_index_for_type<T: Panel>(&self) -> Option<usize> {
@@ -1012,7 +1012,6 @@ where
let message: SharedString = format!("Error: {err}").into();
log::error!("Showing error notification in app: {message}");
show_app_notification(workspace_error_notification_id(), cx, {
- let message = message.clone();
move |cx| {
cx.new({
let message = message.clone();
@@ -480,7 +480,7 @@ impl Pane {
forward_stack: Default::default(),
closed_stack: Default::default(),
paths_by_item: Default::default(),
- pane: handle.clone(),
+ pane: handle,
next_timestamp,
}))),
toolbar: cx.new(|_| Toolbar::new()),
@@ -2516,7 +2516,7 @@ impl Pane {
this.handle_external_paths_drop(paths, window, cx)
}))
.when_some(item.tab_tooltip_content(cx), |tab, content| match content {
- TabTooltipContent::Text(text) => tab.tooltip(Tooltip::text(text.clone())),
+ TabTooltipContent::Text(text) => tab.tooltip(Tooltip::text(text)),
TabTooltipContent::Custom(element_fn) => {
tab.tooltip(move |window, cx| element_fn(window, cx))
}
@@ -1175,7 +1175,7 @@ mod element {
bounding_boxes.clear();
let mut layout = PaneAxisLayout {
- dragged_handle: dragged_handle.clone(),
+ dragged_handle,
children: Vec::new(),
};
for (ix, mut child) in mem::take(&mut self.children).into_iter().enumerate() {
@@ -620,7 +620,7 @@ mod tests {
]);
let order = vec![2, 0, 1];
let serialized =
- SerializedWorkspaceLocation::Local(LocalPaths(paths.clone()), LocalPathsOrder(order));
+ SerializedWorkspaceLocation::Local(LocalPaths(paths), LocalPathsOrder(order));
assert_eq!(
serialized.sorted_paths(),
Arc::new(vec![
@@ -371,13 +371,13 @@ impl<T: SearchableItem> SearchableItemHandle for Entity<T> {
impl From<Box<dyn SearchableItemHandle>> for AnyView {
fn from(this: Box<dyn SearchableItemHandle>) -> Self {
- this.to_any().clone()
+ this.to_any()
}
}
impl From<&Box<dyn SearchableItemHandle>> for AnyView {
fn from(this: &Box<dyn SearchableItemHandle>) -> Self {
- this.to_any().clone()
+ this.to_any()
}
}
@@ -108,7 +108,7 @@ impl StatusBar {
self.left_items
.iter()
.chain(self.right_items.iter())
- .find_map(|item| item.to_any().clone().downcast().log_err())
+ .find_map(|item| item.to_any().downcast().log_err())
}
pub fn position_of_item<T>(&self) -> Option<usize>
@@ -217,6 +217,6 @@ impl<T: StatusItemView> StatusItemViewHandle for Entity<T> {
impl From<&dyn StatusItemViewHandle> for AnyView {
fn from(val: &dyn StatusItemViewHandle) -> Self {
- val.to_any().clone()
+ val.to_any()
}
}
@@ -303,7 +303,6 @@ impl ThemePreview {
.gap_1()
.children(all_colors.into_iter().map(|(color, name)| {
let id = ElementId::Name(format!("{:?}-preview", color).into());
- let name = name.clone();
div().size_8().flex_none().child(
ButtonLike::new(id)
.child(
@@ -903,7 +903,7 @@ impl AppState {
let languages = Arc::new(LanguageRegistry::test(cx.background_executor().clone()));
let clock = Arc::new(clock::FakeSystemClock::new());
let http_client = http_client::FakeHttpClient::with_404_response();
- let client = Client::new(clock, http_client.clone(), cx);
+ let client = Client::new(clock, http_client, cx);
let session = cx.new(|cx| AppSession::new(Session::test(), cx));
let user_store = cx.new(|cx| UserStore::new(client.clone(), cx));
let workspace_store = cx.new(|cx| WorkspaceStore::new(client.clone(), cx));
@@ -1323,7 +1323,6 @@ impl Workspace {
let mut active_call = None;
if let Some(call) = ActiveCall::try_global(cx) {
- let call = call.clone();
let subscriptions = vec![cx.subscribe_in(&call, window, Self::on_active_call_event)];
active_call = Some((call, subscriptions));
}
@@ -4116,7 +4115,6 @@ impl Workspace {
.unwrap_or_else(|| {
self.split_pane(self.active_pane.clone(), SplitDirection::Right, window, cx)
})
- .clone()
}
pub fn pane_for(&self, handle: &dyn ItemHandle) -> Option<Entity<Pane>> {
@@ -6713,7 +6711,7 @@ impl WorkspaceStore {
.update(cx, |workspace, window, cx| {
let handler_response =
workspace.handle_follow(follower.project_id, window, cx);
- if let Some(active_view) = handler_response.active_view.clone()
+ if let Some(active_view) = handler_response.active_view
&& workspace.project.read(cx).remote_id() == follower.project_id
{
response.active_view = Some(active_view)
@@ -1968,7 +1968,7 @@ impl LocalWorktree {
cx: &Context<Worktree>,
) -> Option<Task<Result<()>>> {
let path = self.entry_for_id(entry_id).unwrap().path.clone();
- let mut rx = self.add_path_prefix_to_scan(path.clone());
+ let mut rx = self.add_path_prefix_to_scan(path);
Some(cx.background_spawn(async move {
rx.next().await;
Ok(())
@@ -3952,7 +3952,7 @@ impl BackgroundScanner {
.iter()
.map(|path| {
if path.file_name().is_some() {
- root_canonical_path.as_path().join(path).to_path_buf()
+ root_canonical_path.as_path().join(path)
} else {
root_canonical_path.as_path().to_path_buf()
}
@@ -1254,7 +1254,7 @@ async fn test_create_directory_during_initial_scan(cx: &mut TestAppContext) {
let snapshot = Arc::new(Mutex::new(tree.snapshot()));
tree.observe_updates(0, cx, {
let snapshot = snapshot.clone();
- let settings = tree.settings().clone();
+ let settings = tree.settings();
move |update| {
snapshot
.lock()
@@ -242,7 +242,7 @@ pub fn main() {
if args.system_specs {
let system_specs = feedback::system_specs::SystemSpecs::new_stateless(
app_version,
- app_commit_sha.clone(),
+ app_commit_sha,
*release_channel::RELEASE_CHANNEL,
);
println!("Zed System Specs (from CLI):\n{}", system_specs);
@@ -367,7 +367,7 @@ pub fn main() {
if let Some(app_state) = AppState::try_global(cx).and_then(|app_state| app_state.upgrade())
{
cx.spawn({
- let app_state = app_state.clone();
+ let app_state = app_state;
async move |cx| {
if let Err(e) = restore_or_create_workspace(app_state, cx).await {
fail_to_open_window_async(e, cx)
@@ -523,13 +523,13 @@ pub fn main() {
let app_session = cx.new(|cx| AppSession::new(session, cx));
let app_state = Arc::new(AppState {
- languages: languages.clone(),
+ languages,
client: client.clone(),
- user_store: user_store.clone(),
+ user_store,
fs: fs.clone(),
build_window_options,
workspace_store,
- node_runtime: node_runtime.clone(),
+ node_runtime,
session: app_session,
});
AppState::set_global(Arc::downgrade(&app_state), cx);
@@ -751,7 +751,6 @@ fn handle_open_request(request: OpenRequest, app_state: Arc<AppState>, cx: &mut
if let Some(kind) = request.kind {
match kind {
OpenRequestKind::CliConnection(connection) => {
- let app_state = app_state.clone();
cx.spawn(async move |cx| handle_cli_connection(connection, app_state, cx).await)
.detach();
}
@@ -1313,7 +1312,6 @@ fn eager_load_active_theme_and_icon_theme(fs: Arc<dyn Fs>, cx: &App) {
.path_to_extension_icon_theme(icon_theme_name)
{
cx.spawn({
- let theme_registry = theme_registry.clone();
let fs = fs.clone();
async move |cx| {
theme_registry
@@ -1335,9 +1333,7 @@ fn load_user_themes_in_background(fs: Arc<dyn fs::Fs>, cx: &mut App) {
cx.spawn({
let fs = fs.clone();
async move |cx| {
- if let Some(theme_registry) =
- cx.update(|cx| ThemeRegistry::global(cx).clone()).log_err()
- {
+ if let Some(theme_registry) = cx.update(|cx| ThemeRegistry::global(cx)).log_err() {
let themes_dir = paths::themes_dir().as_ref();
match fs
.metadata(themes_dir)
@@ -1376,7 +1372,7 @@ fn watch_themes(fs: Arc<dyn fs::Fs>, cx: &mut App) {
for event in paths {
if fs.metadata(&event.path).await.ok().flatten().is_some()
&& let Some(theme_registry) =
- cx.update(|cx| ThemeRegistry::global(cx).clone()).log_err()
+ cx.update(|cx| ThemeRegistry::global(cx)).log_err()
&& let Some(()) = theme_registry
.load_user_theme(&event.path, fs.clone())
.await
@@ -526,8 +526,6 @@ fn initialize_panels(
window: &mut Window,
cx: &mut Context<Workspace>,
) {
- let prompt_builder = prompt_builder.clone();
-
cx.spawn_in(window, async move |workspace_handle, cx| {
let project_panel = ProjectPanel::load(workspace_handle.clone(), cx.clone());
let outline_panel = OutlinePanel::load(workspace_handle.clone(), cx.clone());
@@ -1394,7 +1392,7 @@ fn show_keymap_file_load_error(
cx: &mut App,
) {
show_markdown_app_notification(
- notification_id.clone(),
+ notification_id,
error_message,
"Open Keymap File".into(),
|window, cx| {
@@ -4786,7 +4784,7 @@ mod tests {
cx.background_executor.run_until_parked();
// 5. Critical: Verify .zed is actually excluded from worktree
- let worktree = cx.update(|cx| project.read(cx).worktrees(cx).next().unwrap().clone());
+ let worktree = cx.update(|cx| project.read(cx).worktrees(cx).next().unwrap());
let has_zed_entry = cx.update(|cx| worktree.read(cx).entry_for_path(".zed").is_some());
@@ -4822,7 +4820,7 @@ mod tests {
.await
.unwrap();
- let new_content_str = new_content.clone();
+ let new_content_str = new_content;
eprintln!("New settings content: {}", new_content_str);
// The bug causes the settings to be overwritten with empty settings
@@ -33,8 +33,6 @@ use workspace::{
pub fn init(app_state: Arc<AppState>, cx: &mut App) {
workspace::register_serializable_item::<ComponentPreview>(cx);
- let app_state = app_state.clone();
-
cx.observe_new(move |workspace: &mut Workspace, _window, cx| {
let app_state = app_state.clone();
let project = workspace.project().clone();
@@ -462,12 +460,12 @@ impl ComponentPreview {
Vec::new()
};
if valid_positions.is_empty() {
- Label::new(name.clone()).into_any_element()
+ Label::new(name).into_any_element()
} else {
- HighlightedLabel::new(name.clone(), valid_positions).into_any_element()
+ HighlightedLabel::new(name, valid_positions).into_any_element()
}
} else {
- Label::new(name.clone()).into_any_element()
+ Label::new(name).into_any_element()
})
.selectable(true)
.toggle_state(selected)
@@ -685,7 +683,7 @@ impl ComponentPreview {
.h_full()
.py_8()
.bg(cx.theme().colors().panel_background)
- .children(self.active_thread.clone().map(|thread| thread.clone()))
+ .children(self.active_thread.clone())
.when_none(&self.active_thread.clone(), |this| {
this.child("No active thread")
}),
@@ -716,7 +714,7 @@ impl Render for ComponentPreview {
if input.is_empty(cx) {
String::new()
} else {
- input.editor().read(cx).text(cx).to_string()
+ input.editor().read(cx).text(cx)
}
});
@@ -929,7 +927,7 @@ impl SerializableItem for ComponentPreview {
Err(_) => ActivePageId::default(),
};
- let user_store = project.read(cx).user_store().clone();
+ let user_store = project.read(cx).user_store();
let language_registry = project.read(cx).languages().clone();
let preview_page = if deserialized_active_page.0 == ActivePageId::default().0 {
Some(PreviewPage::default())
@@ -940,7 +938,7 @@ impl SerializableItem for ComponentPreview {
let found_component = all_components.iter().find(|c| c.id().0 == component_str);
if let Some(component) = found_component {
- Some(PreviewPage::Component(component.id().clone()))
+ Some(PreviewPage::Component(component.id()))
} else {
Some(PreviewPage::default())
}
@@ -1057,7 +1055,7 @@ impl ComponentPreviewPage {
.rounded_sm()
.bg(color.color(cx).alpha(0.12))
.child(
- Label::new(status.clone().to_string())
+ Label::new(status.to_string())
.size(LabelSize::Small)
.color(color),
),
@@ -60,23 +60,16 @@ pub fn init(client: Arc<Client>, user_store: Entity<UserStore>, cx: &mut App) {
cx.subscribe(&user_store, {
let editors = editors.clone();
let client = client.clone();
+
move |user_store, event, cx| {
if let client::user::Event::PrivateUserInfoUpdated = event {
- assign_edit_prediction_providers(
- &editors,
- provider,
- &client,
- user_store.clone(),
- cx,
- );
+ assign_edit_prediction_providers(&editors, provider, &client, user_store, cx);
}
}
})
.detach();
cx.observe_global::<SettingsStore>({
- let editors = editors.clone();
- let client = client.clone();
let user_store = user_store.clone();
move |cx| {
let new_provider = all_language_settings(None, cx).edit_predictions.provider;
@@ -102,11 +102,8 @@ impl OpenRequest {
self.open_paths.is_empty(),
"cannot open both local and ssh paths"
);
- let mut connection_options = SshSettings::get_global(cx).connection_options_for(
- host.clone(),
- port,
- username.clone(),
- );
+ let mut connection_options =
+ SshSettings::get_global(cx).connection_options_for(host, port, username);
if let Some(password) = url.password() {
connection_options.password = Some(password.to_string());
}
@@ -161,7 +161,7 @@ impl Render for QuickActionBar {
IconName::ZedAssistant,
false,
Box::new(InlineAssist::default()),
- focus_handle.clone(),
+ focus_handle,
"Inline Assist",
move |_, window, cx| {
window.dispatch_action(Box::new(InlineAssist::default()), cx);
@@ -215,7 +215,7 @@ impl Render for QuickActionBar {
)
})
.on_click({
- let focus = focus.clone();
+ let focus = focus;
move |_, window, cx| {
focus.dispatch_action(
&ToggleCodeActions {
@@ -196,7 +196,6 @@ impl QuickActionBar {
.into_any_element()
},
{
- let editor = editor.clone();
move |window, cx| {
repl::restart(editor.clone(), window, cx);
}
@@ -346,7 +345,7 @@ impl QuickActionBar {
),
Tooltip::text("Select Kernel"),
)
- .with_handle(menu_handle.clone())
+ .with_handle(menu_handle)
.into_any_element()
}
@@ -362,7 +361,7 @@ impl QuickActionBar {
.shape(ui::IconButtonShape::Square)
.icon_size(ui::IconSize::Small)
.icon_color(Color::Muted)
- .tooltip(Tooltip::text(tooltip.clone()))
+ .tooltip(Tooltip::text(tooltip))
.on_click(|_, _window, cx| {
cx.open_url(&format!("{}#installation", ZED_REPL_DOCUMENTATION))
}),
@@ -90,7 +90,7 @@ fn expand_range(
range: Range<Point>,
mut remaining_tokens: usize,
) -> Range<Point> {
- let mut expanded_range = range.clone();
+ let mut expanded_range = range;
expanded_range.start.column = 0;
expanded_range.end.column = snapshot.line_len(expanded_range.end.row);
loop {
@@ -107,11 +107,7 @@ pub fn init(cx: &mut App) -> ZetaCliAppState {
language::init(cx);
debug_adapter_extension::init(extension_host_proxy.clone(), cx);
- language_extension::init(
- LspAccess::Noop,
- extension_host_proxy.clone(),
- languages.clone(),
- );
+ language_extension::init(LspAccess::Noop, extension_host_proxy, languages.clone());
language_model::init(client.clone(), cx);
language_models::init(user_store.clone(), client.clone(), cx);
languages::init(languages.clone(), node_runtime.clone(), cx);
@@ -293,7 +293,7 @@ impl ScopeMap {
sub_items_start + 1,
sub_items_end,
"Expected one item: got: {:?}",
- &items[items_range.clone()]
+ &items[items_range]
);
enabled = Some(items[sub_items_start].1);
} else {
@@ -119,7 +119,7 @@ impl zed::Extension for GlslExtension {
) -> Result<Option<serde_json::Value>> {
let settings = LspSettings::for_worktree("glsl_analyzer", worktree)
.ok()
- .and_then(|lsp_settings| lsp_settings.settings.clone())
+ .and_then(|lsp_settings| lsp_settings.settings)
.unwrap_or_default();
Ok(Some(serde_json::json!({
@@ -94,7 +94,7 @@ impl zed::Extension for HtmlExtension {
) -> Result<Option<zed::serde_json::Value>> {
let settings = LspSettings::for_worktree(server_id.as_ref(), worktree)
.ok()
- .and_then(|lsp_settings| lsp_settings.settings.clone())
+ .and_then(|lsp_settings| lsp_settings.settings)
.unwrap_or_default();
Ok(Some(settings))
}
@@ -151,7 +151,7 @@ impl zed::Extension for RuffExtension {
) -> Result<Option<zed_extension_api::serde_json::Value>> {
let settings = LspSettings::for_worktree(server_id.as_ref(), worktree)
.ok()
- .and_then(|lsp_settings| lsp_settings.initialization_options.clone())
+ .and_then(|lsp_settings| lsp_settings.initialization_options)
.unwrap_or_default();
Ok(Some(settings))
}
@@ -163,7 +163,7 @@ impl zed::Extension for RuffExtension {
) -> Result<Option<zed_extension_api::serde_json::Value>> {
let settings = LspSettings::for_worktree(server_id.as_ref(), worktree)
.ok()
- .and_then(|lsp_settings| lsp_settings.settings.clone())
+ .and_then(|lsp_settings| lsp_settings.settings)
.unwrap_or_default();
Ok(Some(settings))
}
@@ -113,7 +113,7 @@ impl zed::Extension for SnippetExtension {
) -> Result<Option<zed_extension_api::serde_json::Value>> {
let settings = LspSettings::for_worktree(server_id.as_ref(), worktree)
.ok()
- .and_then(|lsp_settings| lsp_settings.settings.clone())
+ .and_then(|lsp_settings| lsp_settings.settings)
.unwrap_or_else(|| {
json!({
"max_completion_items": 20,