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

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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