pub trait CanonicalExt<'tcx, V> {
    // Required methods
    fn instantiate(
        &self,
        tcx: TyCtxt<'tcx>,
        var_values: &CanonicalVarValues<'tcx>
    ) -> V
       where V: TypeFoldable<TyCtxt<'tcx>>;
    fn instantiate_projected<T>(
        &self,
        tcx: TyCtxt<'tcx>,
        var_values: &CanonicalVarValues<'tcx>,
        projection_fn: impl FnOnce(&V) -> T
    ) -> T
       where T: TypeFoldable<TyCtxt<'tcx>>;
}
Expand description

FIXME(-Znext-solver): This or public because it is shared with the new trait solver implementation. We should deduplicate canonicalization.

Required Methods§

source

fn instantiate( &self, tcx: TyCtxt<'tcx>, var_values: &CanonicalVarValues<'tcx> ) -> V
where V: TypeFoldable<TyCtxt<'tcx>>,

Instantiate the wrapped value, replacing each canonical value with the value given in var_values.

source

fn instantiate_projected<T>( &self, tcx: TyCtxt<'tcx>, var_values: &CanonicalVarValues<'tcx>, projection_fn: impl FnOnce(&V) -> T ) -> T
where T: TypeFoldable<TyCtxt<'tcx>>,

Allows one to apply a instantiation to some subset of self.value. Invoke projection_fn with self.value to get a value V that is expressed in terms of the same canonical variables bound in self (usually this extracts from subset of self). Apply the instantiation var_values to this value V, replacing each of the canonical variables.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<'tcx, V> CanonicalExt<'tcx, V> for Canonical<TyCtxt<'tcx>, V>

source§

fn instantiate( &self, tcx: TyCtxt<'tcx>, var_values: &CanonicalVarValues<'tcx> ) -> V
where V: TypeFoldable<TyCtxt<'tcx>>,

Instantiate the wrapped value, replacing each canonical value with the value given in var_values.

source§

fn instantiate_projected<T>( &self, tcx: TyCtxt<'tcx>, var_values: &CanonicalVarValues<'tcx>, projection_fn: impl FnOnce(&V) -> T ) -> T
where T: TypeFoldable<TyCtxt<'tcx>>,

Allows one to apply a instantiation to some subset of self.value. Invoke projection_fn with self.value to get a value V that is expressed in terms of the same canonical variables bound in self (usually this extracts from subset of self). Apply the instantiation var_values to this value V, replacing each of the canonical variables.

Implementors§