Expand description
The bundled JSON contract front-end: loading, lookup, and conversion.
Three embedded JSON assets provide out-of-the-box contracts: std function
requires contracts (std-api-requires.json), std type invariants
(std-type-invariants.json), and std auto-trait ensures obligations
(std-trait-ensures.json). Lookup uses exact, path-stripped, and wildcard
fallback so trait-method impls and re-exported paths resolve correctly.
Entries are then converted into Property values via entry_to_property.
StructsΒ§
- Json
Property π - Structure of JSON entries.
- Type
Invariant πEntry - Serialisation-friendly struct for the type-invariants JSON.
EnumsΒ§
- AnyItem π
- One disjunct inside a JSON
anyentry.
FunctionsΒ§
- any_
entry_ πto_ property - Parse an
anydisjunction entry from JSON into aProperty::Orproperty. - entry_
to_ πproperty - Convert a single
JsonPropertyfrom JSON into the properties it denotes. - get_
std_ πcontracts_ from_ json - Looks up backup contracts for a standard-library function by its normalized path. For trait-method impls, resolves to the trait methodβs path first so that all impls share the same contracts.
- get_
std_ πtype_ invariants - Returns the std-type-invariants database, mapping a type path key
(e.g.
"core::num::nonzero::NonZero") to its invariant entries. - is_
contract_ πtoken_ char - load_
std_ πcontracts_ json - Lazily loads the backup contract database for standard-library APIs.
- load_
trait_ πensures_ json - Lazily loads the std auto-trait
ensuresobligation database. - normalize_
json_ πcontract_ arg - Convert explicit JSON contract tokens into the expression syntax accepted by the existing property parser.
- query_
json_ πcontracts - Query contracts for a function from the bundled JSON backup database.
- query_
trait_ πensures - Returns the
ensuresobligation template for a marker trait such asSend/Sync, keyed by the traitβs def path (e.g."core::marker::Send"). - resolve_
entry_ πgroup - Resolve a single JSON
anyentry into its property group (empty on error). - resolve_
json_ πargs - Resolve JSON contract argument strings to parsed
syn::Exprvalues. - resolve_
json_ πparam_ name - Resolve a simple parameter-name reference in a JSON contract arg string to
the
arg:Npositional form. Complex expressions (containing function calls, field access, etc.) are left unchanged β they are handled later by the expression parser which already knows how to resolve named parameters. - resolve_
trait_ πmethod - If
def_idis a trait-method implementation, returns the corresponding trait methodβs [DefId]; otherwise returnsdef_idunchanged. - scan_
while π - std_
contracts_ πhas_ entry - Whether the JSON contract database has an entry for
def_idβ including an empty one, which means βno safety contract is neededβ (e.g.fmt::new, whose arguments are all references).