Skip to content

fix(stylo_taffy): macro no-tracing arm consumes args to silence unused_variables#6

Merged
nixpt merged 1 commit into
mainfrom
feat/stylo-taffy-macro-arg-consume
May 18, 2026
Merged

fix(stylo_taffy): macro no-tracing arm consumes args to silence unused_variables#6
nixpt merged 1 commit into
mainfrom
feat/stylo-taffy-macro-arg-consume

Conversation

@nixpt
Copy link
Copy Markdown
Owner

@nixpt nixpt commented May 18, 2026

Summary

The log_fallback!() macro in convert.rs has a #[cfg(not(feature = "tracing"))] arm that expands to empty {}. Empty expansion leaves caller bindings unconsumed, producing a unused_variables warning at every match-arm call site. Fix: the no-tracing arm now does let _ = (&$value, &$to); which consumes the args at the call site (zero runtime cost, just a binding consumption).

PR-D of 4 in the s190 cascade arc. Backport of the same fix from DioxusLabs/blitz#443 (upstream-of-upstream — same macro, same problem, same fix).

Changes

packages/stylo_taffy/src/convert.rs:75-78:

 #[cfg(not(feature = "tracing"))]
 macro_rules! log_fallback {
-    ($value:expr, $to:expr) => {};
+    ($value:expr, $to:expr) => {
+        let _ = (&$value, &$to);
+    };
 }

Net delta: 3 LOC.

Why

The warning surfaces on every match-arm call site like:

unsupported => {
    log_fallback!(&format!("display:{:?}", unsupported), "DEFAULT");
    taffy::Display::DEFAULT
}

The unsupported binding gets bound by the match pattern, then passed to the macro. The compiler can't see through macro expansion — from its perspective the macro expanded to {} and unsupported was never used. Result: warning: unused variable: unsupported at compile time in no-tracing builds (which is the default).

The fix is the canonical "macro arm that wants to consume args without emitting runtime code": bind both args to _. The & prevents move-out so the caller's bindings stay usable downstream (currently not needed but cheap insurance).

Test plan

  • CARGO_TARGET_DIR=/build/target-foreman-bliss-main-merge cargo check -p stylo_taffy → clean. The previously-warned packages/stylo_taffy/src/convert.rs:260:9 unused_variables warning is gone.
  • No behavioural change — the no-tracing arm still produces zero runtime code (let _ = (&_, &_) is a no-op after dead-code elimination).
  • Tracing arm untouched.

Downstream context

This is the same warning DioxusLabs#443 fixes upstream-of-upstream. Bliss-engine carries its own stylo_taffy fork (PR #1 landed the panic-elimination + tracing-feature work), so it doesn't auto-inherit the upstream fix. Backporting it here keeps bliss-engine no-tracing builds warning-clean and aligns the macro shape with blitz.

Generated with Claude Code

…d_variables

The `log_fallback!()` macro has two arms — one for `feature = "tracing"`
that calls `tracing::debug!()` (which consumes both args), one for the
no-tracing build that was an empty `{}`. The empty arm leaves the
caller's bindings unused, producing a `unused_variables` warning at
call sites like:

    unsupported => {
        log_fallback!(&format!("display:{:?}", unsupported), "DEFAULT");
        taffy::Display::DEFAULT
    }

The `unsupported` binding becomes unused in no-tracing builds, even
though it IS used in the macro call (semantically). Compiler can't see
through the macro expansion to know that.

Fix: change the no-tracing arm to `let _ = (&$value, &$to);` which
consumes both args at the call site without emitting any code at
runtime. The `&` ensures we don't move out of the caller's bindings.

Backport of the same fix from DioxusLabs#443 (the upstream of
upstream — same macro, same problem, same fix). PR-D of 4 in the s190
cascade arc.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@nixpt nixpt merged commit f412286 into main May 18, 2026
10 of 16 checks passed
@nixpt nixpt deleted the feat/stylo-taffy-macro-arg-consume branch May 18, 2026 06:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant