← Rule catalog

Structure · Maintainability

Rust file no mod declaration reaches

rust_doctor::structure::orphan_module_file

Declare the file with a mod declaration, or delete it: Cargo compiles no file the module tree does not reach.

Category
Maintainability
Default level
warn
Tier
P3
Producer
Structure
Diff scope
line

Not a defect when

The file is pulled in by other means, such as include!, a #[path] attribute, a build script, or a test that reads it as fixture data rather than compiling it as a module.

What it reads

Complexity, and families of near-duplicate code.

Tier

Lowest tier: real, and rarely urgent.

The tier bounds how severe a rule may be; its category bounds the tier.

Diff scope

The changed line itself.

What --scope contextual looks at to decide whether a change caused the finding.

Change it

Turn it off, or make it blocking, without touching the code it flags:

rust-doctor --rule rust_doctor::structure::orphan_module_file=off .
rust-doctor --rule rust_doctor::structure::orphan_module_file=error .

Set it once in rust-doctor.toml

Other Maintainability rules