Skip to content

M0020 crate-dir-name

Rule: A member's directory is named after its crate.

Code M0020 (stable, never reused)
Id crate-dir-name
Category workspace
Source spirit_level
Fix by hand

Level per tier

Tier Level Reason
small off
small-workspace warn flat crates/: the folder is the crate
medium warn flat crates/: the folder is the crate
big warn flat crates/: the folder is the crate
ai off
embedded off
ui off
egui off
units-strict off
units-paranoid off

Why

The crate's own folder is the crate: search, completion and the crate table all assume the two names agree (matklad's rule for large workspaces). It holds at every depth: a flat crates/<crate>, a layer folder crates/<layer>/<crate> and a discipline folder crates/<layer>/<discipline>/<crate>. Which of those a crate sits in is crate-folder-layer's check.

How to fix

Rename the directory (and its members entry) to the package name.

Configure

[lints.crate-dir-name]
level = "deny"
reason = "why this project wants it at this level"

Allow one finding in the code with // spirit-level: allow(crate-dir-name) <reason> (waivers); the code works there too, as in [lints.M0020].