Wf

Struct Wf 

Source
struct Wf<'a, 'genv, 'tcx> {
    infcx: &'a mut InferCtxt<'genv, 'tcx>,
    errors: Errors<'genv>,
    next_type_index: u32,
    next_region_index: u32,
    next_const_index: u32,
}

Fields§

§infcx: &'a mut InferCtxt<'genv, 'tcx>§errors: Errors<'genv>§next_type_index: u32§next_region_index: u32§next_const_index: u32

Implementations§

Source§

impl<'a, 'genv, 'tcx> Wf<'a, 'genv, 'tcx>

Source

fn with( infcx: &'a mut InferCtxt<'genv, 'tcx>, f: impl FnOnce(&mut Self) -> Result<(), ErrorGuaranteed>, ) -> Result<(), ErrorGuaranteed>

Source

fn check_flux_item(&mut self, item: FluxItem<'genv>)

Source

fn check_node(&mut self, node: &OwnerNode<'genv>)

Source

fn check_expr(&mut self, expr: &Expr<'genv>, sort: &Sort)

Source

fn declare_params_for_primop_prop( &mut self, primop_prop: &PrimOpProp<'genv>, ) -> Result<(), ErrorGuaranteed>

Source

fn declare_params_for_flux_item( &mut self, item: FluxItem<'genv>, ) -> Result<(), ErrorGuaranteed>

Recursively traverse item and declare all refinement parameters

Source

fn declare_params_for_node( &mut self, node: &OwnerNode<'genv>, ) -> Result<(), ErrorGuaranteed>

Recursively traverse node and declare all refinement parameters

Source

fn declare_params_for_invariants( &mut self, params: &[RefineParam<'genv>], invariants: &[Expr<'genv>], ) -> Result<(), ErrorGuaranteed>

Recursively traverse invariants and declare all refinement parameters

Source

fn declare_params_in_expr( &mut self, expr: &Expr<'genv>, ) -> Result<(), ErrorGuaranteed>

Source

fn declare_param( &mut self, param: &RefineParam<'genv>, ) -> Result<(), ErrorGuaranteed>

Source

fn init_infcx_for_node(&mut self, node: &OwnerNode<'genv>) -> QueryResult

To check for well-formedness we need to synthesize sorts for some nodes which is hard to compute in fhir. For example, to check if the type i32[e] is well formed, we need to know that the sort of i32 is int so we can check the expression e against it. Computing the sort from a base type is subtle and hard to do in fhir so we must do it in rty. However, to convert from fhir to rty we need elaborated information from sort checking which we do in fhir.

To break this circularity, we do conversion in two phases. In the first phase, we do conversion without elaborated information. This results in types in rty with incorrect refinements but with the right shape to compute their sorts. We use these sorts for sort checking and then do conversion again with the elaborated information.

This function initializes the inference context by running the first phase of conversion and collecting the sorts of some nodes that are hard to compute in fhir.

Source

fn init_infcx_for_flux_item(&mut self, item: FluxItem<'genv>) -> QueryResult

Source

fn check_output_locs(&mut self, fn_decl: &FnDecl<'_>)

Trait Implementations§

Source§

impl<'genv, 'tcx> ConvPhase<'genv, 'tcx> for Wf<'_, 'genv, 'tcx>

Source§

const EXPAND_TYPE_ALIASES: bool = false

We don’t expand type aliases before sort checking because we need every base type in fhir to match a type in rty.

Source§

const HAS_ELABORATED_INFORMATION: bool = false

Whether we have elaborated information or not (in the first phase we will not, but in the second we will).
Source§

type Results = InferCtxt<'genv, 'tcx>

Source§

fn genv(&self) -> GlobalEnv<'genv, 'tcx>

Source§

fn owner(&self) -> FluxOwnerId

Source§

fn next_sort_vid(&mut self) -> SortVid

Source§

fn next_type_vid(&mut self) -> TyVid

Source§

fn next_region_vid(&mut self) -> RegionVid

Source§

fn next_const_vid(&mut self) -> ConstVid

Source§

fn results(&self) -> &Self::Results

Source§

fn insert_node_sort(&mut self, fhir_id: FhirId, sort: Sort)

Called during the first phase to collect the sort associated to a node which would be hard to recompute from fhir otherwise. Currently, this is being called when converting: Read more
Source§

fn insert_path_args(&mut self, fhir_id: FhirId, args: GenericArgs)

Called after converting a path with the generic arguments. Using during the first phase to instantiate sort of generic refinements.
Source§

fn insert_alias_reft_sort(&mut self, fhir_id: FhirId, fsort: FuncSort)

Called after converting an fhir::ExprKind::Alias with the sort of the resulting rty::AliasReft. Used during the first phase to collect the sorts of refinement aliases.
Source§

fn into_conv_ctxt(self) -> ConvCtxt<Self>

Source§

fn as_conv_ctxt(&mut self) -> &mut ConvCtxt<Self>

Source§

impl<'genv> Visitor<'genv> for Wf<'_, 'genv, '_>

Source§

fn visit_qualifier(&mut self, qual: &Qualifier<'genv>)

Source§

fn visit_primop_prop(&mut self, primop_prop: &PrimOpProp<'genv>)

Source§

fn visit_func(&mut self, func: &SpecFunc<'genv>)

Source§

fn visit_impl_assoc_reft(&mut self, assoc_reft: &ImplAssocReft<'genv>)

Source§

fn visit_trait_assoc_reft(&mut self, assoc_reft: &TraitAssocReft<'genv>)

Source§

fn visit_variant_ret(&mut self, ret: &VariantRet<'genv>)

Source§

fn visit_fn_decl(&mut self, decl: &FnDecl<'genv>)

Source§

fn visit_requires(&mut self, requires: &Requires<'genv>)

Source§

fn visit_ensures(&mut self, ensures: &Ensures<'genv>)

Source§

fn visit_ty(&mut self, ty: &Ty<'genv>)

Source§

fn visit_path(&mut self, path: &Path<'genv>)

Source§

fn visit_flux_item(&mut self, item: &FluxItem<'v>)

Source§

fn visit_node(&mut self, node: &OwnerNode<'v>)

Source§

fn visit_item(&mut self, item: &Item<'v>)

Source§

fn visit_trait_item(&mut self, trait_item: &TraitItem<'v>)

Source§

fn visit_impl_item(&mut self, impl_item: &ImplItem<'v>)

Source§

fn visit_foreign_item(&mut self, foreign_item: &ForeignItem<'v>)

Source§

fn visit_generics(&mut self, generics: &Generics<'v>)

Source§

fn visit_where_predicate(&mut self, predicate: &WhereBoundPredicate<'v>)

Source§

fn visit_impl(&mut self, impl_: &Impl<'v>)

Source§

fn visit_struct_def(&mut self, struct_def: &StructDef<'v>)

Source§

fn visit_enum_def(&mut self, enum_def: &EnumDef<'v>)

Source§

fn visit_variant(&mut self, variant: &VariantDef<'v>)

Source§

fn visit_field_def(&mut self, field: &FieldDef<'v>)

Source§

fn visit_ty_alias(&mut self, ty_alias: &TyAlias<'v>)

Source§

fn visit_opaque_ty(&mut self, opaque_ty: &OpaqueTy<'v>)

Source§

fn visit_generic_bound(&mut self, bound: &GenericBound<'v>)

Source§

fn visit_poly_trait_ref(&mut self, trait_ref: &PolyTraitRef<'v>)

Source§

fn visit_fn_sig(&mut self, sig: &FnSig<'v>)

Source§

fn visit_refine_param(&mut self, param: &RefineParam<'v>)

Source§

fn visit_fn_output(&mut self, output: &FnOutput<'v>)

Source§

fn visit_generic_arg(&mut self, arg: &GenericArg<'v>)

Source§

fn visit_lifetime(&mut self, _lft: &Lifetime)

Source§

fn visit_bty(&mut self, bty: &BaseTy<'v>)

Source§

fn visit_qpath(&mut self, qpath: &QPath<'v>)

Source§

fn visit_path_segment(&mut self, segment: &PathSegment<'v>)

Source§

fn visit_assoc_item_constraint(&mut self, constraint: &AssocItemConstraint<'v>)

Source§

fn visit_sort(&mut self, sort: &Sort<'v>)

Source§

fn visit_sort_path(&mut self, path: &SortPath<'v>)

Source§

fn visit_poly_func_sort(&mut self, func: &PolyFuncSort<'v>)

Source§

fn visit_func_sort(&mut self, func: &FuncSort<'v>)

Source§

fn visit_expr(&mut self, expr: &Expr<'v>)

Source§

fn visit_field_expr(&mut self, expr: &FieldExpr<'v>)

Source§

fn visit_alias_reft(&mut self, alias_reft: &AliasReft<'v>)

Source§

fn visit_literal(&mut self, _lit: &Lit)

Source§

fn visit_path_expr(&mut self, _path: &PathExpr<'v>)

Auto Trait Implementations§

§

impl<'a, 'genv, 'tcx> !Freeze for Wf<'a, 'genv, 'tcx>

§

impl<'a, 'genv, 'tcx> !RefUnwindSafe for Wf<'a, 'genv, 'tcx>

§

impl<'a, 'genv, 'tcx> !Send for Wf<'a, 'genv, 'tcx>

§

impl<'a, 'genv, 'tcx> !Sync for Wf<'a, 'genv, 'tcx>

§

impl<'a, 'genv, 'tcx> Unpin for Wf<'a, 'genv, 'tcx>

§

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

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more