From 956963e9d9911807144380567e68638c3c1e22fb Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Mon, 12 Oct 2026 05:36:02 -0400 Subject: [PATCH] ui-egui: fix Windows clippy in desktop_theme (#872) Bus is a unit struct off Linux, so Bus::default() tripped clippy::default_constructed_unit_structs on Windows and macOS. Each platform's Bus now has a plain constructor. Co-authored-by: Claude Opus 5.5 --- crates/ui-egui/src/desktop_theme.rs | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/crates/ui-egui/src/desktop_theme.rs b/crates/ui-egui/src/desktop_theme.rs index 7f9ed41..b49bbbc 100644 --- a/crates/ui-egui/src/desktop_theme.rs +++ b/crates/ui-egui/src/desktop_theme.rs @@ -16,7 +16,7 @@ const POLL: Duration = Duration::from_secs(4); /// there is no session bus or no portal to ask (a bare X server, a container), so the caller /// keeps whatever it chose itself. pub fn prefers_dark() -> Option { - read(&mut Bus::default()) + read(&mut Bus::new()) } /// Watches the desktop and reports its choice when it changes. [`prefers_dark`] covers the @@ -38,7 +38,7 @@ impl DesktopTheme { let started = std::thread::Builder::new().name("wordcraft-desktop-theme".into()).spawn(move || { // One session-bus connection for the life of the watcher, opened again only after // it fails. - let mut bus = Bus::default(); + let mut bus = Bus::new(); let mut last = read(&mut bus); if tx.send(last).is_err() { return; @@ -81,13 +81,27 @@ impl DesktopTheme { /// The watcher's session-bus connection, kept between polls. #[cfg(target_os = "linux")] -#[derive(Default)] struct Bus(Option); +#[cfg(target_os = "linux")] +impl Bus { + /// No connection yet: the first read opens one. + fn new() -> Self { + Bus(None) + } +} + +/// Elsewhere there is no session bus to keep. #[cfg(not(target_os = "linux"))] -#[derive(Default)] struct Bus; +#[cfg(not(target_os = "linux"))] +impl Bus { + fn new() -> Self { + Bus + } +} + /// Ask the portal once, over `bus`'s connection (opened when there is none). D-Bus calls /// block, so this belongs off the UI thread. A connection whose calls all fail is dropped, so /// the next poll opens a fresh one (the bus or portal may have restarted).