pub(crate) enum Property<'tcx> {
Atom(AtomProperty<'tcx>),
And(AndProperty<'tcx>),
Or(OrProperty<'tcx>),
}Expand description
A safety property: a boolean formula over atomic predicates.
The formula is a tree of three node kinds — Atom (a single predicate),
And (conjunction: all members hold), and Or (disjunction: at least one
member holds). Box breaks the recursion; the top level of a contract is
simply a Vec<Property> (an implicit conjunction of requirements).
Variants§
Implementations§
Source§impl<'tcx> Property<'tcx>
impl<'tcx> Property<'tcx>
Sourcefn parse_from_spec(
tcx: TyCtxt<'tcx>,
def_id: DefId,
spec: &PropertySpec,
exprs: &[Expr],
) -> Self
fn parse_from_spec( tcx: TyCtxt<'tcx>, def_id: DefId, spec: &PropertySpec, exprs: &[Expr], ) -> Self
Parse a property from the declaration table, dispatching on the tag’s assembly strategy.
Sourcefn resolve_arg(
tcx: TyCtxt<'tcx>,
def_id: DefId,
tag: &str,
arg_kind: ArgKind,
expr: &Expr,
) -> Option<PropertyArg<'tcx>>
fn resolve_arg( tcx: TyCtxt<'tcx>, def_id: DefId, tag: &str, arg_kind: ArgKind, expr: &Expr, ) -> Option<PropertyArg<'tcx>>
Resolve a single positional argument according to its declared role.
Returns None when a Ty argument cannot be resolved, so the caller
degrades the whole property to Unknown instead of silently
substituting the never type (which would make Align/Typed trivially
provable).
Sourcefn build_uniform(
tcx: TyCtxt<'tcx>,
def_id: DefId,
spec: &PropertySpec,
exprs: &[Expr],
) -> Self
fn build_uniform( tcx: TyCtxt<'tcx>, def_id: DefId, spec: &PropertySpec, exprs: &[Expr], ) -> Self
Positional resolution over one of the spec’s accepted forms.
pub(crate) fn new( tcx: TyCtxt<'tcx>, def_id: DefId, name: &str, exprs: &[Expr], ) -> Self
fn build_size(tcx: TyCtxt<'tcx>, def_id: DefId, exprs: &[Expr]) -> Self
fn build_allocated(tcx: TyCtxt<'tcx>, def_id: DefId, exprs: &[Expr]) -> Self
fn build_inbound(tcx: TyCtxt<'tcx>, def_id: DefId, exprs: &[Expr]) -> Self
fn build_nonoverlap(tcx: TyCtxt<'tcx>, def_id: DefId, exprs: &[Expr]) -> Self
fn build_validnum(tcx: TyCtxt<'tcx>, def_id: DefId, exprs: &[Expr]) -> Self
fn build_targets( spec: &PropertySpec, tcx: TyCtxt<'tcx>, def_id: DefId, exprs: &[Expr], ) -> Self
fn build_pinned(tcx: TyCtxt<'tcx>, def_id: DefId, exprs: &[Expr]) -> Self
fn build_split_transmute( tcx: TyCtxt<'tcx>, def_id: DefId, exprs: &[Expr], ) -> Self
fn build_contain_no_type( tcx: TyCtxt<'tcx>, def_id: DefId, exprs: &[Expr], ) -> Self
fn new_simple(kind: PropertyKind) -> Self
Sourcepub(crate) fn parse_list(
tcx: TyCtxt<'tcx>,
def_id: DefId,
name: &str,
exprs: &[Expr],
) -> Vec<Self>
pub(crate) fn parse_list( tcx: TyCtxt<'tcx>, def_id: DefId, name: &str, exprs: &[Expr], ) -> Vec<Self>
Parse one annotation entry into the properties it denotes.
Plain entries (Align(p, T), Owning(p), …) yield one property.
The any(...) combinator may expand to several: see Self::parse_any.
Sourcefn parse_any(tcx: TyCtxt<'tcx>, def_id: DefId, exprs: &[Expr]) -> Vec<Self>
fn parse_any(tcx: TyCtxt<'tcx>, def_id: DefId, exprs: &[Expr]) -> Vec<Self>
Parse the disjunctive combinator any(D1, D2, ...) written in DNF:
any means logical OR between disjuncts, and commas inside a
parenthesised disjunct mean logical AND:
any(Null(p), (P1(p, ...), P2(p, ...), ...))
any(Trait(T, Copy), Trait(T, TrivialClone), ...)A disjunct is either a single property application P(...) or a
parenthesised conjunction (P1(...), ..., Pn(...)). Any number (≥ 2)
of disjuncts is accepted; each is expanded into its constituent
properties, producing a single Property::Or whose disjuncts are atoms
or And nodes.
Sourcefn disjunct_parts(expr: &Expr) -> Option<Vec<(String, Vec<Expr>)>>
fn disjunct_parts(expr: &Expr) -> Option<Vec<(String, Vec<Expr>)>>
Split one disjunct into its conjunct calls: a (P1, P2, ...) tuple, a
parenthesised single property (P), or a bare property application.
Sourcefn call_parts(expr: &Expr) -> Option<(String, Vec<Expr>)>
fn call_parts(expr: &Expr) -> Option<(String, Vec<Expr>)>
Split a Name(arg, ...) call expression into its name and arguments.
fn check_arg_length(expr_len: usize, required_len: usize, sp: &str) -> bool
Source§impl<'tcx> Property<'tcx>
impl<'tcx> Property<'tcx>
pub(crate) fn display_for_report( &self, tcx: TyCtxt<'tcx>, struct_def_id: Option<DefId>, fn_def_id: Option<DefId>, ) -> String
Source§impl<'tcx> Property<'tcx>
impl<'tcx> Property<'tcx>
Sourcepub(crate) fn new_atom(kind: PropertyKind, args: Vec<PropertyArg<'tcx>>) -> Self
pub(crate) fn new_atom(kind: PropertyKind, args: Vec<PropertyArg<'tcx>>) -> Self
Build a single atomic predicate.
Sourcepub(crate) fn new_and(conjuncts: Vec<Property<'tcx>>) -> Self
pub(crate) fn new_and(conjuncts: Vec<Property<'tcx>>) -> Self
Build a conjunction (And) of already-expanded conjuncts.
Sourcepub(crate) fn new_or(disjuncts: Vec<Property<'tcx>>) -> Self
pub(crate) fn new_or(disjuncts: Vec<Property<'tcx>>) -> Self
Build a disjunction (Or) of already-expanded disjuncts.
Sourcepub(crate) fn conjunction(conjuncts: Vec<Property<'tcx>>) -> Self
pub(crate) fn conjunction(conjuncts: Vec<Property<'tcx>>) -> Self
Normalize a list of conjuncts into a single Property: a singleton is
returned as-is, otherwise the list is wrapped in an And node.
Sourcepub(crate) fn kind(&self) -> Option<PropertyKind>
pub(crate) fn kind(&self) -> Option<PropertyKind>
The predicate kind of an atom (None for And/Or, which have no
single kind).
Sourcepub(crate) fn args(&self) -> &[PropertyArg<'tcx>]
pub(crate) fn args(&self) -> &[PropertyArg<'tcx>]
The positional arguments of an atom (And/Or have none).
Sourcepub(crate) fn target_place(&self) -> Option<&ContractPlace<'tcx>>
pub(crate) fn target_place(&self) -> Option<&ContractPlace<'tcx>>
The ContractPlace this atom’s first argument refers to, when the
first argument is a place (or an index access over one, e.g. slice[i]).
Sourcepub(crate) fn conjuncts(&self) -> &[Box<Property<'tcx>>]
pub(crate) fn conjuncts(&self) -> &[Box<Property<'tcx>>]
The conjuncts of an And property (Atom/Or have none).
Sourcepub(crate) fn disjuncts(&self) -> &[Box<Property<'tcx>>]
pub(crate) fn disjuncts(&self) -> &[Box<Property<'tcx>>]
The disjuncts of an Or property (Atom/And have none).
pub(crate) fn contract_kind(&self) -> ContractKind
pub(crate) fn for_each(&self) -> Option<&ContractPlace<'tcx>>
Sourcepub(crate) fn origin(&self) -> Option<&ContractOrigin>
pub(crate) fn origin(&self) -> Option<&ContractOrigin>
Display metadata when this property was expanded from a compound property.
pub(crate) fn is_or(&self) -> bool
pub(crate) fn is_and(&self) -> bool
Sourcepub(crate) fn apply_kind(&mut self, kind: Option<&str>)
pub(crate) fn apply_kind(&mut self, kind: Option<&str>)
Apply contract kind metadata from a JSON entry or attribute.
Sourcepub(crate) fn set_origin(
&mut self,
name: String,
args: Vec<String>,
meaning: Option<String>,
)
pub(crate) fn set_origin( &mut self, name: String, args: Vec<String>, meaning: Option<String>, )
Tag a property (atom, And, or Or) with the display name, full
call-site arguments, and meaning of the compound property it expanded from.
Sourcepub(crate) fn clear_origin(&mut self)
pub(crate) fn clear_origin(&mut self)
Remove the compound-origin display metadata from this property.
Sourcepub(crate) fn set_for_each(&mut self, place: Option<ContractPlace<'tcx>>)
pub(crate) fn set_for_each(&mut self, place: Option<ContractPlace<'tcx>>)
Attach a for_each container to an atom.
Sourcepub(crate) fn set_contract_kind(&mut self, k: ContractKind)
pub(crate) fn set_contract_kind(&mut self, k: ContractKind)
Override the contract kind (e.g. Alias → Hazard).
Trait Implementations§
Auto Trait Implementations§
impl<'tcx> !RefUnwindSafe for Property<'tcx>
impl<'tcx> !UnwindSafe for Property<'tcx>
impl<'tcx> DynSend for Property<'tcx>
impl<'tcx> DynSync for Property<'tcx>
impl<'tcx> Freeze for Property<'tcx>
impl<'tcx> Send for Property<'tcx>
impl<'tcx> Sync for Property<'tcx>
impl<'tcx> Unpin for Property<'tcx>
impl<'tcx> UnsafeUnpin for Property<'tcx>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more