From a8a54be6bcd0667c50b7c739dbfd072df684b3c3 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Thu, 1 Dec 2022 18:37:38 +0200 Subject: [PATCH] Fix nightly clippy lints (#4954) --- helix-term/src/commands.rs | 4 ++-- helix-term/src/commands/lsp.rs | 2 +- helix-term/src/health.rs | 2 +- helix-term/src/keymap.rs | 6 +++--- helix-term/src/ui/editor.rs | 10 +++++----- helix-term/src/ui/mod.rs | 4 ++-- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index a6f88362c..4cd271194 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -2346,8 +2346,8 @@ fn buffer_picker(cx: &mut Context) { let picker = FilePicker::new( cx.editor .documents - .iter() - .map(|(_, doc)| new_meta(doc)) + .values() + .map(|doc| new_meta(doc)) .collect(), (), |cx, meta, action| { diff --git a/helix-term/src/commands/lsp.rs b/helix-term/src/commands/lsp.rs index 1f80de5f8..810e3adf1 100644 --- a/helix-term/src/commands/lsp.rs +++ b/helix-term/src/commands/lsp.rs @@ -706,7 +706,7 @@ pub fn apply_document_resource_op(op: &lsp::ResourceOp) -> std::io::Result<()> { if ignore_if_exists && to.exists() { Ok(()) } else { - fs::rename(&from, &to) + fs::rename(from, &to) } } } diff --git a/helix-term/src/health.rs b/helix-term/src/health.rs index ac9f06fc6..e8fbb84d0 100644 --- a/helix-term/src/health.rs +++ b/helix-term/src/health.rs @@ -281,7 +281,7 @@ fn probe_protocol(protocol_name: &str, server_cmd: Option) -> std::io::R writeln!(stdout, "Configured {}: {}", protocol_name, cmd_name)?; if let Some(cmd) = server_cmd { - let path = match which::which(&cmd) { + let path = match which::which(cmd) { Ok(path) => path.display().to_string().green(), Err(_) => "Not found in $PATH".to_string().red(), }; diff --git a/helix-term/src/keymap.rs b/helix-term/src/keymap.rs index 088b3b6d2..4a131f0a5 100644 --- a/helix-term/src/keymap.rs +++ b/helix-term/src/keymap.rs @@ -390,18 +390,18 @@ impl Keymaps { self.state.push(key); match trie.search(&self.state[1..]) { - Some(&KeyTrie::Node(ref map)) => { + Some(KeyTrie::Node(map)) => { if map.is_sticky { self.state.clear(); self.sticky = Some(map.clone()); } KeymapResult::Pending(map.clone()) } - Some(&KeyTrie::Leaf(ref cmd)) => { + Some(KeyTrie::Leaf(cmd)) => { self.state.clear(); KeymapResult::Matched(cmd.clone()) } - Some(&KeyTrie::Sequence(ref cmds)) => { + Some(KeyTrie::Sequence(cmds)) => { self.state.clear(); KeymapResult::MatchedSequence(cmds.clone()) } diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index 32c8fe91a..fc201853f 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -516,8 +516,8 @@ impl EditorView { use helix_core::graphemes::{grapheme_width, RopeGraphemes}; for grapheme in RopeGraphemes::new(text) { - let out_of_bounds = offset.col > (visual_x as usize) - || (visual_x as usize) >= viewport.width as usize + offset.col; + let out_of_bounds = offset.col > visual_x + || visual_x >= viewport.width as usize + offset.col; if LineEnding::from_rope_slice(&grapheme).is_some() { if !out_of_bounds { @@ -547,7 +547,7 @@ impl EditorView { let (display_grapheme, width) = if grapheme == "\t" { is_whitespace = true; // make sure we display tab as appropriate amount of spaces - let visual_tab_width = tab_width - (visual_x as usize % tab_width); + let visual_tab_width = tab_width - (visual_x % tab_width); let grapheme_tab_width = helix_core::str_utils::char_to_byte_idx(&tab, visual_tab_width); @@ -566,7 +566,7 @@ impl EditorView { (grapheme.as_ref(), width) }; - let cut_off_start = offset.col.saturating_sub(visual_x as usize); + let cut_off_start = offset.col.saturating_sub(visual_x); if !out_of_bounds { // if we're offscreen just keep going until we hit a new line @@ -583,7 +583,7 @@ impl EditorView { } else if cut_off_start != 0 && cut_off_start < width { // partially on screen let rect = Rect::new( - viewport.x as u16, + viewport.x, viewport.y + line, (width - cut_off_start) as u16, 1, diff --git a/helix-term/src/ui/mod.rs b/helix-term/src/ui/mod.rs index 3416b3194..f61c4c450 100644 --- a/helix-term/src/ui/mod.rs +++ b/helix-term/src/ui/mod.rs @@ -254,8 +254,8 @@ pub mod completers { pub fn buffer(editor: &Editor, input: &str) -> Vec { let mut names: Vec<_> = editor .documents - .iter() - .map(|(_id, doc)| { + .values() + .map(|doc| { let name = doc .relative_path() .map(|p| p.display().to_string())