Another batch of lint fixes (#36521)

- **Enable a bunch of extra lints**
- **First batch of fixes**
- **More fixes**

Release Notes:

- N/A
This commit is contained in:
Piotr Osiewicz 2025-08-19 22:33:44 +02:00 committed by GitHub
parent 69b1c6d6f5
commit 6825715503
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
147 changed files with 788 additions and 1042 deletions

View file

@ -61,14 +61,14 @@ pub fn replacement(c: char) -> Option<&'static str> {
// but could if we tracked state in the classifier.
const IDEOGRAPHIC_SPACE: char = '\u{3000}';
const C0_SYMBOLS: &'static [&'static str] = &[
const C0_SYMBOLS: &[&str] = &[
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "",
];
const DEL: &'static str = "";
const DEL: &str = "";
// generated using ucd-generate: ucd-generate general-category --include Format --chars ucd-16.0.0
pub const FORMAT: &'static [(char, char)] = &[
pub const FORMAT: &[(char, char)] = &[
('\u{ad}', '\u{ad}'),
('\u{600}', '\u{605}'),
('\u{61c}', '\u{61c}'),
@ -93,7 +93,7 @@ pub const FORMAT: &'static [(char, char)] = &[
];
// hand-made base on https://invisible-characters.com (Excluding Cf)
pub const OTHER: &'static [(char, char)] = &[
pub const OTHER: &[(char, char)] = &[
('\u{034f}', '\u{034f}'),
('\u{115F}', '\u{1160}'),
('\u{17b4}', '\u{17b5}'),
@ -107,7 +107,7 @@ pub const OTHER: &'static [(char, char)] = &[
];
// a subset of FORMAT/OTHER that may appear within glyphs
const PRESERVE: &'static [(char, char)] = &[
const PRESERVE: &[(char, char)] = &[
('\u{034f}', '\u{034f}'),
('\u{200d}', '\u{200d}'),
('\u{17b4}', '\u{17b5}'),

View file

@ -1943,26 +1943,24 @@ impl Editor {
let git_store = project.read(cx).git_store().clone();
let project = project.clone();
project_subscriptions.push(cx.subscribe(&git_store, move |this, _, event, cx| {
match event {
GitStoreEvent::RepositoryUpdated(
_,
RepositoryEvent::Updated {
new_instance: true, ..
},
_,
) => {
this.load_diff_task = Some(
update_uncommitted_diff_for_buffer(
cx.entity(),
&project,
this.buffer.read(cx).all_buffers(),
this.buffer.clone(),
cx,
)
.shared(),
);
}
_ => {}
if let GitStoreEvent::RepositoryUpdated(
_,
RepositoryEvent::Updated {
new_instance: true, ..
},
_,
) = event
{
this.load_diff_task = Some(
update_uncommitted_diff_for_buffer(
cx.entity(),
&project,
this.buffer.read(cx).all_buffers(),
this.buffer.clone(),
cx,
)
.shared(),
);
}
}));
}
@ -3221,35 +3219,31 @@ impl Editor {
selections.select_anchors(other_selections);
});
let other_subscription =
cx.subscribe(&other, |this, other, other_evt, cx| match other_evt {
EditorEvent::SelectionsChanged { local: true } => {
let other_selections = other.read(cx).selections.disjoint.to_vec();
if other_selections.is_empty() {
return;
}
this.selections.change_with(cx, |selections| {
selections.select_anchors(other_selections);
});
let other_subscription = cx.subscribe(&other, |this, other, other_evt, cx| {
if let EditorEvent::SelectionsChanged { local: true } = other_evt {
let other_selections = other.read(cx).selections.disjoint.to_vec();
if other_selections.is_empty() {
return;
}
_ => {}
});
this.selections.change_with(cx, |selections| {
selections.select_anchors(other_selections);
});
}
});
let this_subscription =
cx.subscribe_self::<EditorEvent>(move |this, this_evt, cx| match this_evt {
EditorEvent::SelectionsChanged { local: true } => {
let these_selections = this.selections.disjoint.to_vec();
if these_selections.is_empty() {
return;
}
other.update(cx, |other_editor, cx| {
other_editor.selections.change_with(cx, |selections| {
selections.select_anchors(these_selections);
})
});
let this_subscription = cx.subscribe_self::<EditorEvent>(move |this, this_evt, cx| {
if let EditorEvent::SelectionsChanged { local: true } = this_evt {
let these_selections = this.selections.disjoint.to_vec();
if these_selections.is_empty() {
return;
}
_ => {}
});
other.update(cx, |other_editor, cx| {
other_editor.selections.change_with(cx, |selections| {
selections.select_anchors(these_selections);
})
});
}
});
Subscription::join(other_subscription, this_subscription)
}
@ -5661,34 +5655,31 @@ impl Editor {
let Ok(()) = editor.update_in(cx, |editor, window, cx| {
// Newer menu already set, so exit.
match editor.context_menu.borrow().as_ref() {
Some(CodeContextMenu::Completions(prev_menu)) => {
if prev_menu.id > id {
return;
}
}
_ => {}
if let Some(CodeContextMenu::Completions(prev_menu)) =
editor.context_menu.borrow().as_ref()
&& prev_menu.id > id
{
return;
};
// Only valid to take prev_menu because it the new menu is immediately set
// below, or the menu is hidden.
match editor.context_menu.borrow_mut().take() {
Some(CodeContextMenu::Completions(prev_menu)) => {
let position_matches =
if prev_menu.initial_position == menu.initial_position {
true
} else {
let snapshot = editor.buffer.read(cx).read(cx);
prev_menu.initial_position.to_offset(&snapshot)
== menu.initial_position.to_offset(&snapshot)
};
if position_matches {
// Preserve markdown cache before `set_filter_results` because it will
// try to populate the documentation cache.
menu.preserve_markdown_cache(prev_menu);
}
if let Some(CodeContextMenu::Completions(prev_menu)) =
editor.context_menu.borrow_mut().take()
{
let position_matches =
if prev_menu.initial_position == menu.initial_position {
true
} else {
let snapshot = editor.buffer.read(cx).read(cx);
prev_menu.initial_position.to_offset(&snapshot)
== menu.initial_position.to_offset(&snapshot)
};
if position_matches {
// Preserve markdown cache before `set_filter_results` because it will
// try to populate the documentation cache.
menu.preserve_markdown_cache(prev_menu);
}
_ => {}
};
menu.set_filter_results(matches, provider, window, cx);
@ -6179,12 +6170,11 @@ impl Editor {
}
});
Some(cx.background_spawn(async move {
let scenarios = futures::future::join_all(scenarios)
futures::future::join_all(scenarios)
.await
.into_iter()
.flatten()
.collect::<Vec<_>>();
scenarios
.collect::<Vec<_>>()
}))
})
.unwrap_or_else(|| Task::ready(vec![]))
@ -7740,12 +7730,9 @@ impl Editor {
self.edit_prediction_settings =
self.edit_prediction_settings_at_position(&buffer, cursor_buffer_position, cx);
match self.edit_prediction_settings {
EditPredictionSettings::Disabled => {
self.discard_edit_prediction(false, cx);
return None;
}
_ => {}
if let EditPredictionSettings::Disabled = self.edit_prediction_settings {
self.discard_edit_prediction(false, cx);
return None;
};
self.edit_prediction_indent_conflict = multibuffer.is_line_whitespace_upto(cursor);
@ -10638,8 +10625,7 @@ impl Editor {
.buffer_snapshot
.anchor_after(Point::new(row, line_len));
let bp = self
.breakpoint_store
self.breakpoint_store
.as_ref()?
.read_with(cx, |breakpoint_store, cx| {
breakpoint_store
@ -10664,8 +10650,7 @@ impl Editor {
None
}
})
});
bp
})
}
pub fn edit_log_breakpoint(
@ -10701,7 +10686,7 @@ impl Editor {
let cursors = self
.selections
.disjoint_anchors()
.into_iter()
.iter()
.map(|selection| {
let cursor_position: Point = selection.head().to_point(&snapshot.buffer_snapshot);
@ -14878,7 +14863,7 @@ impl Editor {
let start = parent.start - offset;
offset += parent.len() - text.len();
selections.push(Selection {
id: id,
id,
start,
end: start + text.len(),
reversed: false,
@ -19202,7 +19187,7 @@ impl Editor {
let locations = self
.selections
.all_anchors(cx)
.into_iter()
.iter()
.map(|selection| Location {
buffer: buffer.clone(),
range: selection.start.text_anchor..selection.end.text_anchor,
@ -19914,11 +19899,8 @@ impl Editor {
event: &SessionEvent,
cx: &mut Context<Self>,
) {
match event {
SessionEvent::InvalidateInlineValue => {
self.refresh_inline_values(cx);
}
_ => {}
if let SessionEvent::InvalidateInlineValue = event {
self.refresh_inline_values(cx);
}
}

View file

@ -21037,7 +21037,7 @@ fn assert_breakpoint(
let mut breakpoint = breakpoints
.get(path)
.unwrap()
.into_iter()
.iter()
.map(|breakpoint| {
(
breakpoint.row,
@ -23622,7 +23622,7 @@ pub fn handle_completion_request(
complete_from_position
);
Ok(Some(lsp::CompletionResponse::List(lsp::CompletionList {
is_incomplete: is_incomplete,
is_incomplete,
item_defaults: None,
items: completions
.iter()

View file

@ -724,7 +724,7 @@ impl EditorElement {
ColumnarMode::FromMouse => true,
ColumnarMode::FromSelection => false,
},
mode: mode,
mode,
goal_column: point_for_position.exact_unclipped.column(),
},
window,
@ -2437,14 +2437,13 @@ impl EditorElement {
.unwrap_or_default()
.padding as f32;
if let Some(edit_prediction) = editor.active_edit_prediction.as_ref() {
match &edit_prediction.completion {
EditPrediction::Edit {
display_mode: EditDisplayMode::TabAccept,
..
} => padding += INLINE_ACCEPT_SUGGESTION_EM_WIDTHS,
_ => {}
}
if let Some(edit_prediction) = editor.active_edit_prediction.as_ref()
&& let EditPrediction::Edit {
display_mode: EditDisplayMode::TabAccept,
..
} = &edit_prediction.completion
{
padding += INLINE_ACCEPT_SUGGESTION_EM_WIDTHS
}
padding * em_width
@ -2978,8 +2977,8 @@ impl EditorElement {
.ilog10()
+ 1;
let elements = buffer_rows
.into_iter()
buffer_rows
.iter()
.enumerate()
.map(|(ix, row_info)| {
let ExpandInfo {
@ -3034,9 +3033,7 @@ impl EditorElement {
Some((toggle, origin))
})
.collect();
elements
.collect()
}
fn calculate_relative_line_numbers(
@ -3136,7 +3133,7 @@ impl EditorElement {
let relative_rows = self.calculate_relative_line_numbers(snapshot, &rows, relative_to);
let mut line_number = String::new();
let line_numbers = buffer_rows
.into_iter()
.iter()
.enumerate()
.flat_map(|(ix, row_info)| {
let display_row = DisplayRow(rows.start.0 + ix as u32);
@ -3213,7 +3210,7 @@ impl EditorElement {
&& self.editor.read(cx).is_singleton(cx);
if include_fold_statuses {
row_infos
.into_iter()
.iter()
.enumerate()
.map(|(ix, info)| {
if info.expand_info.is_some() {

View file

@ -213,8 +213,8 @@ impl GitBlame {
let project_subscription = cx.subscribe(&project, {
let buffer = buffer.clone();
move |this, _, event, cx| match event {
project::Event::WorktreeUpdatedEntries(_, updated) => {
move |this, _, event, cx| {
if let project::Event::WorktreeUpdatedEntries(_, updated) = event {
let project_entry_id = buffer.read(cx).entry_id(cx);
if updated
.iter()
@ -224,7 +224,6 @@ impl GitBlame {
this.generate(cx);
}
}
_ => {}
}
});
@ -292,7 +291,7 @@ impl GitBlame {
let buffer_id = self.buffer_snapshot.remote_id();
let mut cursor = self.entries.cursor::<u32>(&());
rows.into_iter().map(move |info| {
rows.iter().map(move |info| {
let row = info
.buffer_row
.filter(|_| info.buffer_id == Some(buffer_id))?;

View file

@ -603,18 +603,15 @@ async fn parse_blocks(
})
.join("\n\n");
let rendered_block = cx
.new_window_entity(|_window, cx| {
Markdown::new(
combined_text.into(),
language_registry.cloned(),
language.map(|language| language.name()),
cx,
)
})
.ok();
rendered_block
cx.new_window_entity(|_window, cx| {
Markdown::new(
combined_text.into(),
language_registry.cloned(),
language.map(|language| language.name()),
cx,
)
})
.ok()
}
pub fn hover_markdown_style(window: &Window, cx: &App) -> MarkdownStyle {

View file

@ -1009,16 +1009,12 @@ impl Item for Editor {
) {
self.workspace = Some((workspace.weak_handle(), workspace.database_id()));
if let Some(workspace) = &workspace.weak_handle().upgrade() {
cx.subscribe(
workspace,
|editor, _, event: &workspace::Event, _cx| match event {
workspace::Event::ModalOpened => {
editor.mouse_context_menu.take();
editor.inline_blame_popover.take();
}
_ => {}
},
)
cx.subscribe(workspace, |editor, _, event: &workspace::Event, _cx| {
if let workspace::Event::ModalOpened = event {
editor.mouse_context_menu.take();
editor.inline_blame_popover.take();
}
})
.detach();
}
}

View file

@ -808,10 +808,7 @@ mod jsx_tag_autoclose_tests {
);
buf
});
let buffer_c = cx.new(|cx| {
let buf = language::Buffer::local("<span", cx);
buf
});
let buffer_c = cx.new(|cx| language::Buffer::local("<span", cx));
let buffer = cx.new(|cx| {
let mut buf = MultiBuffer::new(language::Capability::ReadWrite);
buf.push_excerpts(

View file

@ -241,24 +241,13 @@ impl ProposedChangesEditor {
event: &BufferEvent,
_cx: &mut Context<Self>,
) {
match event {
BufferEvent::Operation { .. } => {
self.recalculate_diffs_tx
.unbounded_send(RecalculateDiff {
buffer,
debounce: true,
})
.ok();
}
// BufferEvent::DiffBaseChanged => {
// self.recalculate_diffs_tx
// .unbounded_send(RecalculateDiff {
// buffer,
// debounce: false,
// })
// .ok();
// }
_ => (),
if let BufferEvent::Operation { .. } = event {
self.recalculate_diffs_tx
.unbounded_send(RecalculateDiff {
buffer,
debounce: true,
})
.ok();
}
}
}

View file

@ -119,8 +119,8 @@ impl SelectionsCollection {
cx: &mut App,
) -> Option<Selection<D>> {
let map = self.display_map(cx);
let selection = resolve_selections(self.pending_anchor().as_ref(), &map).next();
selection
resolve_selections(self.pending_anchor().as_ref(), &map).next()
}
pub(crate) fn pending_mode(&self) -> Option<SelectMode> {
@ -276,18 +276,18 @@ impl SelectionsCollection {
cx: &mut App,
) -> Selection<D> {
let map = self.display_map(cx);
let selection = resolve_selections([self.newest_anchor()], &map)
resolve_selections([self.newest_anchor()], &map)
.next()
.unwrap();
selection
.unwrap()
}
pub fn newest_display(&self, cx: &mut App) -> Selection<DisplayPoint> {
let map = self.display_map(cx);
let selection = resolve_selections_display([self.newest_anchor()], &map)
resolve_selections_display([self.newest_anchor()], &map)
.next()
.unwrap();
selection
.unwrap()
}
pub fn oldest_anchor(&self) -> &Selection<Anchor> {
@ -303,10 +303,10 @@ impl SelectionsCollection {
cx: &mut App,
) -> Selection<D> {
let map = self.display_map(cx);
let selection = resolve_selections([self.oldest_anchor()], &map)
resolve_selections([self.oldest_anchor()], &map)
.next()
.unwrap();
selection
.unwrap()
}
pub fn first_anchor(&self) -> Selection<Anchor> {