Expand description
Strict-mode lint preset for Trust.
Each lint is a visitor over the parsed Rust AST that emits a teaching
diagnostic for a specific footgun. Activated by #![strict] at the
crate root; individual lints can be silenced with #[allow(...)] if
accompanied by a // reason: justification comment.
Intentionally not #![strict]-marked: this file’s #[cfg(test)] block
has 45+ positional helper calls (fires(Rule::X, src), diags_for(...))
that R0042 correctly flags but mass-rewriting hits >100-LOC stop cond
for RT-31. runner.rs / rules.rs are strict-marked.
Re-exports§
pub use config::TrustConfig;
Modules§
- config
- Project configuration (RT-102/RT-113): a
trust.tomlthat selects the rule set and lists project-wide suppressions/relaxations, so adopters don’t sprinkle inline#[allow(trust::Rxxxx)]across every call site. The first external adopter would have needed 162 inline allows for one rule alone; this is the coarse, one-place sibling of that.
Structs§
Enums§
Functions§
- advisory_
rules - The advisory lint set (RT-101): every rule that applies to plain Rust,
with the named-argument dialect rules (R0042) removed. Run these with
lint_advisoryto use Trust as an out-of-tree linter on a stock cargo workspace — no#![strict]marker, no named-arg syntax, no lowering — so the bug-catching rules (.unwrap(),as-casts, bare indexing, dropped error context, …) surface as a plain-Rust cleanup backlog. - all_
rules - Returns the full Trust strict-mode lint set.
- bug_
rules - The bug-catching subset (RT-101): rules that flag a genuine runtime
correctness bug — panics, silent truncation, dropped errors, deadlocks —
and nothing stylistic.
trust check --rules bugsruns exactly this set: the highest-signal advisory backlog for a stock-Rust codebase. A strict subset ofadvisory_rules; none require the dialect. - lint
- Run every rule against
file, auto-detecting strict mode from the file’s inner attributes.sourceis the original source text, used by individual rules to extract justification comments and to produceariadnespans. - lint_
advisory - Run
rulesagainstfileas an advisory pass (RT-101): lints fire regardless of whether the file carries a#![strict]marker. This is how Trust runs as a plain-Rust linter on a stock cargo workspace (trust check --rules safety), where the source has no marker and must stay valid stock Rust. Pass a dialect-free subset (seecrate::advisory_rules); R0042 is a no-op in the runner regardless — it is emitted only during lowering. - lint_
strict - Like
lintbut with an explicit strict-mode flag. Use this when the driver has already detected#![strict]at the token level (e.g. before the attribute was stripped during lowering). - lint_
with - Run only the given subset of rules. Useful for tests and for crates that opt into stricter-than-default subsets.