fix(cross-platform): cfg 掉的 Windows 路径遗留 dead_code 在 -D warnings 下报错
CI 的 setup-rust-toolchain 默认 RUSTFLAGS=-Dwarnings:非 Windows 下 sample_windows/set_topmost_windows 被 cfg 移除后,其专用字段 (Sampler.pid/last_cpu/last_percent)与常量(SWP_*)成为 dead code。 字段加 cfg_attr(not(windows) allow(dead_code)),常量加 cfg 门控。
This commit is contained in:
@@ -47,6 +47,11 @@ fn set_topmost_windows(_window: &gpui_kit::Window, _topmost: bool) -> bool {
|
|||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 仅 Windows 采样路径使用;非 Windows 下该路径被 cfg 移除,常量会成为
|
||||||
|
// dead_code(CI 的 -D warnings 下即错误),按平台放行。
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
const SWP_NOSIZE: u32 = 0x0001;
|
const SWP_NOSIZE: u32 = 0x0001;
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
const SWP_NOMOVE: u32 = 0x0002;
|
const SWP_NOMOVE: u32 = 0x0002;
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
const SWP_NOACTIVATE: u32 = 0x0010;
|
const SWP_NOACTIVATE: u32 = 0x0010;
|
||||||
|
|||||||
@@ -24,6 +24,9 @@ pub struct Sample {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// 周期采样器:内部记录上次 CPU 时间,用于差分计算占用率。
|
/// 周期采样器:内部记录上次 CPU 时间,用于差分计算占用率。
|
||||||
|
// pid/last_cpu/last_percent 仅 Windows 采样路径读写;非 Windows 下该路径被 cfg
|
||||||
|
// 移除,这三个字段会成为 dead_code(CI 的 -D warnings 下即错误),按平台放行。
|
||||||
|
#[cfg_attr(not(target_os = "windows"), allow(dead_code))]
|
||||||
pub struct Sampler {
|
pub struct Sampler {
|
||||||
pid: u32,
|
pid: u32,
|
||||||
last_cpu: Option<(u64, u64, Instant)>,
|
last_cpu: Option<(u64, u64, Instant)>,
|
||||||
|
|||||||
Reference in New Issue
Block a user