Skip to main content

Crate trust_lints

Crate trust_lints 

Source
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.toml that 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§

Diagnostic
LintReport

Enums§

Rule

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_advisory to 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 bugs runs exactly this set: the highest-signal advisory backlog for a stock-Rust codebase. A strict subset of advisory_rules; none require the dialect.
lint
Run every rule against file, auto-detecting strict mode from the file’s inner attributes. source is the original source text, used by individual rules to extract justification comments and to produce ariadne spans.
lint_advisory
Run rules against file as 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 (see crate::advisory_rules); R0042 is a no-op in the runner regardless — it is emitted only during lowering.
lint_strict
Like lint but 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.