Skip to content

[Bug]: Unused/dead-code warnings for all 8 Linux-only symbols in CLI self_update module on Windows builds #2566

Description

@1688mengdie

Summary

The upstream CI logs for main report a cluster of unused/dead-code warnings in the CLI self-update module. Evidence from GitHub Actions run 33035362609 (job "CLI Tests (windows-latest)"; the same entries repeat across runs 33050974141 and 33047041028):

  • warning: unused import: flate2::read::GzDecoder --> src/apps/cli/src/self_update.rs:2:5
  • warning: unused import: std::io::Cursor --> src/apps/cli/src/self_update.rs:8:5
  • warning: unused import: tar::Archive --> src/apps/cli/src/self_update.rs:12:5
  • warning: constant DEPRECATION_WARNING is never used --> src/apps/cli/src/self_update.rs:18:7
  • warning: function find_package_dir is never used --> src/apps/cli/src/self_update.rs:1166:4
  • warning: function validate_entrypoint_pair is never used --> src/apps/cli/src/self_update.rs:1178:4
  • warning: function validate_plugin_host_resources is never used --> src/apps/cli/src/self_update.rs:1201:4
  • warning: function copy_plugin_host_resources is never used --> src/apps/cli/src/self_update.rs:1214:4

The module only performs a real installation on Linux: install_archive (the consumer of all eight symbols) is behind #[cfg(unix)], and a #[cfg(not(unix))] stub twin exists. On non-Unix builds (Windows compiles the whole module) rustc therefore reports all eight symbols as unused/dead.

Root Cause Analysis

  • The eight symbols are declared unconditionally but their only consumers live inside the #[cfg(unix)] install path (install_archive and the validation/upgrade chain reachable only from it).
  • On Windows builds the Unix install path is compiled out, so rustc flags the imports/const as unused imports and the functions as dead code. The warnings are structural, not flaky: the same entries appear in every full CI run of main (runs 33035362609 / 33050974141 / 33047041028 all reproduce them).

Proposed Fix

Gate exactly these eight declarations with #[cfg(unix)] (imports at lines 2/8/12, the DEPRECATION_WARNING const, and the four helper functions), so:

  • Windows/non-Unix builds stop emitting the warnings;
  • the Linux install path is unchanged (all eight symbols stay available exactly where they are consumed).

No #[allow(dead_code)]/#[allow(unused_imports)] suppression is involved; the warnings are eliminated by precise cfg gating.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions