Skip to main content

Module contract

Module contract 

Source
Expand description

Contract IR and type invariants.

Inline attributes, embedded JSON, and pred!-style compound properties produce the contract IR defined here. Attribute and JSON arguments are parsed as syn expressions; compound bodies use the pest grammar.

type_invariants synthesizes properties for known types.

§Layering

Contracts go through two stages, each with its own type:

attribute ──▶ AttrProperty ─┐
JSON ───────▶ JsonProperty ─┴──▶ builder.rs ──▶ Property (Atom | And | Or)
pred! ──────▶ CompoundSpec ─────▶ compound.rs ─▶ Property

Property::parse_list dispatches compound tags to compound::expand_compound; their CompoundSpec bypasses the primitive property builder.

Within the resolved IR, the naming follows granularity rather than stage: Property* names the formula level (Property, PropertyKind, PropertyArg), while Contract* names the expression sub-language used by PropertyArg::Expr and PropertyArg::ForEach (ContractPlace, ContractExpr, ContractProjection).

Re-exports§

use rustc_hir::def_id::DefId; 🔒
use rustc_middle::mir::Local; 🔒
use rustc_middle::ty::Region; 🔒
use rustc_middle::ty::Ty; 🔒

Modules§

annotation 🔒
Contract annotations on functions and structs.
attr 🔒
Parsing utilities for RAPx contract attributes.
builder 🔒
Assemble a safety tag into a Property via the declarative spec table.
compound 🔒
User-defined compound-contract layer.
ensures 🔒
Trait-method and foreign-call postcondition lookup.
json 🔒
The bundled JSON contract front-end: loading, lookup, and conversion.
pest 🔒
pest parser and semantic converter for the contract DSL.
place 🔒
Place resolution: syn::Expr → ContractPlace.
render 🔒
User-facing rendering of contract data structures.
resolve 🔒
Expression / argument resolution: syn::Expr → semantic values.
spec 🔒
Declaration table mapping tag names to their property specs.
type_invariants 🔒
Standard-library type-invariant generation.

Structs§

AndProperty 🔒
A conjunction: every conjuncts member must hold.
AtomProperty 🔒
ContractOrigin 🔒
Display metadata for a property expanded from a compound property (pred!-style macro). Purely presentational: it lets reports render a macro-expanded contract as a single name(args) entry with its doc-derived meaning, instead of the underlying primitives it expanded into.
ContractPlace 🔒
A place a contract refers to: a PlaceBase root plus a sequence of ContractProjection steps into it (e.g. self.next.value).
NumericPredicate 🔒
OrProperty 🔒
A disjunction: at least one disjuncts member must hold.

Enums§

BinOp 🔒
ContractExpr 🔒
ContractKind 🔒
ContractProjection 🔒
A step into a place, from the base down to the value a contract talks about (written as .field, .unwrap_some(), or .iter() in the DSL).
PlaceBase 🔒
The root of a contract place: a function’s return value, an argument, or a raw MIR local. Return ⇔ Local(0); Arg(n) ⇔ Local(n + 1).
Property 🔒
A safety property: a boolean formula over atomic predicates.
PropertyArg 🔒
One argument of a predicate call — what the property is applied to.
PropertyKind 🔒
The vocabulary of safety predicates a contract can assert.
RelOp 🔒
UnaryOp 🔒

Constants§

STATIC_LIFETIME_IDENT 🔒
The Ident a contract uses for the 'static lifetime. 'static is a Rust keyword, so after the leading ' is stripped it cannot be a plain ident token; the attribute and JSON parsers map it to this name.

Functions§

is_static_lifetime_ident 🔒
Whether a contract lifetime ident is the keyword-safe 'static placeholder.