Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

tech(KF-11b): clippy war auf Windows rot — acht Befunde in Code, den der Mac nie kompiliert

David7de9badd833a
diff --git a/src-tauri/src/commands/download.rs b/src-tauri/src/commands/download.rs
index 155a75a2..148c049e 100644
--- a/src-tauri/src/commands/download.rs
+++ b/src-tauri/src/commands/download.rs
@@ -1594,12 +1594,10 @@ pub async fn download_model_to_path(
if let Ok(mut dl) = downloads_arc.lock() {
dl.remove(&id_clone);
}
- } else {
- if let Ok(mut dl) = downloads_arc.lock() {
- if let Some(p) = dl.get_mut(&id_clone) {
- p.status = "error".to_string();
- p.error = Some(e.clone());
- }
+ } else if let Ok(mut dl) = downloads_arc.lock() {
+ if let Some(p) = dl.get_mut(&id_clone) {
+ p.status = "error".to_string();
+ p.error = Some(e.clone());
}
}
}
diff --git a/src-tauri/src/os_paths.rs b/src-tauri/src/os_paths.rs
index 8c42eca9..5f09e14b 100644
--- a/src-tauri/src/os_paths.rs
+++ b/src-tauri/src/os_paths.rs
@@ -236,7 +236,7 @@ fn scan_python_subdirs(base: &std::path::Path) -> Option<PathBuf> {
&& e.file_name().to_string_lossy().to_lowercase().starts_with("python")
})
.collect();
- dirs.sort_by(|a, b| b.file_name().cmp(&a.file_name()));
+ dirs.sort_by_key(|e| std::cmp::Reverse(e.file_name()));
for dir in dirs {
let exe = dir.path().join("python.exe");
if exe.exists() && verify_python_path(&exe.to_string_lossy()) {
@@ -317,6 +317,9 @@ mod python_candidate_tests {
/// 1. Post-bootstrap install (`~/.lmstudio/bin/lms`)
/// 2. Pre-bootstrap (Windows package layout)
/// 3. PATH
+// Its only caller (install/lmstudio.rs) delegates here on everything but
+// Windows; on Windows the function was dead and clippy -D warnings said so.
+#[cfg(not(target_os = "windows"))]
pub fn find_lms_cli() -> Option<PathBuf> {
let ext = if cfg!(target_os = "windows") { ".exe" } else { "" };
let post = home().join(".lmstudio").join("bin").join(format!("lms{ext}"));
diff --git a/src-tauri/src/process_util.rs b/src-tauri/src/process_util.rs
index 4511293e..bf01c3a9 100644
--- a/src-tauri/src/process_util.rs
+++ b/src-tauri/src/process_util.rs
@@ -275,6 +275,10 @@ pub fn kill_pid_tree(pid: u32) {
/// itself (so there's no `Child` handle to kill) — the MLX sidecar and the
/// Ollama server. Only the listener is targeted (`-sTCP:LISTEN`), so the
/// bridge's own client connections to that port aren't hit.
+// Gated like its only caller (state.rs, app quit): on Windows and Linux the
+// function had no caller and a unix-only body, and `-D warnings` on the
+// Windows CI row rejected it as dead. The gate says where it is alive.
+#[cfg(target_os = "macos")]
pub fn kill_listeners_on_port(port: u16) {
#[cfg(unix)]
{
@@ -517,6 +521,9 @@ mod kill_tree_tests {
/// centralised. This test is the shared guard — it fails for either of them.
#[cfg(test)]
mod process_table_tests {
+ // Only the unix test below reads anything from the parent; on Windows the
+ // import was the one thing in this module clippy could see — and rejected.
+ #[cfg(unix)]
use super::*;
#[cfg(unix)]
diff --git a/src-tauri/src/python.rs b/src-tauri/src/python.rs
index 1540f9fd..aad83baf 100644
--- a/src-tauri/src/python.rs
+++ b/src-tauri/src/python.rs
@@ -271,11 +271,11 @@ fn scan_python_subdirs(base: &Path, label: &str) -> Option<String> {
let mut dirs: Vec<_> = entries
.filter_map(|e| e.ok())
.filter(|e| {
- e.file_type().ok().map_or(false, |ft| ft.is_dir())
+ e.file_type().ok().is_some_and(|ft| ft.is_dir())
&& e.file_name().to_string_lossy().to_lowercase().starts_with("python")
})
.collect();
- dirs.sort_by(|a, b| b.file_name().cmp(&a.file_name()));
+ dirs.sort_by_key(|e| std::cmp::Reverse(e.file_name()));
for dir in dirs {
let exe = dir.path().join("python.exe");
if exe.exists() {
diff --git a/src-tauri/src/test_support.rs b/src-tauri/src/test_support.rs
index 09a54de5..332462f7 100644
--- a/src-tauri/src/test_support.rs
+++ b/src-tauri/src/test_support.rs
@@ -329,6 +329,9 @@ pub(crate) fn worker_descendants_of(root: u32) -> Vec<u32> {
/// kernel does not assign a bound port to a second `bind(0)`, so two concurrent
/// copies of a test cannot draw the same number. Keep the listener in scope for
/// as long as the number has to stay yours.
+// The one test that draws a port this way is `#[cfg(unix)]`; on Windows the
+// helper was dead and clippy -D warnings rejected it.
+#[cfg(unix)]
pub(crate) fn reserved_port() -> (u16, std::net::TcpListener) {
let listener = std::net::TcpListener::bind("127.0.0.1:0")
.expect("the loopback interface refused an ephemeral port");