windows: Remove `allow(deadcode)` (#29651)

张小白 created

Release Notes:

- N/A

Change summary

crates/gpui/src/platform.rs                      | 15 ++++++++++-----
crates/gpui/src/platform/blade/blade_renderer.rs |  5 ++++-
crates/gpui/src/platform/windows/direct_write.rs |  4 +---
crates/gpui/src/platform/windows/display.rs      | 15 ---------------
4 files changed, 15 insertions(+), 24 deletions(-)

Detailed changes

crates/gpui/src/platform.rs 🔗

@@ -1,6 +1,3 @@
-// todo(windows): remove
-#![cfg_attr(windows, allow(dead_code))]
-
 mod app_menu;
 mod keystroke;
 
@@ -802,6 +799,7 @@ impl PlatformInputHandler {
             .flatten()
     }
 
+    #[cfg_attr(target_os = "windows", allow(dead_code))]
     fn marked_text_range(&mut self) -> Option<Range<usize>> {
         self.cx
             .update(|window, cx| self.handler.marked_text_range(window, cx))
@@ -809,7 +807,10 @@ impl PlatformInputHandler {
             .flatten()
     }
 
-    #[cfg_attr(any(target_os = "linux", target_os = "freebsd"), allow(dead_code))]
+    #[cfg_attr(
+        any(target_os = "linux", target_os = "freebsd", target_os = "windows"),
+        allow(dead_code)
+    )]
     fn text_for_range(
         &mut self,
         range_utf16: Range<usize>,
@@ -852,6 +853,7 @@ impl PlatformInputHandler {
             .ok();
     }
 
+    #[cfg_attr(target_os = "windows", allow(dead_code))]
     fn unmark_text(&mut self) {
         self.cx
             .update(|window, cx| self.handler.unmark_text(window, cx))
@@ -1069,7 +1071,10 @@ pub(crate) struct WindowParams {
     #[cfg_attr(any(target_os = "linux", target_os = "freebsd"), allow(dead_code))]
     pub is_movable: bool,
 
-    #[cfg_attr(any(target_os = "linux", target_os = "freebsd"), allow(dead_code))]
+    #[cfg_attr(
+        any(target_os = "linux", target_os = "freebsd", target_os = "windows"),
+        allow(dead_code)
+    )]
     pub focus: bool,
 
     #[cfg_attr(any(target_os = "linux", target_os = "freebsd"), allow(dead_code))]

crates/gpui/src/platform/blade/blade_renderer.rs 🔗

@@ -453,7 +453,10 @@ impl BladeRenderer {
         }
     }
 
-    #[cfg_attr(any(target_os = "macos", feature = "wayland"), allow(dead_code))]
+    #[cfg_attr(
+        any(target_os = "macos", feature = "wayland", target_os = "windows"),
+        allow(dead_code)
+    )]
     pub fn viewport_size(&self) -> gpu::Extent {
         self.surface_config.size
     }

crates/gpui/src/platform/windows/direct_write.rs 🔗

@@ -33,7 +33,6 @@ struct FontInfo {
     features: IDWriteTypography,
     fallbacks: Option<IDWriteFontFallback>,
     is_system_font: bool,
-    is_emoji: bool,
 }
 
 pub(crate) struct DirectWriteTextSystem(RwLock<DirectWriteState>);
@@ -375,7 +374,6 @@ impl DirectWriteState {
             let Some(identifier) = get_font_identifier(&font_face, &self.components.locale) else {
                 continue;
             };
-            let is_emoji = unsafe { font_face.IsColorFont().as_bool() };
             let Some(direct_write_features) =
                 (unsafe { self.generate_font_features(font_features).log_err() })
             else {
@@ -389,7 +387,6 @@ impl DirectWriteState {
                 features: direct_write_features,
                 fallbacks,
                 is_system_font,
-                is_emoji,
             };
             let font_id = FontId(self.fonts.len());
             self.fonts.push(font_info);
@@ -1174,6 +1171,7 @@ impl<'a> StringIndexConverter<'a> {
         }
     }
 
+    #[allow(dead_code)]
     fn advance_to_utf8_ix(&mut self, utf8_target: usize) {
         for (ix, c) in self.text[self.utf8_ix..].char_indices() {
             if self.utf8_ix + ix >= utf8_target {

crates/gpui/src/platform/windows/display.rs 🔗

@@ -172,21 +172,6 @@ impl WindowsDisplay {
             .collect()
     }
 
-    pub(crate) fn frequency(&self) -> Option<u32> {
-        get_monitor_info(self.handle).ok().and_then(|info| {
-            let mut devmode = DEVMODEW::default();
-            unsafe {
-                EnumDisplaySettingsW(
-                    PCWSTR(info.szDevice.as_ptr()),
-                    ENUM_CURRENT_SETTINGS,
-                    &mut devmode,
-                )
-            }
-            .as_bool()
-            .then(|| devmode.dmDisplayFrequency)
-        })
-    }
-
     /// Check if this monitor is still online
     pub fn is_connected(hmonitor: HMONITOR) -> bool {
         available_monitors().iter().contains(&hmonitor)