Skip to content

Commit 37fe42d

Browse files
authored
fix(lints): clippy 1.89-1.90 (#14223)
1 parent 55167c2 commit 37fe42d

File tree

24 files changed

+39
-43
lines changed

24 files changed

+39
-43
lines changed

helix-core/src/indent.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::{borrow::Cow, collections::HashMap, iter};
1+
use std::{borrow::Cow, collections::HashMap};
22

33
use helix_stdx::rope::RopeSliceExt;
44
use tree_house::TREE_SITTER_MATCH_LIMIT;
@@ -214,7 +214,10 @@ fn whitespace_with_same_width(text: RopeSlice) -> String {
214214
if grapheme == "\t" {
215215
s.push('\t');
216216
} else {
217-
s.extend(std::iter::repeat(' ').take(grapheme_width(&Cow::from(grapheme))));
217+
s.extend(std::iter::repeat_n(
218+
' ',
219+
grapheme_width(&Cow::from(grapheme)),
220+
));
218221
}
219222
}
220223
s
@@ -243,10 +246,10 @@ pub fn normalize_indentation(
243246
original_len += 1;
244247
}
245248
if indent_style == IndentStyle::Tabs {
246-
dst.extend(iter::repeat('\t').take(len / tab_width));
249+
dst.extend(std::iter::repeat_n('\t', len / tab_width));
247250
len %= tab_width;
248251
}
249-
dst.extend(iter::repeat(' ').take(len));
252+
dst.extend(std::iter::repeat_n(' ', len));
250253
original_len
251254
}
252255

helix-core/src/snippets/elaborate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ impl Transform {
361361
}
362362
}
363363
FormatItem::Conditional(i, ref if_, ref else_) => {
364-
if cap.get_group(i).map_or(true, |mat| mat.is_empty()) {
364+
if cap.get_group(i).is_none_or(|mat| mat.is_empty()) {
365365
buf.push_str(else_)
366366
} else {
367367
buf.push_str(if_)

helix-core/src/syntax.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -562,15 +562,15 @@ impl Syntax {
562562
self.inner.tree_for_byte_range(start, end)
563563
}
564564

565-
pub fn named_descendant_for_byte_range(&self, start: u32, end: u32) -> Option<Node> {
565+
pub fn named_descendant_for_byte_range(&self, start: u32, end: u32) -> Option<Node<'_>> {
566566
self.inner.named_descendant_for_byte_range(start, end)
567567
}
568568

569-
pub fn descendant_for_byte_range(&self, start: u32, end: u32) -> Option<Node> {
569+
pub fn descendant_for_byte_range(&self, start: u32, end: u32) -> Option<Node<'_>> {
570570
self.inner.descendant_for_byte_range(start, end)
571571
}
572572

573-
pub fn walk(&self) -> TreeCursor {
573+
pub fn walk(&self) -> TreeCursor<'_> {
574574
self.inner.walk()
575575
}
576576

@@ -1073,7 +1073,7 @@ fn node_is_visible(node: &Node) -> bool {
10731073
node.is_missing() || (node.is_named() && node.grammar().node_kind_is_visible(node.kind_id()))
10741074
}
10751075

1076-
fn format_anonymous_node_kind(kind: &str) -> Cow<str> {
1076+
fn format_anonymous_node_kind(kind: &str) -> Cow<'_, str> {
10771077
if kind.contains('"') {
10781078
Cow::Owned(kind.replace('"', "\\\""))
10791079
} else {
@@ -1130,7 +1130,6 @@ fn pretty_print_tree_impl<W: fmt::Write>(
11301130
}
11311131

11321132
/// Finds the child of `node` which contains the given byte range.
1133-
11341133
pub fn child_for_byte_range<'a>(node: &Node<'a>, range: ops::Range<u32>) -> Option<Node<'a>> {
11351134
for child in node.children() {
11361135
let child_range = child.byte_range();

helix-core/src/transaction.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ impl ChangeSet {
520520
pos
521521
}
522522

523-
pub fn changes_iter(&self) -> ChangeIterator {
523+
pub fn changes_iter(&self) -> ChangeIterator<'_> {
524524
ChangeIterator::new(self)
525525
}
526526
}
@@ -753,7 +753,7 @@ impl Transaction {
753753
})
754754
}
755755

756-
pub fn changes_iter(&self) -> ChangeIterator {
756+
pub fn changes_iter(&self) -> ChangeIterator<'_> {
757757
self.changes.changes_iter()
758758
}
759759
}

helix-lsp-types/src/code_action.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ pub struct CodeActionParams {
129129
/// response for CodeActionRequest
130130
pub type CodeActionResponse = Vec<CodeActionOrCommand>;
131131

132+
#[allow(clippy::large_enum_variant)] // TODO: In a separate PR attempt the `Box<CodeAction>` pattern.
132133
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
133134
#[serde(untagged)]
134135
pub enum CodeActionOrCommand {

helix-lsp-types/src/progress.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,6 @@ pub struct WorkDoneProgressCancelParams {
4040
pub token: ProgressToken,
4141
}
4242

43-
/// Options to signal work done progress support in server capabilities.
44-
#[derive(Debug, Eq, PartialEq, Default, Deserialize, Serialize, Clone)]
45-
#[serde(rename_all = "camelCase")]
46-
pub struct WorkDoneProgressOptions {
47-
#[serde(skip_serializing_if = "Option::is_none")]
48-
pub work_done_progress: Option<bool>,
49-
}
50-
5143
/// An optional token that a server can use to report work done progress
5244
#[derive(Debug, Eq, PartialEq, Default, Deserialize, Serialize, Clone)]
5345
#[serde(rename_all = "camelCase")]

helix-stdx/src/env.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ fn find_brace_end(src: &[u8]) -> Option<usize> {
8585
None
8686
}
8787

88-
fn expand_impl(src: &OsStr, mut resolve: impl FnMut(&OsStr) -> Option<OsString>) -> Cow<OsStr> {
88+
fn expand_impl(src: &OsStr, mut resolve: impl FnMut(&OsStr) -> Option<OsString>) -> Cow<'_, OsStr> {
8989
use regex_automata::meta::Regex;
9090

9191
static REGEX: Lazy<Regex> = Lazy::new(|| {
@@ -157,7 +157,7 @@ fn expand_impl(src: &OsStr, mut resolve: impl FnMut(&OsStr) -> Option<OsString>)
157157
/// * `${<var>:-<default>}`, `${<var>-<default>}`
158158
/// * `${<var>:=<default>}`, `${<var>=default}`
159159
///
160-
pub fn expand<S: AsRef<OsStr> + ?Sized>(src: &S) -> Cow<OsStr> {
160+
pub fn expand<S: AsRef<OsStr> + ?Sized>(src: &S) -> Cow<'_, OsStr> {
161161
expand_impl(src.as_ref(), |var| std::env::var_os(var))
162162
}
163163

helix-term/src/commands/lsp.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ struct PickerDiagnostic {
100100
diag: lsp::Diagnostic,
101101
}
102102

103-
fn location_to_file_location(location: &Location) -> Option<FileLocation> {
103+
fn location_to_file_location(location: &Location) -> Option<FileLocation<'_>> {
104104
let path = location.uri.as_path()?;
105105
let line = Some((
106106
location.range.start.line as usize,
@@ -589,7 +589,7 @@ struct CodeActionOrCommandItem {
589589

590590
impl ui::menu::Item for CodeActionOrCommandItem {
591591
type Data = ();
592-
fn format(&self, _data: &Self::Data) -> Row {
592+
fn format(&self, _data: &Self::Data) -> Row<'_> {
593593
match &self.lsp_item {
594594
lsp::CodeActionOrCommand::CodeAction(action) => action.title.as_str().into(),
595595
lsp::CodeActionOrCommand::Command(command) => command.title.as_str().into(),
@@ -1146,7 +1146,7 @@ pub fn rename_symbol(cx: &mut Context) {
11461146

11471147
let Some(language_server) = doc
11481148
.language_servers_with_feature(LanguageServerFeature::RenameSymbol)
1149-
.find(|ls| language_server_id.map_or(true, |id| id == ls.id()))
1149+
.find(|ls| language_server_id.is_none_or(|id| id == ls.id()))
11501150
else {
11511151
cx.editor
11521152
.set_error("No configured language server supports symbol renaming");

helix-term/src/commands/typed.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3740,7 +3740,7 @@ pub(super) fn command_mode(cx: &mut Context) {
37403740
cx.push_layer(Box::new(prompt));
37413741
}
37423742

3743-
fn command_line_doc(input: &str) -> Option<Cow<str>> {
3743+
fn command_line_doc(input: &str) -> Option<Cow<'_, str>> {
37443744
let (command, _, _) = command_line::split(input);
37453745
let command = TYPABLE_COMMAND_MAP.get(command)?;
37463746

helix-term/src/handlers/completion/item.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ impl LspCompletionItem {
6767
}
6868
}
6969

70+
#[allow(clippy::large_enum_variant)] // TODO: In a separate PR attempt the `Box<LspCompletionItem>` pattern.
7071
#[derive(Debug, PartialEq, Clone)]
7172
pub enum CompletionItem {
7273
Lsp(LspCompletionItem),

0 commit comments

Comments
 (0)