Rust version is declared
rust/version-declared@v1
The build names the Rust toolchain it compiles with. The toolchain is an exact release, not a moving channel, and it is no older than the configured floor.
| Id | rust/version-declared |
| Version | v1 |
| Category | rust |
| Default severity | warning |
| Interpreter | python3 |
| Timeout | 30 seconds |
| Violations tolerated | 0 |
| Collects | rust |
Collectors
This guardrail doesn't gather anything itself. It relies on the collectors below, which the CLI runs once per build before any check, and reads what they found from GUARDRAIL_FACTS. If a collector collects nothing, this guardrail is skipped, not failed.
| Collector | Gathers | Inputs it is given |
|---|---|---|
rust | The Cargo build in the project directory: the crate it declares, the Rust version and edition it asks for, every workspace member, the dependencies each manifest names with where each comes from and whether it is pinned, and the lock file beside them. | projectDir |
The inputs above are this guardrail's own inputs, passed straight through to the collector. Setting one in buildnote.json changes what is collected, and two guardrails configured the same way share a single collection.
Configuration
{
"guardrails": {
"failOn": "error",
"checks": [
{
"use": "rust/version-declared@v1",
"severity": "warning",
"with": {
"projectDir": ".",
"minVersion": "1.70"
},
"exemptions": []
}
]
}
}Inputs
| Input | Description | Default | Environment variable |
|---|---|---|---|
projectDir | Directory holding the project, relative to the directory the CLI runs in. | . | GUARDRAIL_INPUT_PROJECTDIR |
minVersion | Oldest Rust version accepted. A declared version below this is a violation. | 1.70 | GUARDRAIL_INPUT_MINVERSION |
How to fix
Name the toolchain where cargo reads it, in a rust-toolchain.toml next to the manifest:
[toolchain]
channel = "1.76.0"
components = ["clippy", "rustfmt"]A published crate can also add rust-version = "1.76" under [package]. That sets the minimum version the crate compiles with, not the toolchain it is built with. With neither, the compiler is whichever release the runner already has. stable doesn't count, because it moves: a stricter lint or a newly stabilised feature can change the result when you rerun the same commit.
More in rust
rust/edition-floor. The package declares a Rust edition instead of falling back to the implied 2015 edition, and that edition is no older than the configured floor.rust/lockfile-committed. The build commitsCargo.lock, so a rebuild of the same commit resolves the same crate versions.rust/no-git-dependencies. No manifest declares a dependency with agitsource, so every crate in the build comes from a registry that versions it.