fix(desktop): scope webview builder mutability - #2583
Open
1688mengdie wants to merge 1 commit into
Open
Conversation
The browser_webview_create helper declared its WebviewBuilder as mut unconditionally, but the only mutating call (enabling devtools) is compiled solely under #[cfg(any(debug_assertions, feature = "devtools"))]. In release builds without the devtools feature the mut requirement disappears and the compiler flags the binding as unused_mut. Move the mutation into the cfg block by shadowing: the outer binding is immutable, and the devtools block rebinds a local mut copy, applies the devtools flag, and returns it. Builder construction and the final add_child consumer are unchanged, so behavior is identical on every build configuration while the mutability now exactly matches the consumer surface. Test: cargo check --release -p bitfun-desktop --jobs 4 (browser_api unused_mut gone; lib compiles 0 warnings) Test: cargo check -p bitfun-desktop (dev profile, cfg block active, 0 errors 0 warnings) AI: This commit was authored with AI assistance; checks were run locally on Windows (release + dev profiles) and non-Windows compilation surfaces are to be confirmed by the upstream multi-OS CI matrix.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
browser_webview_createdeclares itsWebviewBuilderasmutunconditionally, but the only mutating call (builder.devtools(true)) is compiled solely under#[cfg(any(debug_assertions, feature = "devtools"))]. In release builds without the devtools feature the mutation is compiled out and the compiler flags the binding asunused_mut. This PR moves the mutation into the cfg block by shadowing: the outer binding becomes immutable, and the devtools block rebinds a localmutcopy, applies the flag, and returns it.Fixes #2581
Type and Areas
Type: Bug fix
Areas: Rust core (desktop, built-in browser API)
Motivation / Impact
Release-mode builds of the desktop crate currently emit an
unused_mutwarning from the browser webview creation path, which pollutes build output for anyone building without dev tooling. After this change the mutability exactly matches the consumer surface on every build configuration; builder construction and the finaladd_childconsumer are unchanged, so behavior is identical everywhere. No direct user-facing change beyond cleaner build output.Verification
cargo check --release -p bitfun-desktop --jobs 4on Windows: 0 errors, 0 warnings; thebrowser_api.rs:145unused_mutwarning present on main is gone.cargo check -p bitfun-desktop --jobs 4(dev profile, cfg block active): 0 errors, 0 warnings.AI-assisted change, lightly tested.
Reviewer Notes
let mutrebind inside the cfg block) is deliberate: it removes the mut requirement from the release/devtools-less compilation unit without changing any builder call or theadd_childconsumer.browser_api.rscontains no tests, and the diff touches no assertions.Checklist