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:
parent
cf7c64d77f
commit
7bdc99abc1
306 changed files with 805 additions and 1102 deletions
|
@ -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(),
|
||||
),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue