F0006 cfg-4¶
Rule: Every crate is in the tree from one source.
| Code | F0006 (stable, never reused) |
| Id | cfg-4 |
| Category | cfg |
| Source | spirit_level |
| Fix | by hand |
Level per tier¶
| Tier | Level | Reason |
|---|---|---|
| small | off | |
| small-workspace | off | |
| medium | off | |
| big | off | |
| ai | off | |
| embedded | deny |
bedrock error: A crate in the tree twice (git and path copies of WireWeaver, embassy): patch it to one source |
| ui | off | |
| egui | off | |
| units-strict | off | |
| units-paranoid | off |
Why¶
When one dependency (WireWeaver, embassy) is reachable both as a git source and as a [patch]-redirected path source at the same time — because a sibling crate's own Cargo.toml still points at git while the workspace root patches it to the local checkout — Cargo ends up compiling and linking two copies. Types that look identical (ww_indication::Indication, shrink_wrap's traits) become two distinct types to the compiler, and every call between the two copies is a type error.
Example¶
Typec_dongle FW-51: the workspace stopped building on 24 Oct 2026 because bedrock_crash came in through embedded_bedrock's own git dependency (which itself pulled a templated bedrock_template/Cargo.toml), while bedrock_led and bedrock_sync brought WireWeaver a second time from git on top of the workspace's [patch] to the sibling ../wire_weaver checkout — thirteen E0308 type mismatches in ww/leds.rs and ww/clock.rs, all "expected shrink_wrap::X, found shrink_wrap::X" from the two copies. The fix made bedrock_crash a path dependency on ../embedded_bedrock, like the other bedrock crates, and patched fw/donguru/Cargo.toml's WireWeaver source to the same sibling checkout that bedrock_led's own Cargo.toml already asked for.
How to fix¶
Patch every crate in the tree to exactly one source (git xor the sibling path) in the workspace root's [patch], and check every crate that depends on it transitively agrees — a sibling crate's own Cargo.toml dependency line can reintroduce the git copy even with a correct root patch.
How it is checked¶
Check: cfg easy — cargo tree -d (duplicate dependencies) catches this directly; the lint flags any dependency present at two different git/path sources in the resolved tree.
Source¶
Ported from embedded_bedrock's firmware check catalogue, CFG-4 (book/checks.md, detail in book/checks/cfg.md). Found on: typec_dongle FW-51.
Configure¶
Allow one finding in the code with // spirit-level: allow(cfg-4) <reason> (waivers); the code works there too, as in [lints.F0006].