Struct chalk_engine::normalize_deep::DeepNormalizer

source ·
pub(crate) struct DeepNormalizer<'table, I: Interner> {
    table: &'table mut InferenceTable<I>,
    interner: I,
}

Fields§

§table: &'table mut InferenceTable<I>§interner: I

Implementations§

source§

impl<I: Interner> DeepNormalizer<'_, I>

source

pub fn normalize_deep<T: TypeFoldable<I>>( table: &mut InferenceTable<I>, interner: I, value: T, ) -> T

Given a value value with variables in it, replaces those variables with their instantiated values (if any). Uninstantiated variables are left as-is.

This is mainly intended for getting final values to dump to the user and its use should otherwise be avoided, particularly given the possibility of snapshots and rollbacks.

See also InferenceTable::canonicalize, which – during real processing – is often used to capture the “current state” of variables.

Trait Implementations§

source§

impl<'table, I: Interner> FallibleTypeFolder<I> for DeepNormalizer<'table, I>

§

type Error = Infallible

The type this folder returns when folding fails. This is commonly [NoSolution].
source§

fn as_dyn(&mut self) -> &mut dyn FallibleTypeFolder<I, Error = Self::Error>

Creates a dyn value from this folder. Unfortunately, this must be added manually to each impl of FallibleTypeFolder; it permits the default implements below to create a &mut dyn FallibleTypeFolder from Self without knowing what Self is (by invoking this method). Effectively, this limits impls of FallibleTypeFolder to types for which we are able to create a dyn value (i.e., not [T] types).
source§

fn try_fold_ty( &mut self, ty: Ty<I>, outer_binder: DebruijnIndex, ) -> Result<Ty<I>, Self::Error>

Top-level callback: invoked for each Ty<I> that is encountered when folding. By default, invokes try_super_fold_with, which will in turn invoke the more specialized folding methods below, like try_fold_free_var_ty.
source§

fn try_fold_lifetime( &mut self, lifetime: Lifetime<I>, outer_binder: DebruijnIndex, ) -> Result<Lifetime<I>, Self::Error>

Top-level callback: invoked for each Lifetime<I> that is encountered when folding. By default, invokes try_super_fold_with, which will in turn invoke the more specialized folding methods below, like try_fold_free_var_lifetime.
source§

fn try_fold_const( &mut self, constant: Const<I>, outer_binder: DebruijnIndex, ) -> Result<Const<I>, Self::Error>

Top-level callback: invoked for each Const<I> that is encountered when folding. By default, invokes try_super_fold_with, which will in turn invoke the more specialized folding methods below, like try_fold_free_var_const.
source§

fn try_fold_program_clause( &mut self, clause: ProgramClause<I>, outer_binder: DebruijnIndex, ) -> Result<ProgramClause<I>, Self::Error>

Invoked for every program clause. By default, recursively folds the goals contents.
source§

fn try_fold_goal( &mut self, goal: Goal<I>, outer_binder: DebruijnIndex, ) -> Result<Goal<I>, Self::Error>

Invoked for every goal. By default, recursively folds the goals contents.
source§

fn forbid_free_vars(&self) -> bool

If overridden to return true, then folding will panic if a free variable is encountered. This should be done if free type/lifetime variables are not expected.
source§

fn try_fold_free_var_ty( &mut self, bound_var: BoundVar, outer_binder: DebruijnIndex, ) -> Result<Ty<I>, Self::Error>

Invoked for TyKind::BoundVar instances that are not bound within the type being folded over: Read more
source§

fn try_fold_free_var_lifetime( &mut self, bound_var: BoundVar, outer_binder: DebruijnIndex, ) -> Result<Lifetime<I>, Self::Error>

As try_fold_free_var_ty, but for lifetimes.
source§

fn try_fold_free_var_const( &mut self, ty: Ty<I>, bound_var: BoundVar, outer_binder: DebruijnIndex, ) -> Result<Const<I>, Self::Error>

As try_fold_free_var_ty, but for constants.
source§

fn forbid_free_placeholders(&self) -> bool

If overridden to return true, we will panic when a free placeholder type/lifetime/const is encountered.
source§

fn try_fold_free_placeholder_ty( &mut self, universe: PlaceholderIndex, outer_binder: DebruijnIndex, ) -> Result<Ty<I>, Self::Error>

Invoked for each occurrence of a placeholder type; these are used when we instantiate binders universally. Returns a type to use instead, which should be suitably shifted to account for binders. Read more
source§

fn try_fold_free_placeholder_lifetime( &mut self, universe: PlaceholderIndex, outer_binder: DebruijnIndex, ) -> Result<Lifetime<I>, Self::Error>

As with try_fold_free_placeholder_ty, but for lifetimes.
source§

fn try_fold_free_placeholder_const( &mut self, ty: Ty<I>, universe: PlaceholderIndex, outer_binder: DebruijnIndex, ) -> Result<Const<I>, Self::Error>

As with try_fold_free_placeholder_ty, but for constants.
source§

fn forbid_inference_vars(&self) -> bool

If overridden to return true, inference variables will trigger panics when folded. Used when inference variables are unexpected.
source§

fn try_fold_inference_ty( &mut self, var: InferenceVar, kind: TyVariableKind, outer_binder: DebruijnIndex, ) -> Result<Ty<I>, Self::Error>

Invoked for each occurrence of a inference type; these are used when we instantiate binders universally. Returns a type to use instead, which should be suitably shifted to account for binders. Read more
source§

fn try_fold_inference_lifetime( &mut self, var: InferenceVar, outer_binder: DebruijnIndex, ) -> Result<Lifetime<I>, Self::Error>

As with try_fold_inference_ty, but for lifetimes.
source§

fn try_fold_inference_const( &mut self, ty: Ty<I>, var: InferenceVar, outer_binder: DebruijnIndex, ) -> Result<Const<I>, Self::Error>

As with try_fold_inference_ty, but for constants.
source§

fn interner(&self) -> I

Gets the interner that is being folded from.
source§

impl<I: Interner> TypeFolder<I> for DeepNormalizer<'_, I>

source§

fn as_dyn(&mut self) -> &mut dyn TypeFolder<I>

Creates a dyn value from this folder. Unfortunately, this must be added manually to each impl of TypeFolder; it permits the default implements below to create a &mut dyn TypeFolder from Self without knowing what Self is (by invoking this method). Effectively, this limits impls of TypeFolder to types for which we are able to create a dyn value (i.e., not [T] types).
source§

fn fold_inference_ty( &mut self, var: InferenceVar, kind: TyVariableKind, _outer_binder: DebruijnIndex, ) -> Ty<I>

Invoked for each occurrence of a inference type; these are used when we instantiate binders universally. Returns a type to use instead, which should be suitably shifted to account for binders. Read more
source§

fn fold_inference_lifetime( &mut self, var: InferenceVar, _outer_binder: DebruijnIndex, ) -> Lifetime<I>

As with fold_inference_ty, but for lifetimes.
source§

fn fold_inference_const( &mut self, ty: Ty<I>, var: InferenceVar, _outer_binder: DebruijnIndex, ) -> Const<I>

As with fold_inference_ty, but for constants.
source§

fn forbid_free_vars(&self) -> bool

If overridden to return true, then folding will panic if a free variable is encountered. This should be done if free type/lifetime variables are not expected.
source§

fn interner(&self) -> I

Gets the interner that is being folded from.
§

fn fold_ty(&mut self, ty: Ty<I>, outer_binder: DebruijnIndex) -> Ty<I>

Top-level callback: invoked for each Ty<I> that is encountered when folding. By default, invokes super_fold_with, which will in turn invoke the more specialized folding methods below, like fold_free_var_ty.
§

fn fold_lifetime( &mut self, lifetime: Lifetime<I>, outer_binder: DebruijnIndex, ) -> Lifetime<I>

Top-level callback: invoked for each Lifetime<I> that is encountered when folding. By default, invokes super_fold_with, which will in turn invoke the more specialized folding methods below, like fold_free_var_lifetime.
§

fn fold_const( &mut self, constant: Const<I>, outer_binder: DebruijnIndex, ) -> Const<I>

Top-level callback: invoked for each Const<I> that is encountered when folding. By default, invokes super_fold_with, which will in turn invoke the more specialized folding methods below, like fold_free_var_const.
§

fn fold_program_clause( &mut self, clause: ProgramClause<I>, outer_binder: DebruijnIndex, ) -> ProgramClause<I>

Invoked for every program clause. By default, recursively folds the goals contents.
§

fn fold_goal(&mut self, goal: Goal<I>, outer_binder: DebruijnIndex) -> Goal<I>

Invoked for every goal. By default, recursively folds the goals contents.
§

fn fold_free_var_ty( &mut self, bound_var: BoundVar, outer_binder: DebruijnIndex, ) -> Ty<I>

Invoked for TyKind::BoundVar instances that are not bound within the type being folded over: Read more
§

fn fold_free_var_lifetime( &mut self, bound_var: BoundVar, outer_binder: DebruijnIndex, ) -> Lifetime<I>

As fold_free_var_ty, but for lifetimes.
§

fn fold_free_var_const( &mut self, ty: Ty<I>, bound_var: BoundVar, outer_binder: DebruijnIndex, ) -> Const<I>

As fold_free_var_ty, but for constants.
§

fn forbid_free_placeholders(&self) -> bool

If overridden to return true, we will panic when a free placeholder type/lifetime/const is encountered.
§

fn fold_free_placeholder_ty( &mut self, universe: PlaceholderIndex, outer_binder: DebruijnIndex, ) -> Ty<I>

Invoked for each occurrence of a placeholder type; these are used when we instantiate binders universally. Returns a type to use instead, which should be suitably shifted to account for binders. Read more
§

fn fold_free_placeholder_lifetime( &mut self, universe: PlaceholderIndex, outer_binder: DebruijnIndex, ) -> Lifetime<I>

As with fold_free_placeholder_ty, but for lifetimes.
§

fn fold_free_placeholder_const( &mut self, ty: Ty<I>, universe: PlaceholderIndex, outer_binder: DebruijnIndex, ) -> Const<I>

As with fold_free_placeholder_ty, but for constants.
§

fn forbid_inference_vars(&self) -> bool

If overridden to return true, inference variables will trigger panics when folded. Used when inference variables are unexpected.

Auto Trait Implementations§

§

impl<'table, I> Freeze for DeepNormalizer<'table, I>
where I: Freeze,

§

impl<'table, I> RefUnwindSafe for DeepNormalizer<'table, I>
where I: RefUnwindSafe, <I as Interner>::InternedGenericArg: RefUnwindSafe,

§

impl<'table, I> Send for DeepNormalizer<'table, I>
where I: Send, <I as Interner>::InternedGenericArg: Send,

§

impl<'table, I> Sync for DeepNormalizer<'table, I>
where I: Sync, <I as Interner>::InternedGenericArg: Sync,

§

impl<'table, I> Unpin for DeepNormalizer<'table, I>
where I: Unpin,

§

impl<'table, I> !UnwindSafe for DeepNormalizer<'table, I>

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<T> Cast for T

§

fn cast<U>(self, interner: <U as HasInterner>::Interner) -> U
where Self: CastTo<U>, U: HasInterner,

Cast a value to type U using CastTo.
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, U> TryFrom<U> for T
where U: Into<T>,

§

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

§

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