Skip to main content

Property

Enum Property 

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

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, ) -> PropertyArg<'tcx>

Resolve a single positional argument according to its declared role.

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 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 new_simple(kind: PropertyKind) -> Self

Source

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.

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

A disjunct is either a single property application P(...) or a parenthesised conjunction (P1(...), ..., Pn(...)). Two patterns are supported:

  1. Null guard: exactly two disjuncts, one being Null(p) alone, the other a conjunction of properties over the same place p. The disjunction expands to the conjunct properties, each holding whenever p is non-null and vacuously for a null p.

  2. General disjunction: each disjunct is standalone or a conjunction, e.g., any(Trait(T, Copy), Trait(T, TrivialClone)). Produces a single Property::Or whose groups encode the DNF structure: each inner Vec is one AND-group.

Source

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

Source

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.

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 new_with_args(kind: PropertyKind, args: Vec<PropertyArg<'tcx>>) -> Self

Source

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

Source

fn parse_target_args_with_for_each( tcx: TyCtxt<'tcx>, def_id: DefId, exprs: &[Expr], ) -> (Vec<PropertyArg<'tcx>>, Option<ContractPlace<'tcx>>)

Source

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

Source§

impl<'tcx> Property<'tcx>

Source

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>

Source

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

Build a single predicate leaf.

Source

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.

Source

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

The predicate kind of a leaf property (None for an Or, which has no single kind).

Source

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

The positional arguments of a leaf property (Or has none).

Source

pub fn groups(&self) -> &[Vec<Box<Property<'tcx>>>]

The alternative groups of an Or property (Leaf has none).

Source

pub fn contract_kind(&self) -> ContractKind

Source

pub fn null_guard(&self) -> Option<&PlaceKey>

Source

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

Source

pub fn origin_name(&self) -> Option<&str>

Source

pub fn origin_args(&self) -> Option<&[String]>

The full call-site arguments of the compound def this property expanded from (None for plain primitives).

Source

pub fn origin_meaning(&self) -> Option<&str>

The human-readable meaning of the compound def.

Source

pub fn is_or(&self) -> bool

Source

pub fn ty_arg(&self) -> Option<Ty<'tcx>>

The first Ty argument.

Source

pub fn count_expr(&self) -> Option<&ContractExpr<'tcx>>

The first Expr argument, typically a count/length expression.

Source

pub 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 (leaf or Or) with the display name, full call-site arguments, and meaning of the compound def it expanded from.

Source

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

Attach a for_each container to a leaf property.

Source

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

Override the contract kind (e.g. AliasHazard).

Trait Implementations§

Source§

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

Source§

fn clone(&self) -> Property<'tcx>

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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