From 3110de8803887e9ee49a503acfec6ab7e36dd0e2 Mon Sep 17 00:00:00 2001 From: l0ng-ai <24760907+l0ng-ai@users.noreply.github.com> Date: Thu, 22 Oct 2026 22:01:38 +0800 Subject: [PATCH] fix: Satisfy clippy 1.99 lints Box the unknown-host-key error variant (result_large_err), decode semantic tokens with as_chunks, and use `?` for the warning-prefix fallbacks. Claude-Session: https://claude.ai/code/session_01B65qLEKnkeYTGdbwhLpjCu --- crates/ide-build/src/compile/parse.rs | 20 ++++++++------------ crates/ide-db/src/lib.rs | 2 +- crates/ide-db/src/tunnel.rs | 4 ++-- crates/ide-lsp/src/convert.rs | 3 +-- 4 files changed, 12 insertions(+), 17 deletions(-) diff --git a/crates/ide-build/src/compile/parse.rs b/crates/ide-build/src/compile/parse.rs index 011440206..e7e935cfd 100644 --- a/crates/ide-build/src/compile/parse.rs +++ b/crates/ide-build/src/compile/parse.rs @@ -209,10 +209,9 @@ fn kotlin_location(s: &str, severity: Severity) -> Option { fn kotlin_line(line: &str) -> Option { let (severity, rest) = if let Some(r) = line.strip_prefix("e: ") { (Severity::Error, r) - } else if let Some(r) = line.strip_prefix("w: ") { - (Severity::Warning, r) } else { - return None; + let r = line.strip_prefix("w: ")?; + (Severity::Warning, r) }; kotlin_location(rest, severity) } @@ -226,10 +225,9 @@ fn javac_header(line: &str) -> Option { let rest = rest.trim_start_matches(':').trim_start(); let (severity, msg) = if let Some(m) = rest.strip_prefix("error:") { (Severity::Error, m) - } else if let Some(m) = rest.strip_prefix("warning:") { - (Severity::Warning, m) } else { - return None; + let m = rest.strip_prefix("warning:")?; + (Severity::Warning, m) }; Some(RawMessage::new(severity, msg.trim(), ColUnit::Char).at(path, ln, col)) } @@ -238,10 +236,9 @@ fn javac_header(line: &str) -> Option { fn maven_line(line: &str) -> Option { let (severity, rest) = if let Some(r) = line.strip_prefix("[ERROR] ") { (Severity::Error, r) - } else if let Some(r) = line.strip_prefix("[WARNING] ") { - (Severity::Warning, r) } else { - return None; + let r = line.strip_prefix("[WARNING] ")?; + (Severity::Warning, r) }; let rest = rest.trim_start(); if let Some((path, pos)) = rest.split_once(":[") @@ -276,10 +273,9 @@ fn tsc_line(line: &str) -> Option { let rest = rest.trim_start(); let (severity, rest) = if let Some(r) = rest.strip_prefix("error") { (Severity::Error, r) - } else if let Some(r) = rest.strip_prefix("warning") { - (Severity::Warning, r) } else { - return None; + let r = rest.strip_prefix("warning")?; + (Severity::Warning, r) }; let (code, msg) = match rest.trim_start().split_once(':') { Some((code, msg)) if code.starts_with("TS") => (Some(code.to_owned()), msg.trim()), diff --git a/crates/ide-db/src/lib.rs b/crates/ide-db/src/lib.rs index dbf3b82f0..1b3e05b78 100644 --- a/crates/ide-db/src/lib.rs +++ b/crates/ide-db/src/lib.rs @@ -398,7 +398,7 @@ impl DbManager { Err(OpenError::Other(e)) => Err(e), Err(OpenError::UnknownHostKey(k)) => { let message = format!("Unknown SSH host key for {}:{} ({})", k.host, k.port, k.fingerprint()); - self.unknown_host_keys.lock().insert(source.id.clone(), k); + self.unknown_host_keys.lock().insert(source.id.clone(), *k); Err(IdeError::new(ErrorKind::Protocol, message)) } } diff --git a/crates/ide-db/src/tunnel.rs b/crates/ide-db/src/tunnel.rs index 3959e4dad..84539a5e5 100644 --- a/crates/ide-db/src/tunnel.rs +++ b/crates/ide-db/src/tunnel.rs @@ -44,7 +44,7 @@ impl UnknownHostKey { #[derive(Debug)] pub enum OpenError { - UnknownHostKey(UnknownHostKey), + UnknownHostKey(Box), Other(IdeError), } @@ -319,7 +319,7 @@ where }; result.map_err(|e| match issue.lock().take() { Some(HostKeyIssue::Unknown(key)) => { - OpenError::UnknownHostKey(UnknownHostKey { host: hop.host.clone(), port: hop.port, key }) + OpenError::UnknownHostKey(Box::new(UnknownHostKey { host: hop.host.clone(), port: hop.port, key })) } Some(HostKeyIssue::Changed(line)) => OpenError::Other(IdeError::new( ErrorKind::PermissionDenied, diff --git a/crates/ide-lsp/src/convert.rs b/crates/ide-lsp/src/convert.rs index baf0db520..508f5e482 100644 --- a/crates/ide-lsp/src/convert.rs +++ b/crates/ide-lsp/src/convert.rs @@ -760,8 +760,7 @@ pub fn inlay_hint(conv: &Conv, path: &Path, h: lsp::InlayHint) -> InlayHint { pub fn decode_semantic_tokens(data: &[u32], enc: Encoding, text: Option<&DocText>) -> Vec { let mut out = Vec::with_capacity(data.len()); let (mut line, mut start) = (0u32, 0u32); - for chunk in data.chunks_exact(5) { - let (dl, ds, len, ty, mods) = (chunk[0], chunk[1], chunk[2], chunk[3], chunk[4]); + for &[dl, ds, len, ty, mods] in data.as_chunks::<5>().0 { if dl == 0 { start = start.saturating_add(ds); } else {