Skip to content

Commit dabf964

Browse files
committed
fix(desktop): silence non-Linux dead_code in linux_media
`PROD_ORIGIN`, `DEV_ORIGIN` and `is_trusted_media_origin` are reachable only from the `cfg(target_os = "linux")` `enable_media_capture` and from the tests, so in the lib target on macOS or Windows `clippy -- -D warnings` fails with three dead_code errors. That breaks `just desktop-tauri-clippy`, and with it the pre-push hook, for anyone developing on a Mac. Upstream's CI runs that lint on Linux only and so never sees it: the file arrived byte-identical from upstream in PR #7 (c9aa555) and has been failing locally ever since. An `allow` and not a `cfg`: the items must stay compiled on every platform because `mod tests` unit-tests the origin check everywhere, which is what the doc comment on `is_trusted_media_origin` explicitly asks for. Gating them to Linux would trade three lint errors for three broken tests. Verified both halves on darwin: Tauri clippy is clean and the three linux_media tests still pass. One module-level attribute rather than three item-level ones, to keep this to a single hunk at the top of the file. The fix belongs upstream in block/buzz. Signed-off-by: adrienlacombe <[email protected]>
1 parent 3ce7c8a commit dabf964

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

‎desktop/src-tauri/src/linux_media.rs‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,24 @@
2121
//! Buzz's AppImage pins `GDK_BACKEND=x11` (see [`crate::webkit_rendering`]),
2222
//! which is the backend WebKitGTK media capture is reliable on.
2323
24+
// FORK-LOCAL PATCH (adrienlacombe/buzz): `PROD_ORIGIN`, `DEV_ORIGIN` and
25+
// `is_trusted_media_origin` are reachable only from the `cfg(target_os = "linux")`
26+
// `enable_media_capture` and from the tests. In the *lib* target on macOS or
27+
// Windows nothing calls them, so `clippy -- -D warnings` fails with three
28+
// dead_code errors — which breaks `just desktop-tauri-clippy`, and with it the
29+
// pre-push hook, for anyone developing on a Mac. Upstream's CI only runs that
30+
// lint on Linux, so it never sees this.
31+
//
32+
// Deliberately an `allow` and not a `cfg`: the items must stay compiled on every
33+
// platform, because `mod tests` below unit-tests the origin check everywhere (see
34+
// the doc comment on `is_trusted_media_origin`). Gating them to Linux would fix
35+
// the lint by breaking those tests on the other two platforms.
36+
//
37+
// One module-level attribute rather than three item-level ones, to keep this to a
38+
// single hunk at the top of the file where an upstream merge is least likely to
39+
// touch it. Belongs upstream in block/buzz; carried here until it lands there.
40+
#![cfg_attr(not(target_os = "linux"), allow(dead_code))]
41+
2442
/// The origin Tauri serves the packaged app from on Linux.
2543
const PROD_ORIGIN: &str = "tauri://localhost";
2644

0 commit comments

Comments
 (0)