diff --git a/gpui-app/src/platform.rs b/gpui-app/src/platform.rs index 8788b08..1556d62 100644 --- a/gpui-app/src/platform.rs +++ b/gpui-app/src/platform.rs @@ -2,10 +2,17 @@ /// 窗口置顶 / 取消置顶。返回是否成功(非 Windows 或句柄不可得为 false)。 pub fn set_topmost(window: &gpui_kit::Window, topmost: bool) -> bool { - if !cfg!(target_os = "windows") { - return false; + // 属性 cfg 分派而非 cfg!() 运行时判断:非 Windows 下 set_topmost_windows + // 被 cfg 移除,cfg! 分支仍参与编译会报方法不存在(CI Test job 实测暴露) + #[cfg(target_os = "windows")] + { + set_topmost_windows(window, topmost) + } + #[cfg(not(target_os = "windows"))] + { + let _ = (window, topmost); + false } - set_topmost_windows(window, topmost) } #[cfg(target_os = "windows")] diff --git a/gpui-app/src/sysmon.rs b/gpui-app/src/sysmon.rs index 2edc9f1..956f4c1 100644 --- a/gpui-app/src/sysmon.rs +++ b/gpui-app/src/sysmon.rs @@ -42,10 +42,16 @@ impl Sampler { /// 采样一次;CPU 占用首次采样为 0(无差分基准)。 pub fn sample(&mut self) -> Option { - if !cfg!(target_os = "windows") { - return Some(Sample::default()); + // 属性 cfg 分派而非 cfg!() 运行时判断:非 Windows 下 sample_windows + // 被 cfg 移除,cfg! 分支仍参与编译会报方法不存在(CI Test job 实测暴露) + #[cfg(target_os = "windows")] + { + self.sample_windows() + } + #[cfg(not(target_os = "windows"))] + { + Some(Sample::default()) } - self.sample_windows() } #[cfg(target_os = "windows")]