Skip to main content

Module json

Module json 

Source
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Β§

JsonProperty πŸ”’
Structure of JSON entries.
StdTraitContracts πŸ”’
StdTraitMethodContracts πŸ”’

EnumsΒ§

AnyItem πŸ”’
One disjunct inside a JSON any entry.

FunctionsΒ§

any_entry_to_property πŸ”’
Parse an any disjunction entry from JSON into a Property::Or property.
entry_to_property πŸ”’
Convert a single JsonProperty from 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 ensures obligation template for a marker trait such as Send/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 RefCountShare requirements on this function.
resolve_entry_group πŸ”’
Resolve a single JSON any entry into its property group (empty on error).
resolve_json_args πŸ”’
Resolve JSON contract argument strings to parsed syn::Expr values.
resolve_json_param_name πŸ”’
Resolve a simple parameter-name reference in a JSON contract arg string to the arg:N positional 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_id is a trait-method implementation, returns the corresponding trait method’s [DefId]; otherwise returns def_id unchanged.
scan_while πŸ”’