Expand description
Shared lowering/cache/mirror logic used by the trust-rustc
(RUSTC_WRAPPER) and trust-rustdoc (RUSTDOC) shims.
Both wrappers do the same job: given a rustc/rustdoc invocation, find
the input .rs file, and — if it’s strict-marked — lower the whole
source tree into a temp directory keyed by an FNV-1a content hash, then
rewrite the input path so the underlying tool sees plain Rust.
The functions here are the parts that don’t depend on whether we’re
about to exec rustc or rustdoc. The two main.rs files differ only
in how they parse out the tool path / input arg.
Structs§
- Prepared
- Result of preparing a strict-source invocation: the path to the lowered
crate-root file, and a
--remap-path-prefix=<cache>=<orig>flag the caller should append to the tool args so diagnostics still point at the user’s source.
Functions§
- collect_
crate_ callees - Walk
src_dirrecursively, parsing every.rsfile withsynand collecting(fn_name, [param_names...])for every module-levelfndefinition (free fns,pubor otherwise; module-nestedfns included). Used byprepare_strict_inputto build a crate-wide callee registry so cross-file named-arg call sites resolve (RT-40). - collect_
test_ only_ files - Files reachable only through a
#[cfg(test)] mod x;declaration (RT-88). - crate_
is_ force_ strict - Whether the crate currently being compiled was opted into strict mode at
the project level (
[package.metadata.trust] strict = true), rather than per-file with a#![strict]marker. - find_
input_ rs - Find the input
.rsfile argument in a rustc/rustdoc arg list. - lower_
doctests_ in_ source - Lower Trust syntax inside doc-test code blocks (
/// ```...````and//! ```...````) sorustdoc --testdoesn’t choke when rustc compiles each snippet on stable. Used by the mirror pass after the file itself has been lowered. - mirror_
module_ tree - Recursively mirror the source tree rooted at
src_dirintodest_dir, lowering strict-marked.rsfiles and hard-linking/copying others. - mirror_
module_ tree_ with_ extras - Variant of
mirror_module_treethat threads a crate-wide list of(fn_name, params)entries into every per-file lowering call. Used byprepare_strict_inputto resolve cross-file named-arg call sites (RT-40). - prepare_
strict_ input - If
input_pathis strict (per-file marker or project-level opt-in), lower the whole source tree into the cache and return the new root path + a--remap-path-prefixflag. - source_
cache_ key - FNV-1a 64-bit hash of the lowering-version string, the wrapper binary’s fingerprint, and the source bytes. Fast, no deps, deterministic per wrapper build.