Fix clippy::redundant_clone lint violations (#36558)

This removes around 900 unnecessary clones, ranging from cloning a few
ints all the way to large data structures and images.

A lot of these were fixed using `cargo clippy --fix --workspace
--all-targets`, however it often breaks other lints and needs to be run
again. This was then followed up with some manual fixing.

I understand this is a large diff, but all the changes are pretty
trivial. Rust is doing some heavy lifting here for us. Once I get it up
to speed with main, I'd appreciate this getting merged rather sooner
than later.

Release Notes:

- N/A
This commit is contained in:
tidely 2025-08-20 13:20:13 +03:00 committed by GitHub
parent cf7c64d77f
commit 7bdc99abc1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
306 changed files with 805 additions and 1102 deletions

View file

@ -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| {

View file

@ -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);
});
}

View file

@ -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);
});

View file

@ -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)
})

View file

@ -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

View file

@ -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,

View file

@ -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),

View file

@ -234,7 +234,7 @@ fn process_content(
if is_empty {
"Command executed successfully.".to_string()
} else {
content.to_string()
content
}
}
Some(exit_status) => {