Skip to main content

Property

Enum Property 

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

§

Atom(AtomProperty<'tcx>)

§

And(AndProperty<'tcx>)

§

Or(OrProperty<'tcx>)

Implementations§

Source§

impl<'tcx> Property<'tcx>

Source

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.

Source

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).

Source

fn build_uniform( tcx: TyCtxt<'tcx>, def_id: DefId, spec: &PropertySpec, exprs: &[Expr], ) -> Self

Positional resolution over one of the spec’s accepted forms.

Source

pub(crate) fn new( tcx: TyCtxt<'tcx>, def_id: DefId, name: &str, exprs: &[Expr], ) -> Self

Source

fn build_size(tcx: TyCtxt<'tcx>, def_id: DefId, exprs: &[Expr]) -> Self

Source

fn build_allocated(tcx: TyCtxt<'tcx>, def_id: DefId, exprs: &[Expr]) -> Self

Source

fn build_inbound(tcx: TyCtxt<'tcx>, def_id: DefId, exprs: &[Expr]) -> Self

Source

fn build_nonoverlap(tcx: TyCtxt<'tcx>, def_id: DefId, exprs: &[Expr]) -> Self

Source

fn build_validnum(tcx: TyCtxt<'tcx>, def_id: DefId, exprs: &[Expr]) -> Self

Source

fn build_targets( spec: &PropertySpec, tcx: TyCtxt<'tcx>, def_id: DefId, exprs: &[Expr], ) -> Self

Source

fn build_pinned(tcx: TyCtxt<'tcx>, def_id: DefId, exprs: &[Expr]) -> Self

Source

fn build_split_transmute( tcx: TyCtxt<'tcx>, def_id: DefId, exprs: &[Expr], ) -> Self

Source

fn build_contain_no_type( tcx: TyCtxt<'tcx>, def_id: DefId, exprs: &[Expr], ) -> Self

Source

fn new_simple(kind: PropertyKind) -> Self

Source

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.

Source

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.

Source

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.

Source

fn call_parts(expr: &Expr) -> Option<(String, Vec<Expr>)>

Split a Name(arg, ...) call expression into its name and arguments.

Source

fn check_arg_length(expr_len: usize, required_len: usize, sp: &str) -> bool

Source§

impl<'tcx> Property<'tcx>

Source

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>

Source

pub(crate) fn new_atom(kind: PropertyKind, args: Vec<PropertyArg<'tcx>>) -> Self

Build a single atomic predicate.

Source

pub(crate) fn new_and(conjuncts: Vec<Property<'tcx>>) -> Self

Build a conjunction (And) of already-expanded conjuncts.

Source

pub(crate) fn new_or(disjuncts: Vec<Property<'tcx>>) -> Self

Build a disjunction (Or) of already-expanded disjuncts.

Source

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.

Source

pub(crate) fn kind(&self) -> Option<PropertyKind>

The predicate kind of an atom (None for And/Or, which have no single kind).

Source

pub(crate) fn args(&self) -> &[PropertyArg<'tcx>]

The positional arguments of an atom (And/Or have none).

Source

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]).

Source

pub(crate) fn conjuncts(&self) -> &[Box<Property<'tcx>>]

The conjuncts of an And property (Atom/Or have none).

Source

pub(crate) fn disjuncts(&self) -> &[Box<Property<'tcx>>]

The disjuncts of an Or property (Atom/And have none).

Source

pub(crate) fn contract_kind(&self) -> ContractKind

Source

pub(crate) fn for_each(&self) -> Option<&ContractPlace<'tcx>>

Source

pub(crate) fn origin(&self) -> Option<&ContractOrigin>

Display metadata when this property was expanded from a compound property.

Source

pub(crate) fn is_or(&self) -> bool

Source

pub(crate) fn is_and(&self) -> bool

Source

pub(crate) fn apply_kind(&mut self, kind: Option<&str>)

Apply contract kind metadata from a JSON entry or attribute.

Source

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.

Source

pub(crate) fn clear_origin(&mut self)

Remove the compound-origin display metadata from this property.

Source

pub(crate) fn set_for_each(&mut self, place: Option<ContractPlace<'tcx>>)

Attach a for_each container to an atom.

Source

pub(crate) fn set_contract_kind(&mut self, k: ContractKind)

Override the contract kind (e.g. Alias → Hazard).

Trait Implementations§

Source§

impl<'tcx> Clone for Property<'tcx>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'tcx> Debug for Property<'tcx>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V