Expand description
Rust unit-isolation lint (#44): an inline #[cfg(test)] mod may call only into
the unit under test — its parent module, reached via super::. A call out of
the test’s own module — into another first-party module (crate::…), an
external crate, or effectful std — is a violation. Inject a trait double
(hand-rolled or mockall) instead; the compiler checks the double.
Detection is AST-based: each *.rs file under the crate root is parsed with
syn and its #[cfg(test)] modules are walked with a Visitor. This is the
deterministic syn heuristic; full name-resolution precision is a future
dylint pass. The design and its precision limits live in
internals/rust/isolation.md.
Implemented detector:
no-out-of-module-call(D1): a call expressionA::…::f(…)inside a#[cfg(test)]module whose leading segmentAreaches out of the module —crate::(first-party, another module),super::super::…(an ancestor), an external crate fromCargo.toml, or effectfulstd. A singlesuper::,self/Self, a bare/unqualified call, and purestd(incl.io::Cursor) stay in-module and are not flagged.
Re-exports§
pub use crate::violation::Violation;
Enums§
- Language
- A language whose unit-isolation convention can be checked. Rust only for now (Python #42 / TypeScript #43 are separate detectors).
Functions§
- find_
violations - Scan the Rust source files under
rootand return every isolation violation, sorted by(file, line)for deterministic output.