pub enum Property<'tcx> {
Leaf(LeafProperty<'tcx>),
Or(OrProperty<'tcx>),
}Expand description
A safety property: either a single predicate (Leaf) or a disjunction of
alternative predicate groups (Or).
Conjunction (And) is deliberately not a variant: it is expressed by the
surrounding collection — the caller’s requires list is already a
conjunction, and each Or group is a conjunction of its members (DNF).
Splitting Leaf from Or makes the mutually-exclusive payloads (args
vs. groups) explicit in the type, so a leaf can never carry alternatives
and an Or can never carry arguments.
Variants§
Leaf(LeafProperty<'tcx>)
Or(OrProperty<'tcx>)
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,
) -> PropertyArg<'tcx>
fn resolve_arg( tcx: TyCtxt<'tcx>, def_id: DefId, tag: &str, arg_kind: ArgKind, expr: &Expr, ) -> PropertyArg<'tcx>
Resolve a single positional argument according to its declared role.
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 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 new_simple(kind: PropertyKind) -> Self
Sourcepub fn parse_list(
tcx: TyCtxt<'tcx>,
def_id: DefId,
name: &str,
exprs: &[Expr],
) -> Vec<Self>
pub 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, ...), ...))A disjunct is either a single property application P(...) or a
parenthesised conjunction (P1(...), ..., Pn(...)). Two patterns are
supported:
-
Null guard: exactly two disjuncts, one being
Null(p)alone, the other a conjunction of properties over the same placep. The disjunction expands to the conjunct properties, each holding wheneverpis non-null and vacuously for a nullp. -
General disjunction: each disjunct is standalone or a conjunction, e.g.,
any(Trait(T, Copy), Trait(T, TrivialClone)). Produces a singleProperty::Orwhosegroupsencode the DNF structure: each innerVecis one AND-group.
Sourcefn build_null_guard(
tcx: TyCtxt<'tcx>,
def_id: DefId,
guard: &[(String, Vec<Expr>)],
conjuncts: &[(String, Vec<Expr>)],
) -> Vec<Self>
fn build_null_guard( tcx: TyCtxt<'tcx>, def_id: DefId, guard: &[(String, Vec<Expr>)], conjuncts: &[(String, Vec<Expr>)], ) -> Vec<Self>
Build the null-guard expansion: Null(p) OR (P1 & P2 & ...).
Sourcefn apply_null_guard(property: &mut Property<'tcx>, guard_key: &PlaceKey) -> bool
fn apply_null_guard(property: &mut Property<'tcx>, guard_key: &PlaceKey) -> bool
Recursively propagate a null-guard to a property and every member of its
Or groups. Returns false if a place-bearing member constrains a
place other than the guard.
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 new_with_args(kind: PropertyKind, args: Vec<PropertyArg<'tcx>>) -> Self
fn new_with_targets( kind: PropertyKind, tcx: TyCtxt<'tcx>, def_id: DefId, exprs: &[Expr], ) -> Self
fn parse_target_args_with_for_each( tcx: TyCtxt<'tcx>, def_id: DefId, exprs: &[Expr], ) -> (Vec<PropertyArg<'tcx>>, Option<ContractPlace<'tcx>>)
fn check_arg_length(expr_len: usize, required_len: usize, sp: &str) -> bool
Source§impl<'tcx> Property<'tcx>
impl<'tcx> Property<'tcx>
pub 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_leaf(kind: PropertyKind, args: Vec<PropertyArg<'tcx>>) -> Self
pub(crate) fn new_leaf(kind: PropertyKind, args: Vec<PropertyArg<'tcx>>) -> Self
Build a single predicate leaf.
Sourcepub(crate) fn new_or(groups: Vec<Vec<Box<Property<'tcx>>>>) -> Self
pub(crate) fn new_or(groups: Vec<Vec<Box<Property<'tcx>>>>) -> Self
Build a Property::Or disjunction from already-expanded DNF groups.
Each inner Vec is one AND-group (all its members must hold); at least
one group must hold for the disjunction to be satisfied. This is the
single place an Or property is constructed so that callers in the
def, JSON (query), and any(...) (parser) layers share identical
semantics.
Sourcepub fn kind(&self) -> Option<PropertyKind>
pub fn kind(&self) -> Option<PropertyKind>
The predicate kind of a leaf property (None for an Or, which has no
single kind).
Sourcepub fn args(&self) -> &[PropertyArg<'tcx>]
pub fn args(&self) -> &[PropertyArg<'tcx>]
The positional arguments of a leaf property (Or has none).
Sourcepub fn groups(&self) -> &[Vec<Box<Property<'tcx>>>]
pub fn groups(&self) -> &[Vec<Box<Property<'tcx>>>]
The alternative groups of an Or property (Leaf has none).
pub fn contract_kind(&self) -> ContractKind
pub fn null_guard(&self) -> Option<&PlaceKey>
pub fn for_each(&self) -> Option<&ContractPlace<'tcx>>
pub fn origin_name(&self) -> Option<&str>
Sourcepub fn origin_args(&self) -> Option<&[String]>
pub fn origin_args(&self) -> Option<&[String]>
The full call-site arguments of the compound def this property
expanded from (None for plain primitives).
Sourcepub fn origin_meaning(&self) -> Option<&str>
pub fn origin_meaning(&self) -> Option<&str>
The human-readable meaning of the compound def.
pub fn is_or(&self) -> bool
Sourcepub fn count_expr(&self) -> Option<&ContractExpr<'tcx>>
pub fn count_expr(&self) -> Option<&ContractExpr<'tcx>>
The first Expr argument, typically a count/length expression.
Sourcepub fn apply_kind(&mut self, kind: Option<&str>)
pub 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 (leaf or Or) with the display name, full call-site
arguments, and meaning of the compound def it expanded from.
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 a leaf property.
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