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
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
enum Mode { Ready, Retired,}fn main() { std::hint::black_box(Mode::Ready); }[package]name = "demo"version = "0.1.0"edition = "2021"What Skylos leaves alone
enum Mode { Ready, Retired }fn main() { std::hint::black_box((Mode::Ready, Mode::Retired)); }Why Skylos leaves it alone
The tuple constructs both variants.
How Skylos decides
- Requires a repository-root scan with every declared Cargo target and module covered. Macros, derives, conditional compilation or missing modules prevent the proof.
- 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.
- 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.
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.