From 26cb8c060685a893ab45d377ba89a9e02ab85b63 Mon Sep 17 00:00:00 2001 From: RoloEdits Date: Mon, 2 Feb 2026 15:36:58 -0800 Subject: [PATCH] fix(lints): clippy 1.93 (#15232) --- helix-core/src/diagnostic.rs | 8 ++------ helix-core/src/graphemes.rs | 2 +- helix-core/src/snippets/active.rs | 2 +- helix-core/src/snippets/elaborate.rs | 7 ++----- helix-term/src/commands.rs | 2 +- helix-term/src/ui/document.rs | 2 +- helix-vcs/src/diff/line_cache.rs | 6 +++--- helix-view/src/graphics.rs | 8 ++------ 8 files changed, 13 insertions(+), 24 deletions(-) diff --git a/helix-core/src/diagnostic.rs b/helix-core/src/diagnostic.rs index b9360b52..4525653a 100644 --- a/helix-core/src/diagnostic.rs +++ b/helix-core/src/diagnostic.rs @@ -7,19 +7,15 @@ use serde::{Deserialize, Serialize}; /// Describes the severity level of a [`Diagnostic`]. #[derive(Debug, Clone, Copy, Eq, PartialEq, PartialOrd, Ord, Serialize, Deserialize)] #[serde(rename_all = "lowercase")] +#[derive(Default)] pub enum Severity { + #[default] Hint, Info, Warning, Error, } -impl Default for Severity { - fn default() -> Self { - Self::Hint - } -} - #[derive(Debug, Eq, Hash, PartialEq, Clone, Deserialize, Serialize)] pub enum NumberOrString { Number(i32), diff --git a/helix-core/src/graphemes.rs b/helix-core/src/graphemes.rs index 4cbb5746..6ec9d979 100644 --- a/helix-core/src/graphemes.rs +++ b/helix-core/src/graphemes.rs @@ -273,7 +273,7 @@ impl Drop for GraphemeStr<'_> { if self.len & Self::MASK_OWNED != 0 { // free allocation unsafe { - drop(Box::from_raw(slice::from_raw_parts_mut( + drop(Box::from_raw(std::ptr::slice_from_raw_parts_mut( self.ptr.as_ptr(), self.compute_len(), ))); diff --git a/helix-core/src/snippets/active.rs b/helix-core/src/snippets/active.rs index 1c10b76d..628d897c 100644 --- a/helix-core/src/snippets/active.rs +++ b/helix-core/src/snippets/active.rs @@ -201,7 +201,7 @@ impl ActiveSnippet { } pub fn insert_subsnippet(mut self, snippet: RenderedSnippet) -> Option { - if snippet.ranges.len() % self.ranges.len() != 0 + if !snippet.ranges.len().is_multiple_of(self.ranges.len()) || !is_exact_subset(self.ranges.iter().copied(), snippet.ranges.iter().copied()) { log::warn!("number of subsnippets did not match, discarding outer snippet"); diff --git a/helix-core/src/snippets/elaborate.rs b/helix-core/src/snippets/elaborate.rs index b17c149f..e6dd1c63 100644 --- a/helix-core/src/snippets/elaborate.rs +++ b/helix-core/src/snippets/elaborate.rs @@ -323,13 +323,10 @@ impl Transform { pub fn apply(&self, mut doc: RopeSlice<'_>, range: Range) -> Tendril { let mut buf = Tendril::new(); - let it = self - .regex - .captures_iter(doc.regex_input_at(range)) - .enumerate(); + let it = self.regex.captures_iter(doc.regex_input_at(range)); doc = doc.slice(range); let mut last_match = 0; - for (_, cap) in it { + for cap in it { // unwrap on 0 is OK because captures only reports matches let m = cap.get_group(0).unwrap(); buf.extend(doc.byte_slice(last_match..m.start).chunks()); diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 6a659e55..44256fb8 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -5455,7 +5455,7 @@ fn reorder_selection_contents(cx: &mut Context, strategy: ReorderStrategy) { (selection.primary_index() + ranges.len() - rotate_by) % ranges.len() } ReorderStrategy::Reverse => { - if rotate_by % 2 == 0 { + if rotate_by.is_multiple_of(2) { // nothing changed, if we reverse something an even // amount of times, the output will be the same return; diff --git a/helix-term/src/ui/document.rs b/helix-term/src/ui/document.rs index 846c545f..7de1ed24 100644 --- a/helix-term/src/ui/document.rs +++ b/helix-term/src/ui/document.rs @@ -258,7 +258,7 @@ impl<'a> TextRenderer<'a> { whitespace_style: theme.get("ui.virtual.whitespace"), indent_width, starting_indent: offset.col / indent_width as usize - + (offset.col % indent_width as usize != 0) as usize + + !offset.col.is_multiple_of(indent_width as usize) as usize + editor_config.indent_guides.skip_levels as usize, indent_guide_style: text_style.patch( theme diff --git a/helix-vcs/src/diff/line_cache.rs b/helix-vcs/src/diff/line_cache.rs index 187ac540..c66c8913 100644 --- a/helix-vcs/src/diff/line_cache.rs +++ b/helix-vcs/src/diff/line_cache.rs @@ -54,9 +54,9 @@ impl InternedRopeLines { /// Updates the `diff_base` and optionally the document if `doc` is not None pub fn update_diff_base(&mut self, diff_base: Rope, doc: Option) { self.interned.clear(); - self.diff_base = Box::new(diff_base); + *self.diff_base = diff_base; if let Some(doc) = doc { - self.doc = Box::new(doc) + *self.doc = doc } if !self.is_too_large() { self.update_diff_base_impl(); @@ -74,7 +74,7 @@ impl InternedRopeLines { .interner .erase_tokens_after(self.num_tokens_diff_base.into()); - self.doc = Box::new(doc); + *self.doc = doc; if self.is_too_large() { self.interned.after.clear(); } else { diff --git a/helix-view/src/graphics.rs b/helix-view/src/graphics.rs index bf92a445..e4fa3e38 100644 --- a/helix-view/src/graphics.rs +++ b/helix-view/src/graphics.rs @@ -50,8 +50,10 @@ const fn byte_from_hex(mut h: [u8; 2]) -> Option { #[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize, Serialize)] #[serde(rename_all = "lowercase")] /// UNSTABLE +#[derive(Default)] pub enum CursorKind { /// █ + #[default] Block, /// | Bar, @@ -61,12 +63,6 @@ pub enum CursorKind { Hidden, } -impl Default for CursorKind { - fn default() -> Self { - Self::Block - } -} - #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct Margin { pub horizontal: u16, -- 2.51.2