Expand description
Facts from the compiler: what each call in an annotated function really does.
The macro sees only tokens, so it judges calls by their names (crate::effects).
cargo psync build first runs psync-driver, which reads the compiled bodies of every callee
(MIR, across crates, with dyn calls resolved over the whole build) and writes one line per
call site of every #[psync::graph] function. When the environment variable PSYNC_FACTS
names that file, the macro looks each call up by the source location of the callee’s name and
schedules with the compiler’s answer instead of the name:
- its effects replace the guessed ones:
factory.create(..)that only reads is a read, a helper namedwarm()that writescache.jsonis a write to that file; - a callee that panics on purpose (
unwrap,expect,panic!,assert!) is an exit, so writes after it wait for it.
A fact is used only if the callee’s name at that location still matches, so stale facts (from
before an edit) are ignored rather than misapplied. The generated code reads
option_env!("PSYNC_FACTS_STAMP"), which makes cargo rebuild annotated crates when the facts
change.
Structs§
- Fact 🔒
- What the compiler found about one call.
Functions§
- at 🔒
- The fact for the call whose callee name is
ident(a method name, or the last segment of a function path) starting atspan, if the compiler recorded one there. - parse 🔒
- Parse the facts file written by
cargo psync(seepsync_check::facts_text). - site_
key 🔒 /abs/path/file.rs:line:columnof a span’s start, as the driver writes it. Only available inside a procedural macro.- table 🔒