Desktop theme: the watcher's link has a type off Linux, so the gate passes there

`cargo xtask ci` has not passed on macOS or Windows since cc21643:

  error: this let-binding has unit value
    --> crates/ui-egui/src/desktop_theme.rs:36:13
  36 |             let mut link = Link::default();

`Link` is the session-bus connection the watcher keeps between reads. Off Linux
there is no bus to keep, so it was aliased to `()`, which makes that binding a
unit binding: `clippy::let_unit_value` reports it and the gate's `-D warnings`
turns it into an error. CI runs Linux only, where `Link` is a real
`Option<Connection>`, so nothing catches it there.

Off Linux `Link` is now a unit struct rather than `()`. The binding has a type,
the lint does not apply, and nothing else changes: `read` still ignores it on
those platforms. An `allow` on the line would also work, but a named type says
what the thing is rather than silencing a lint that only fires on some
platforms.
This commit is contained in:
Hamza
2026-10-19 22:41:20 +05:00
parent 49fe41afbf
commit 3979e48f89
+7 -2
View File
@@ -67,11 +67,16 @@ impl DesktopTheme {
}
}
/// The session-bus connection the watcher keeps between reads, opened on first use.
/// The session-bus connection the watcher keeps between reads, opened on first use. Off Linux
/// there is no bus to keep, and a unit struct rather than `()` keeps `let mut link = …` from
/// reading as a unit binding, which `cargo xtask ci` refuses on those platforms.
#[cfg(target_os = "linux")]
type Link = Option<zbus::blocking::Connection>;
#[cfg(not(target_os = "linux"))]
type Link = ();
#[derive(Default)]
pub(crate) struct NoLink;
#[cfg(not(target_os = "linux"))]
type Link = NoLink;
/// Ask the portal once, over `link`'s connection (opened if absent, dropped if the bus went
/// away). D-Bus calls block, so this belongs off the UI thread: the watcher's thread is its