From b3dc48d07e2b67bb086131e7558fd118c396c476 Mon Sep 17 00:00:00 2001 From: Tunglies <77394545+Tunglies@users.noreply.github.com> Date: Thu, 20 Nov 2025 14:59:49 +0800 Subject: [PATCH] fix(tests): suppress clippy expect warnings in enhance function fix(timer): improve task removal logic in add_task method refactor(notification): drop binding after emitting event chore(Cargo): add lints section to Cargo.toml --- src-tauri/Cargo.toml | 3 +++ src-tauri/src/cmd/system.rs | 2 +- src-tauri/src/core/notification.rs | 3 +-- src-tauri/src/core/timer.rs | 3 +-- src-tauri/src/enhance/mod.rs | 1 + 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 319d3b4bb..59ca52eae 100755 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -123,3 +123,6 @@ tauri-plugin-updater = "2.9.0" [dev-dependencies] criterion = { workspace = true } + +[lints] +workspace = true \ No newline at end of file diff --git a/src-tauri/src/cmd/system.rs b/src-tauri/src/cmd/system.rs index 1248cea35..f38886d72 100644 --- a/src-tauri/src/cmd/system.rs +++ b/src-tauri/src/cmd/system.rs @@ -4,7 +4,7 @@ use super::CmdResult; use crate::core::{CoreManager, handle, manager::RunningMode}; use clash_verge_logging::{Type, logging}; use parking_lot::RwLock; -use tauri::Manager; +use tauri::Manager as _; use tauri_plugin_clash_verge_sysinfo::Platform; use tauri_plugin_clipboard_manager::ClipboardExt as _; diff --git a/src-tauri/src/core/notification.rs b/src-tauri/src/core/notification.rs index 7e12a263d..52cac30eb 100644 --- a/src-tauri/src/core/notification.rs +++ b/src-tauri/src/core/notification.rs @@ -102,8 +102,6 @@ impl NotificationSystem { } } - // Clippy 似乎对 parking lot 的 RwLock 有误报,这里禁用相关警告 - #[allow(clippy::significant_drop_tightening)] fn process_event(handle: &super::handle::Handle, event: FrontendEvent) { let binding = handle.notification_system.read(); let system = match binding.as_ref() { @@ -117,6 +115,7 @@ impl NotificationSystem { if let Some(window) = super::handle::Handle::get_window() { system.emit_to_window(&window, event); + drop(binding); thread::sleep(timing::EVENT_EMIT_DELAY); } } diff --git a/src-tauri/src/core/timer.rs b/src-tauri/src/core/timer.rs index c2198518d..9110ebc32 100644 --- a/src-tauri/src/core/timer.rs +++ b/src-tauri/src/core/timer.rs @@ -253,12 +253,11 @@ impl Timer { // Now perform async operations without holding locks let delay_timer = self.delay_timer.write(); - let mut timer_map = self.timer_map.write(); for (uid, tid, interval) in operations_to_add { if let Err(e) = self.add_task(&delay_timer, uid.clone(), tid, interval) { logging_error!(Type::Timer, "Failed to add task for uid {}: {}", uid, e); // Rollback on failure - remove from timer_map - timer_map.remove(&uid); + self.timer_map.write().remove(&uid); } else { logging!(debug, Type::Timer, "Added task {} for uid {}", tid, uid); } diff --git a/src-tauri/src/enhance/mod.rs b/src-tauri/src/enhance/mod.rs index 24f0764a1..eafde1db5 100644 --- a/src-tauri/src/enhance/mod.rs +++ b/src-tauri/src/enhance/mod.rs @@ -692,6 +692,7 @@ pub async fn enhance() -> (Mapping, Vec, HashMap) { (config, exists_keys, result_map) } +#[allow(clippy::expect_used)] #[cfg(test)] mod tests { use super::cleanup_proxy_groups;