Repository navigation
fix: drop the unused WebView2 controller import - #1399
Merged
Merged
Conversation
history_step_platform calls webview.controller(), which already yields the controller type, so the explicit ICoreWebView2Controller import was dead. Removing it clears the Windows-only unused_imports warning without touching the navigation path.
jakero
marked this pull request as ready for review
September 26, 2026 14:00
Owner
|
@jakero Thanks for the cleanup. It is merged and included in pake-cli 3.17.3, with no change to how the Windows WebView is configured. |
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
A Windows build reports an
unused_importswarning insrc-tauri/src/app/navigation.rs. The import was never needed, so this removes it. No functional change.#[cfg(windows)] fn history_step_platform(webview: &tauri::webview::PlatformWebview, back: bool) { - use webview2_com::Microsoft::Web::WebView2::Win32::ICoreWebView2Controller; - let controller = webview.controller();Why the warning appeared
Two things overlap.
1. The import was unused from the start
git log -S ICoreWebView2Controller -- src-tauri/src/app/navigation.rsreturns exactly two commits:476a0a6(2026-08-02), which added the line along with the file, and this PR, which removes it. Nothing in between touched the line, so this is not a refactoring regression. The warning existed when the line was written.The likely reasoning was that calling
CoreWebView2()requires the type to be in scope. That is not the case here. See the verification below.2. CI structurally cannot catch this warning
history_step_platformis#[cfg(windows)]. TheRust Code Qualityjob inquality-and-test.ymlruns onubuntu-latest, so it never compiles this block and the warning never reaches a CI log.cargo hack ... clippywithout-D warnings, so even when compiled, a lint warning does not fail the build.Why the import is not needed
The type is returned by value. In wry 0.54.2,
PlatformWebview::controller()hands back anICoreWebView2Controllerby value (wry-0.54.2/src/lib.rs:2236for the trait signature,:2270for the impl):So
let controller = webview.controller();already binds a value of that concrete type. Rust only needs an import when the type has to be named in source. This function callsCoreWebView2()as a method on a value and never writes the type as a path expression (ICoreWebView2Controller::…), so the name does not need to be in scope.CoreWebView2is an inherent method generated by#[interface], which means no trait import is required either.Reproduced in both directions
warning: unused_importsat66:9, identical to the log aboveCompiling pake v3.17.2, zero warningsCompiles and links. With the import gone,
cargo build --libproduces the Windows native artifacts:app_lib.lib(staticlib),app_lib.dll(cdylib), andlibapp_lib.rlib. The#[cfg(windows)]path survives both codegen and linking, which confirms the COM symbols and the inherent method resolve correctly here.Repository-wide check. After the removal, the only remaining occurrence of
ICoreWebView2Controllerundersrc-tauri/srcis a single comment atnavigation.rs:68; no code references it. No code referenceswebview2_comby name either.Not in scope here
The direct
webview2-com = "0.38"dependency inCargo.tomlis left alone. The GoBack/GoForward path still relies on that crate's COM implementation, so whether the direct dependency is still required is a separate decision. This PR only claims the import is unnecessary, not that the crate is.Verification
No diff in the build-state files (
src-tauri/pake.json,src-tauri/tauri.conf.json,src-tauri/tauri.macos.conf.json,src-tauri/icons/,src-tauri/png/).Risk
Low. This deletes one import line inside a single
#[cfg(windows)]function, and the rest of the function body is byte-identical, including theunsafeblock and thelet Ok(core) = … elseform. TheCoreWebView2(),GoBack(), andGoForward()call sites are untouched and the crate links. The macOS and Linux paths do not compile this function and are unaffected.