flux_fhir_analysis::wf::sortck

Struct InferCtxt

Source
pub(super) struct InferCtxt<'genv, 'tcx> {
    pub genv: GlobalEnv<'genv, 'tcx>,
    pub params: UnordMap<ParamId, (Sort, ParamKind)>,
    pub wfckresults: WfckResults,
    sort_unification_table: InPlaceUnificationTable<SortVid>,
    num_unification_table: InPlaceUnificationTable<NumVid>,
    bv_size_unification_table: InPlaceUnificationTable<BvSizeVid>,
    sort_of_bty: FxHashMap<FhirId, Sort>,
    sort_of_alias_reft: UnordMap<FhirId, FuncSort>,
}

Fields§

§genv: GlobalEnv<'genv, 'tcx>§params: UnordMap<ParamId, (Sort, ParamKind)>§wfckresults: WfckResults§sort_unification_table: InPlaceUnificationTable<SortVid>§num_unification_table: InPlaceUnificationTable<NumVid>§bv_size_unification_table: InPlaceUnificationTable<BvSizeVid>§sort_of_bty: FxHashMap<FhirId, Sort>§sort_of_alias_reft: UnordMap<FhirId, FuncSort>

Implementations§

Source§

impl<'genv, 'tcx> InferCtxt<'genv, 'tcx>

Source

pub(super) fn new(genv: GlobalEnv<'genv, 'tcx>, owner: FluxOwnerId) -> Self

Source

fn check_abs( &mut self, arg: &Expr<'_>, params: &[RefineParam<'_>], body: &Expr<'_>, expected: &Sort, ) -> Result<(), ErrorGuaranteed>

Source

fn check_field_exprs( &mut self, expr_span: Span, sort_def: &AdtSortDef, sort_args: &[Sort], field_exprs: &[FieldExpr<'_>], spread: &Option<&Spread<'_>>, expected: &Sort, ) -> Result<(), ErrorGuaranteed>

Source

fn check_constructor( &mut self, expr: &Expr<'_>, field_exprs: &[FieldExpr<'_>], spread: &Option<&Spread<'_>>, expected: &Sort, ) -> Result<(), ErrorGuaranteed>

Source

fn check_record( &mut self, arg: &Expr<'_>, flds: &[Expr<'_>], expected: &Sort, ) -> Result<(), ErrorGuaranteed>

Source

pub(super) fn check_expr( &mut self, expr: &Expr<'_>, expected: &Sort, ) -> Result<(), ErrorGuaranteed>

Source

pub(super) fn check_loc( &mut self, loc: &PathExpr<'_>, ) -> Result<(), ErrorGuaranteed>

Source

fn synth_expr(&mut self, expr: &Expr<'_>) -> Result<Sort, ErrorGuaranteed>

Source

fn synth_var(&mut self, path: &PathExpr<'_>) -> Sort

Source

fn synth_binary_op( &mut self, expr: &Expr<'_>, op: BinOp, e1: &Expr<'_>, e2: &Expr<'_>, ) -> Result<Sort, ErrorGuaranteed>

Source

fn synth_unary_op( &mut self, op: UnOp, e: &Expr<'_>, ) -> Result<Sort, ErrorGuaranteed>

Source

fn synth_app( &mut self, func: &PathExpr<'_>, args: &[Expr<'_>], span: Span, ) -> Result<Sort, ErrorGuaranteed>

Source

fn synth_alias_reft_app( &mut self, fhir_id: FhirId, span: Span, args: &[Expr<'_>], ) -> Result<Sort, ErrorGuaranteed>

Source

fn synth_func( &mut self, func: &PathExpr<'_>, ) -> Result<FuncSort, ErrorGuaranteed>

Source

fn instantiate_func_sort(&mut self, fsort: PolyFuncSort) -> FuncSort

Source

pub(crate) fn insert_sort_for_bty(&mut self, fhir_id: FhirId, sort: Sort)

Source

pub(crate) fn sort_of_bty(&self, fhir_id: FhirId) -> Sort

Source

pub(crate) fn insert_sort_for_alias_reft( &mut self, fhir_id: FhirId, fsort: FuncSort, )

Source

fn sort_of_alias_reft(&self, fhir_id: FhirId) -> FuncSort

Source

pub(crate) fn normalize_weak_alias_sorts(&mut self) -> QueryResult

Source§

impl InferCtxt<'_, '_>

Source

pub(super) fn insert_param(&mut self, id: ParamId, sort: Sort, kind: ParamKind)

Source

fn is_coercible(&mut self, sort1: &Sort, sort2: &Sort, fhir_id: FhirId) -> bool

Whether a value of sort1 can be automatically coerced to a value of sort2. A value of an rty::SortCtor::Adt sort with a single field of sort s can be coerced to a value of sort s and vice versa, i.e., we can automatically project the field out of the record or inject a value into a record.

Source

fn is_coercible_from_func( &mut self, sort: &Sort, fhir_id: FhirId, ) -> Option<PolyFuncSort>

Source

fn is_coercible_to_func( &mut self, sort: &Sort, fhir_id: FhirId, ) -> Option<PolyFuncSort>

Source

fn try_equate(&mut self, sort1: &Sort, sort2: &Sort) -> Option<Sort>

Source

fn try_equate_inner(&mut self, sort1: &Sort, sort2: &Sort) -> Option<Sort>

Source

fn try_equate_bv_sizes( &mut self, size1: BvSize, size2: BvSize, ) -> Option<BvSize>

Source

fn equate(&mut self, sort1: &Sort, sort2: &Sort) -> Sort

Source

pub(crate) fn next_sort_var(&mut self) -> Sort

Source

fn next_num_var(&mut self) -> Sort

Source

pub(crate) fn next_sort_vid(&mut self) -> SortVid

Source

fn next_num_vid(&mut self) -> NumVid

Source

fn next_bv_size_var(&mut self) -> BvSize

Source

fn next_bv_size_vid(&mut self) -> BvSizeVid

Source

pub(crate) fn resolve_param_sort( &mut self, param: &RefineParam<'_>, ) -> Result<(), ErrorGuaranteed>

Source

fn ensure_resolved_var( &mut self, path: &PathExpr<'_>, ) -> Result<Sort, ErrorGuaranteed>

Source

fn is_single_field_record(&mut self, sort: &Sort) -> Option<(DefId, Sort)>

Source

pub(crate) fn into_results(self) -> WfckResults

Source

pub(crate) fn infer_mode(&self, id: ParamId) -> InferMode

Source

pub(crate) fn param_sort(&self, id: ParamId) -> Sort

Source

fn shallow_resolve(&mut self, sort: &Sort) -> Sort

Source

fn resolve_vars_if_possible(&mut self, sort: &Sort) -> Sort

Source

pub(crate) fn fully_resolve(&mut self, sort: &Sort) -> Result<Sort, ()>

Source§

impl InferCtxt<'_, '_>

Source

fn emit_sort_mismatch( &mut self, span: Span, expected: &Sort, found: &Sort, ) -> ErrorGuaranteed

Source

fn emit_field_not_found(&mut self, sort: &Sort, field: Ident) -> ErrorGuaranteed

Source

fn emit_err<'b>(&'b self, err: impl Diagnostic<'b>) -> ErrorGuaranteed

Trait Implementations§

Source§

impl WfckResultsProvider for InferCtxt<'_, '_>

The purpose of doing conversion before sort checking is to collect the sorts of base types. Thus, what we return here mostly doesn’t matter because the refinements on a type should not affect its sort. The one exception is the sort we generate for refinement parameters.

For instance, consider the following definition where we refine a struct with a polymorphic set:

#[flux::refined_by(elems: Set<T>)]
struct RSet<T> { ... }

Now, consider the type RSet<i32{v: v >= 0}>. This type desugars to RSet<λv:σ. {i32[v] | v >= 0}> where the sort σ needs to be inferred. The type RSet<λv:σ. {i32[v] | v >= 0}> has sort RSet<σ> where RSet is the sort-level representation of the RSet type. Thus, it is important that the inference variable we generate for σ is the same we use for sort checking.

Auto Trait Implementations§

§

impl<'genv, 'tcx> Freeze for InferCtxt<'genv, 'tcx>

§

impl<'genv, 'tcx> !RefUnwindSafe for InferCtxt<'genv, 'tcx>

§

impl<'genv, 'tcx> !Send for InferCtxt<'genv, 'tcx>

§

impl<'genv, 'tcx> !Sync for InferCtxt<'genv, 'tcx>

§

impl<'genv, 'tcx> Unpin for InferCtxt<'genv, 'tcx>

§

impl<'genv, 'tcx> !UnwindSafe for InferCtxt<'genv, '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
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
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.