Skip to content

The IDE you know, rebuilt in Rust. IntelliJ IDEA–style keymap, tool windows and search-everywhere in a fast native app: editor, code insight, debugger, Git, terminal, database and HTTP clients for 60+ languages.

fix: Satisfy clippy 1.99 lints

l0ng-ai3110de880388
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<RawMessage> {
fn kotlin_line(line: &str) -> Option<RawMessage> {
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<RawMessage> {
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<RawMessage> {
fn maven_line(line: &str) -> Option<RawMessage> {
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<RawMessage> {
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<UnknownHostKey>),
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<u32> {
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 {