Skip to main content

SKY-U009 · Dead code

Unused private Rust enum variant

Low

A private enum in a Cargo binary has a variant with no identifier occurrence outside its declaration. Skylos has resolved a qualified reference to one of its siblings.

Languages
Rust
Turned on by
skylos . --confidence 40
Quality gate
counted toward the gate limits (full and diff scans). A listed variant counts toward max_dead_code, which is unlimited by default.
Finding type
review
Wrong result? Report itA false positive, a missed case or a confusing message: it goes privately to the founder.

Why it matters

An obsolete variant can make a removed application state appear supported. Its discriminant can still affect data layout or persisted values.

What Skylos flags

src/main.rs · RustReported on line 3
enum Mode {    Ready,    Retired,}fn main() { std::hint::black_box(Mode::Ready); }
Cargo.toml · TOML
[package]name = "demo"version = "0.1.0"edition = "2021"

What Skylos leaves alone

src/main.rs · Rust
enum Mode { Ready, Retired }fn main() { std::hint::black_box((Mode::Ready, Mode::Retired)); }

Cargo.toml: same as in the flagged example.

Why Skylos leaves it alone

The tuple constructs both variants.

How Skylos decides

  1. Requires a repository-root scan with every declared Cargo target and module covered. Macros, derives, conditional compilation or missing modules prevent the proof.
  2. Resolves qualified variant paths. Checks only private enums in binary targets with at least one observed sibling. FFI and unsafe code in the candidate crate prevent the check.
  3. Scans Rust identifiers throughout the observed targets. Imports, patterns and same-spelled identifiers keep the candidate. Reports the declaration in unused_variables at the Rust experimental confidence cap of 40.

How to fix it

Remove the variant after verifying that the discriminant values and external format stay compatible.

src/main.rs · Rust · the fix, against the flagged file
Removed: enum Mode {Removed:     Ready,Removed:     Retired,Removed: }Added: enum Mode { Ready }fn main() { std::hint::black_box(Mode::Ready); }

When it can be wrong

  • An identifier with no source references can still document a reserved wire or disk value.

Seeing a case that isn't listed here? Report the wrong result so the rule can be fixed. Don't paste company code: describe the shape of it.

How to silence it

  • Set [tool.skylos] ignore = ["SKY-U009"] to disable the rule project-wide.

From the Skylos rule handbook, Skylos 5.8.0 (commit 5b880b0). All rules.