Skip to main content

Crate trust_rustc

Crate trust_rustc 

Source
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_dir recursively, parsing every .rs file with syn and collecting (fn_name, [param_names...]) for every module-level fn definition (free fns, pub or otherwise; module-nested fns included). Used by prepare_strict_input to 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 .rs file argument in a rustc/rustdoc arg list.
lower_doctests_in_source
Lower Trust syntax inside doc-test code blocks (/// ```...```` and //! ```...```` ) so rustdoc --test doesn’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_dir into dest_dir, lowering strict-marked .rs files and hard-linking/copying others.
mirror_module_tree_with_extras
Variant of mirror_module_tree that threads a crate-wide list of (fn_name, params) entries into every per-file lowering call. Used by prepare_strict_input to resolve cross-file named-arg call sites (RT-40).
prepare_strict_input
If input_path is 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-prefix flag.
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.