Fix clippy::needless_borrow lint violations (#36444)

Release Notes:

- N/A
This commit is contained in:
Piotr Osiewicz 2025-08-18 23:54:35 +02:00 committed by GitHub
parent eecf142f06
commit 9e0e233319
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
242 changed files with 801 additions and 821 deletions

View file

@ -160,7 +160,7 @@ impl CommitView {
});
}
cx.spawn(async move |this, mut cx| {
cx.spawn(async move |this, cx| {
for file in commit_diff.files {
let is_deleted = file.new_text.is_none();
let new_text = file.new_text.unwrap_or_default();
@ -179,9 +179,9 @@ impl CommitView {
worktree_id,
}) as Arc<dyn language::File>;
let buffer = build_buffer(new_text, file, &language_registry, &mut cx).await?;
let buffer = build_buffer(new_text, file, &language_registry, cx).await?;
let buffer_diff =
build_buffer_diff(old_text, &buffer, &language_registry, &mut cx).await?;
build_buffer_diff(old_text, &buffer, &language_registry, cx).await?;
this.update(cx, |this, cx| {
this.multibuffer.update(cx, |multibuffer, cx| {

View file

@ -156,7 +156,7 @@ fn buffers_removed(editor: &mut Editor, removed_buffer_ids: &[BufferId], cx: &mu
.unwrap()
.buffers
.retain(|buffer_id, buffer| {
if removed_buffer_ids.contains(&buffer_id) {
if removed_buffer_ids.contains(buffer_id) {
removed_block_ids.extend(buffer.block_ids.iter().map(|(_, block_id)| *block_id));
false
} else {
@ -222,12 +222,12 @@ fn conflicts_updated(
let precedes_start = range
.context
.start
.cmp(&conflict_range.start, &buffer_snapshot)
.cmp(&conflict_range.start, buffer_snapshot)
.is_le();
let follows_end = range
.context
.end
.cmp(&conflict_range.start, &buffer_snapshot)
.cmp(&conflict_range.start, buffer_snapshot)
.is_ge();
precedes_start && follows_end
}) else {
@ -268,12 +268,12 @@ fn conflicts_updated(
let precedes_start = range
.context
.start
.cmp(&conflict.range.start, &buffer_snapshot)
.cmp(&conflict.range.start, buffer_snapshot)
.is_le();
let follows_end = range
.context
.end
.cmp(&conflict.range.start, &buffer_snapshot)
.cmp(&conflict.range.start, buffer_snapshot)
.is_ge();
precedes_start && follows_end
}) else {

View file

@ -398,7 +398,7 @@ mod tests {
let project = Project::test(fs.clone(), [path!("/test").as_ref()], cx).await;
let (workspace, mut cx) =
let (workspace, cx) =
cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx));
let diff_view = workspace
@ -417,7 +417,7 @@ mod tests {
// Verify initial diff
assert_state_with_diff(
&diff_view.read_with(cx, |diff_view, _| diff_view.editor.clone()),
&mut cx,
cx,
&unindent(
"
- old line 1
@ -452,7 +452,7 @@ mod tests {
cx.executor().advance_clock(RECALCULATE_DIFF_DEBOUNCE);
assert_state_with_diff(
&diff_view.read_with(cx, |diff_view, _| diff_view.editor.clone()),
&mut cx,
cx,
&unindent(
"
- old line 1
@ -487,7 +487,7 @@ mod tests {
cx.executor().advance_clock(RECALCULATE_DIFF_DEBOUNCE);
assert_state_with_diff(
&diff_view.read_with(cx, |diff_view, _| diff_view.editor.clone()),
&mut cx,
cx,
&unindent(
"
ˇnew line 1

View file

@ -103,7 +103,7 @@ fn prompt<T>(
where
T: IntoEnumIterator + VariantNames + 'static,
{
let rx = window.prompt(PromptLevel::Info, msg, detail, &T::VARIANTS, cx);
let rx = window.prompt(PromptLevel::Info, msg, detail, T::VARIANTS, cx);
cx.spawn(async move |_| Ok(T::iter().nth(rx.await?).unwrap()))
}
@ -652,14 +652,14 @@ impl GitPanel {
if GitPanelSettings::get_global(cx).sort_by_path {
return self
.entries
.binary_search_by(|entry| entry.status_entry().unwrap().repo_path.cmp(&path))
.binary_search_by(|entry| entry.status_entry().unwrap().repo_path.cmp(path))
.ok();
}
if self.conflicted_count > 0 {
let conflicted_start = 1;
if let Ok(ix) = self.entries[conflicted_start..conflicted_start + self.conflicted_count]
.binary_search_by(|entry| entry.status_entry().unwrap().repo_path.cmp(&path))
.binary_search_by(|entry| entry.status_entry().unwrap().repo_path.cmp(path))
{
return Some(conflicted_start + ix);
}
@ -671,7 +671,7 @@ impl GitPanel {
0
} + 1;
if let Ok(ix) = self.entries[tracked_start..tracked_start + self.tracked_count]
.binary_search_by(|entry| entry.status_entry().unwrap().repo_path.cmp(&path))
.binary_search_by(|entry| entry.status_entry().unwrap().repo_path.cmp(path))
{
return Some(tracked_start + ix);
}
@ -687,7 +687,7 @@ impl GitPanel {
0
} + 1;
if let Ok(ix) = self.entries[untracked_start..untracked_start + self.new_count]
.binary_search_by(|entry| entry.status_entry().unwrap().repo_path.cmp(&path))
.binary_search_by(|entry| entry.status_entry().unwrap().repo_path.cmp(path))
{
return Some(untracked_start + ix);
}
@ -1341,7 +1341,7 @@ impl GitPanel {
.iter()
.filter_map(|entry| entry.status_entry())
.filter(|status_entry| {
section.contains(&status_entry, repository)
section.contains(status_entry, repository)
&& status_entry.staging.as_bool() != Some(goal_staged_state)
})
.map(|status_entry| status_entry.clone())
@ -1952,7 +1952,7 @@ impl GitPanel {
thinking_allowed: false,
};
let stream = model.stream_completion_text(request, &cx);
let stream = model.stream_completion_text(request, cx);
match stream.await {
Ok(mut messages) => {
if !text_empty {
@ -4620,7 +4620,7 @@ impl editor::Addon for GitPanelAddon {
git_panel
.read(cx)
.render_buffer_header_controls(&git_panel, &file, window, cx)
.render_buffer_header_controls(&git_panel, file, window, cx)
}
}

View file

@ -152,7 +152,7 @@ impl PickerDelegate for PickerPromptDelegate {
.all_options
.iter()
.enumerate()
.map(|(ix, option)| StringMatchCandidate::new(ix, &option))
.map(|(ix, option)| StringMatchCandidate::new(ix, option))
.collect::<Vec<StringMatchCandidate>>()
});
let Some(candidates) = candidates.log_err() else {

View file

@ -1173,7 +1173,7 @@ impl RenderOnce for ProjectDiffEmptyState {
.child(Label::new("No Changes").color(Color::Muted))
} else {
this.when_some(self.current_branch.as_ref(), |this, branch| {
this.child(has_branch_container(&branch))
this.child(has_branch_container(branch))
})
}
}),
@ -1332,14 +1332,14 @@ fn merge_anchor_ranges<'a>(
loop {
if let Some(left_range) = left
.peek()
.filter(|range| range.start.cmp(&next_range.end, &snapshot).is_le())
.filter(|range| range.start.cmp(&next_range.end, snapshot).is_le())
.cloned()
{
left.next();
next_range.end = left_range.end;
} else if let Some(right_range) = right
.peek()
.filter(|range| range.start.cmp(&next_range.end, &snapshot).is_le())
.filter(|range| range.start.cmp(&next_range.end, snapshot).is_le())
.cloned()
{
right.next();

View file

@ -686,7 +686,7 @@ mod tests {
let project = Project::test(fs, [project_root.as_ref()], cx).await;
let (workspace, mut cx) =
let (workspace, cx) =
cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx));
let buffer = project
@ -725,7 +725,7 @@ mod tests {
assert_state_with_diff(
&diff_view.read_with(cx, |diff_view, _| diff_view.diff_editor.clone()),
&mut cx,
cx,
expected_diff,
);