Expand description
Fail-closed source-capability gating over a Rust module tree.
rustc grants access to a private field to the defining module tree
alone. This crate makes that privacy cone auditable. It loads a module
directory, refuses every construction that could route source into or
out of it, exposes the declared struct shape, and reports identifier
occurrences at token level, so comments and string literals can neither
hide nor fabricate a capability site.
The crate is generic machinery. It knows nothing about any particular library; a caller names the module directory, the struct, and the representation identifier, and holds its own classified manifest.
The checks cover source text as parsed, not macro expansion or cfg
resolution. Item-position macro invocations and include-family
identifiers are therefore refused outright rather than resolved.
Re-exports§
pub use syn;
Structs§
- Macro
Surface - Every macro reachable from a source file, at token level, each entry
carrying its complete path spelling and line. Qualified spellings stay
qualified, so
evil::assertcan never collapse ontoassert. - Module
Audit - The module-shape findings for one file’s items.
- Module
File - One parsed file of a module tree.
- Module
Tree - A loaded module tree:
mod.rsfirst, then every declared file submodule in declaration order.
Functions§
- audit_
module_ items - Audits one file’s items: declared file submodules and refused constructions. Only the root file may declare file submodules.
- file_
module_ binding - Requires the parent file to bind
nameas one plain file module. - identifier_
line_ census - Per-line occurrence presence for
identifier: the set of source lines naming it, mapped to the line’s trimmed text, counted per distinct text. The shape a classified manifest compares against. - identifier_
lines - Every source line on which
identifieroccurs as a token, one entry per occurrence, in source order. Comments and literals cannot produce or hide an occurrence: the scan walks lexed tokens. - load_
module_ tree - Loads
mod.rsand every file submodule it declares, closing the tree. - macro_
surface - The complete macro surface of a source file. Every entry is a site where expansion could manufacture source the gate never scans, so a caller admits each name against an explicit allowlist or fails.
- struct_
fields - The named struct’s fields. Requires exactly one declaration of that name anywhere in the file, including inline modules.
- use_
bindings - Every name a
useitem binds into the file’s scope. - use_
statement_ count - The number of
usedeclarations the item-level walk can see.