F0015 cnt-3¶
Rule: A proc-macro crate and its runtime crate are pinned to the same exact version.
| Code | F0015 (stable, never reused) |
| Id | cnt-3 |
| Category | cnt |
| Source | spirit_level |
| Fix | by hand |
Level per tier¶
| Tier | Level | Reason |
|---|---|---|
| small | off | |
| small-workspace | off | |
| medium | off | |
| big | off | |
| ai | off | |
| embedded | warn |
bedrock warning: Proc-macro crate and its runtime crate not pinned to the exact same version (=x.y.z) |
| ui | off | |
| egui | off | |
| units-strict | off | |
| units-paranoid | off |
Why¶
cnt's proc-macro crate and its runtime crate present at different versions (a ^ or ~ range instead of an exact =x.y.z pin keeping them locked together).
The macro generates code that calls into the runtime's own layout and ABI for a given version; if Cargo's resolver picks different versions for the two (easy to happen across a workspace with several dependents), the generated code and the runtime it calls into can silently disagree about the counter buffer's layout.
Example¶
Noted directly in cnt's own documentation as the reason both crates are versioned and released together rather than independently.
How to fix¶
Pin both crates with =x.y.z to the same version everywhere they're depended on; bump them together, never independently.
How it is checked¶
cfg easy: both cnt and cnt-macros (or however the pair is split) must be pinned to the exact same version with =x.y.z in every Cargo.toml that depends on them.
Source¶
Ported from embedded_bedrock's firmware check catalogue, CNT-3 (book/checks.md, detail in book/checks/cnt.md). Found on: cnt.
Configure¶
Allow one finding in the code with // spirit-level: allow(cnt-3) <reason> (waivers); the code works there too, as in [lints.F0015].