fix(clippy): 修复两处预存 clippy 错误

- execute.rs: ExecResult/ExecStatus 仅 server 端使用,加 cfg gate
  消除 WASM 目标的 unused_imports
- system.rs: in_scope 外层闭包保留 || execute_for_editor() 包装
  (Closure::new 要求 Fn 可重复调用,直接传闭包会 use-after-move),
  加 #[allow(clippy::redundant_closure)] 并注释原因

cargo clippy 双目标 -- -D warnings 均通过。
This commit is contained in:
xfy 2026-07-06 11:42:03 +08:00
parent 1db641bca9
commit 9231e993e4
2 changed files with 8 additions and 2 deletions

View File

@ -17,7 +17,10 @@
use dioxus::prelude::*; use dioxus::prelude::*;
// 共享数据类型在函数签名中出现,双目标可见,不 gate。 // 共享数据类型在函数签名中出现,双目标可见,不 gate。
use crate::api::code_runner::{ExecRequest, ExecResult, ExecStatus, ExecTask}; use crate::api::code_runner::{ExecRequest, ExecTask};
// ExecResult/ExecStatus 仅在 server function body被宏剥离到 WASM 之外)内使用。
#[cfg(feature = "server")]
use crate::api::code_runner::{ExecResult, ExecStatus};
// server-only 辅助模块与依赖:仅在 server function body被宏剥离到 WASM 之外)内使用。 // server-only 辅助模块与依赖:仅在 server function body被宏剥离到 WASM 之外)内使用。
#[cfg(feature = "server")] #[cfg(feature = "server")]

View File

@ -772,7 +772,10 @@ fn SqlConsoleTab() -> Element {
let on_ready = Closure::new(|| {}); let on_ready = Closure::new(|| {});
// Ctrl/Cmd+Enter 触发执行(与按钮共用同一套资源/护栏逻辑)。 // Ctrl/Cmd+Enter 触发执行(与按钮共用同一套资源/护栏逻辑)。
// 从 CodeMirror JS 事件触发时无 dioxus scope必须用 in_scope 重建。 // 从 CodeMirror JS 事件触发时无 dioxus scope必须用 in_scope 重建。
// execute_for_editor 是 Fn只捕获 Copy signal借用调用即可。 // 刻意用闭包 `|| execute_for_editor()` 而非直接传 `execute_for_editor`
// 后者会 move 闭包值进 in_scope导致第二次快捷键触发时 use-after-move
// Closure::new 要求 Fn 可重复调用)。闭包包装走借用调用,每次都读最新值。
#[allow(clippy::redundant_closure)]
let on_run_shortcut = Closure::new(move || { let on_run_shortcut = Closure::new(move || {
dioxus::core::Runtime::current() dioxus::core::Runtime::current()
.in_scope(scope_id, || execute_for_editor()); .in_scope(scope_id, || execute_for_editor());