Rust edition is current enough
rust/edition-floor@v1
The package declares a Rust edition rather than falling back to the implied 2015 one, and that edition is no older than the configured floor.
| Id | rust/edition-floor |
| Version | v1 |
| Category | rust |
| Default severity | warning |
| Interpreter | python3 |
| Timeout | 30 seconds |
| Violations tolerated | 0 |
| Collects | rust |
Collectors
This guardrail gathers nothing itself. It depends on the collectors below, which the CLI runs once per build before any check, and reads what they found out of GUARDRAIL_FACTS. A collector that collects nothing skips this guardrail rather than failing it.
| 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, passed straight through. Configuring one in buildnote.json changes what is collected, and two guardrails configured the same way share the one collection.
Configuration
{
"guardrails": {
"failOn": "error",
"comment": true,
"checks": [
{
"use": "rust/edition-floor@v1",
"severity": "warning",
"with": {
"projectDir": ".",
"minEdition": "2021"
},
"exemptions": []
}
]
}
}Inputs
| Input | Description | Default | Environment variable |
|---|---|---|---|
projectDir | Directory holding the project, relative to the directory the CLI runs in. | . | GUARDRAIL_INPUT_PROJECTDIR |
minEdition | Oldest Rust edition accepted, as its year. A declared edition below this is a violation. | 2021 | GUARDRAIL_INPUT_MINEDITION |
How to fix
Declare the edition in Cargo.toml and migrate to it:
[package]
name = "widget"
edition = "2021"cargo fix --editionCargo implies the 2015 edition when the key is missing, so the crate compiles under module path resolution, closure capture and bare trait object rules that later editions changed. The compiler's own suggestions then stop matching the code in front of you, and every crate you depend on is being built under different rules than yours.
More in rust
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.rust/version-declared. The build names the Rust toolchain it compiles with, that toolchain is one exact release rather than a moving channel, and it is no older than the configured floor.