Expand description
The bundled JSON contract front-end: loading, lookup, and conversion.
Embedded JSON assets provide std requires, type invariants, and trait contracts.
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.
Re-exportsΒ§
use rustc_hir::def_id::DefId;πuse rustc_middle::ty::TyCtxt;πuse serde::Deserialize;πuse serde::Deserialize;πuse serde::Serialize;πuse serde::Serialize;πuse std::collections::HashMap;πuse std::sync::OnceLock;πuse syn::Expr;πuse crate::util::name::public_def_path;πuse super::PlaceBase;πuse super::Property;πuse super::PropertyKind;π
StructsΒ§
- Json
Property π - Structure of JSON entries.
- StdTrait
Contracts π - StdTrait
Method πContracts
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_ πtrait_ method - get_
std_ πtrait_ method_ requires - 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_
std_ πtrait_ json - Lazily loads std trait contracts and marker-trait obligations.
- normalize_
json_ πcontract_ arg - Convert explicit JSON contract tokens into the expression syntax accepted by the existing property parser.
- parse_
json_ πcontracts - query_
json_ πcontracts - Query contracts for a function from the bundled JSON backup database.
- query_
json_ πcontracts_ at_ path - Parse the contract at an explicit JSON key using a functionβs parameter types.
- 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"). - query_
trait_ πmethod_ ensures - ref_
count_ πshare_ arg_ indices - Argument indices named by JSON
RefCountSharerequirements on this function. - 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 π