chore: silence platform-conditional dead-code warnings#10425
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (7)
🚧 Files skipped from review as they are similar to previous changes (6)
📝 WalkthroughWalkthroughAdds ChangesPlatform cfg gating
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
Greptile SummaryThis PR adds platform-conditional
Confidence Score: 5/5Safe to merge — purely additive cfg gates with no logic changes and verified call-site coverage on every target. Every change is a mechanical cfg annotation that exactly mirrors the platform scope of the item's only call sites. The No files require special attention. Important Files Changed
Reviews (2): Last reviewed commit: "chore: gate platform-conditional code to..." | Re-trigger Greptile |
| Warning, | ||
| // Constructed only by the brew package managers (`#[cfg(unix)]`), so it reads | ||
| // as never-constructed on non-unix builds. | ||
| #[cfg_attr(not(unix), allow(dead_code))] |
There was a problem hiding this comment.
i think it probably should be windows instead of not(unix)
There was a problem hiding this comment.
Good call — switched to #[cfg_attr(windows, allow(dead_code))]. mise's only non-unix target is windows, so this is equivalent here but more explicit about where the variant goes unconstructed. Updated in 42d34e6.
|
if you don't verify this in ci it's just going to break again |
Building the `mise` binary on Windows (and one item on macOS) surfaced several dead_code / unused-import warnings from unix/linux-only helpers, a test-only enum construction, and a redundant trait import. Gate each item to the platform(s) that actually use it so the default `cargo check`/`cargo build` is warning-free on every target. - src/system/launchd.rs: cfg(unix) on current_uid_from + its test - src/ui/progress_report.rs: allow(dead_code) on ProgressIcon::Error for non-unix (matched everywhere, but constructed only by the unix brew package managers) - src/oci/layer.rs: cfg(unix) on the assert_layer_mode / assert_layer_entry_owner test helpers - src/plugins/core/erlang.rs: cfg(linux) on linux_precompiled_cache_name (also clears a pre-existing macOS dead_code warning) - src/config/config_file/mise_toml.rs: cfg(unix) on update_bootstrap_brew_tap / remove_bootstrap_brew_tap - src/backend/pkgx.rs: cfg(any(unix, test)) on shell_quote (used by the unix wrapper writer and by a non-gated unit test) - src/cmd.rs: drop the redundant CommandExt import (tokio's Command::raw_arg is an inherent method) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
fa3ccf1 to
42d34e6
Compare
Summary
Building the
misebinary on Windows surfaced a handful ofdead_code/unused_importwarnings (one was also firing on macOS) coming from code that is only ever used on a subset of platforms. This PR gates each item to the platform(s) that actually use it, so the defaultcargo check/cargo buildis warning-free on every target.No behavior change — every item is still compiled on the platform that uses it; only the copies that are unused on a given target are removed.
Changes
src/system/launchd.rs#[cfg(unix)]oncurrent_uid_from+ its test#[cfg(unix)]current_uid()(Windows uses acfg(not(unix))fallback that returns 0)src/ui/progress_report.rs#[cfg_attr(not(unix), allow(dead_code))]onProgressIcon::ErrorDisplay/finish_with_iconon all platforms, so it cannot be cfg-gated away, but it is only constructed by the#[cfg(unix)]brew package managerssrc/oci/layer.rs#[cfg(unix)]onassert_layer_mode/assert_layer_entry_owner#[cfg(unix)]permission-bit testssrc/plugins/core/erlang.rs#[cfg(linux)]onlinux_precompiled_cache_name#[cfg(linux)]install_precompiled(also clears a pre-existing macOS warning, since the caller was already linux-gated)src/config/config_file/mise_toml.rs#[cfg(unix)]onupdate_bootstrap_brew_tap/remove_bootstrap_brew_tap#[cfg(unix)]mise system brew tap/untapCLIsrc/backend/pkgx.rs#[cfg(any(unix, test))]onshell_quote#[cfg(unix)]wrapper writer and by a non-gated unit test (sotestis needed for the Windows test build)src/cmd.rsuse std::os::windows::process::CommandExtself.cmdis atokio::process::Command, whoseraw_argis an inherent method, so the trait import is unnecessary (hooks.rs/path.rskeep theirs because they usestd::process::Command)Verification
cargo fmt --all -- --check✅cargo check --all-targetson Windows (msvc): 0 warnings, 0 errors (previously 8 warnings) ✅🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
Bug Fixes
Chores
Documentation