Expand description
cargo psync check: verifies #[psync::graph] rewrites against the compiled bodies of callees.
#[psync::graph] sees only the tokens of the function it rewrites. It judges every call by its
name: api.get(..) reads, store.put(..) writes, do_work(x) is unknown. cargo psync check
runs the compiler with a custom driver (psync-driver, like clippy-driver) that sees the
program after type checking, as MIR:
- Summaries. For every function of every crate in the build, the driver computes which
effects on the outside world the function performs: file reads and writes (
std::fs,tokio::fs, …), sockets, processes, environment variables, and calls into other crates’ APIs, classified by their verbs (delete,list, …). Calls are resolved exactly (trait methods to their impls), callees in the same crate are followed into their bodies, and summaries of dependencies are read from files the driver wrote when it compiled them. - Checks. In every function
#[psync::graph]rewrote, the generated code marks each concurrent level and each prefetched loop (maybe_done_at,over_at) with what the macro assumed. The driver compares those assumptions with the summaries and warns where the rewrite runs two conflicting effects at once, performs a write before an earlier exit, or shares interior-mutable state between concurrent chains.
This library holds the parts shared by the driver and the cargo psync front end: the effect
model, summary files and findings. It does not link the compiler.
Re-exports§
pub(crate) use Deserialize;🔒pub(crate) use Deserialize;🔒pub(crate) use Serialize;🔒pub(crate) use Serialize;🔒pub(crate) use std::collections::BTreeMap;🔒pub(crate) use std::path::Path;🔒
Modules§
- env
- pdg
- Environment variables the front end passes to the driver. Control dependence for a function’s program dependence graph (Ferrante, Ottenstein and Warren, 1987).
Structs§
- Call
Fact - What one call in a
#[psync::graph]function does, for the macro. - Crate
Findings - The findings of one crate, as written by the driver.
- Crate
Summaries - Every summary of one crate, keyed by the stable hash of each function’s definition path.
- Effect
- One effect of a function, with the calls through which it happens.
- Finding
- One problem found in a rewritten function.
- Fix
- An insertion that fixes a finding:
#[psync::seq]before the statement or loop. - FnSummary
- The summary of one function, as stored for other crates.
- Resolved
- The effects of a deferred trait method: the union over its implementations in the build.
Enums§
- Access
- How an effect touches its domain.
- Domain
- Where an effect lands.
- Severity
- How serious a finding is.
Functions§
- conflict
- Whether two effects may not run concurrently: one writes, they may reach the same resource, and their targets may be the same (or both are ordered writes on one domain).
- facts_
text - The facts file the macro reads (
PSYNC_FACTS): one call site per line,site \t name \t panics \t opaque \t effects(opaque: some callee could not be seen through), effects separated by\x1e, eachdomain \x1f access \x1f target. Domains:fs,net,env,process,output,svc:<owner>; accessesr,w,o. A line-based format keeps the macro free of a JSON dependency. - link
- Link-time resolution of
dynand generic trait calls over the whole build (closed world): every deferred trait method’s effects are the union of its implementations’ effects, and of what those call throughdynin turn. - paths_
overlap - Equal paths, or one is a directory containing the other.
- read_
all - Read every
*.jsonfile indirasT, skipping files that do not parse. - resolve_
call - The final effects of a call site: its own, and those of the trait methods it reaches
through
dyn. - same_
effect 🔒