Trait chalk_solve::split::Split

source ·
pub trait Split<I: Interner>: RustIrDatabase<I> {
    // Provided methods
    fn split_projection<'p>(
        &self,
        projection: &'p ProjectionTy<I>
    ) -> (Arc<AssociatedTyDatum<I>>, &'p [GenericArg<I>], &'p [GenericArg<I>]) { ... }
    fn trait_parameters_from_projection<'p>(
        &self,
        projection: &'p ProjectionTy<I>
    ) -> &'p [GenericArg<I>] { ... }
    fn trait_ref_from_projection(
        &self,
        projection: &ProjectionTy<I>
    ) -> TraitRef<I> { ... }
    fn split_associated_ty_value_parameters<'p, P>(
        &self,
        parameters: &'p [P],
        associated_ty_value: &AssociatedTyValue<I>
    ) -> (&'p [P], &'p [P]) { ... }
    fn impl_parameters_and_projection_from_associated_ty_value<'p>(
        &self,
        parameters: &'p [GenericArg<I>],
        associated_ty_value: &AssociatedTyValue<I>
    ) -> (&'p [GenericArg<I>], ProjectionTy<I>) { ... }
    fn split_associated_ty_parameters<'p, P>(
        &self,
        parameters: &'p [P],
        associated_ty_datum: &AssociatedTyDatum<I>
    ) -> (&'p [P], &'p [P]) { ... }
}
Expand description

Methods for splitting up the projections for associated types from the surrounding context.

Provided Methods§

source

fn split_projection<'p>( &self, projection: &'p ProjectionTy<I> ) -> (Arc<AssociatedTyDatum<I>>, &'p [GenericArg<I>], &'p [GenericArg<I>])

Given a projection of an associated type, split the type parameters into those that come from the trait and those that come from the associated type itself. So e.g. if you have (Iterator::Item)<F>, this would return ([F], []), since Iterator::Item is not generic and hence doesn’t have any type parameters itself.

source

fn trait_parameters_from_projection<'p>( &self, projection: &'p ProjectionTy<I> ) -> &'p [GenericArg<I>]

Given a projection <P0 as Trait<P1..Pn>>::Item<Pn..Pm>, returns the trait parameters [P0..Pn] (see split_projection).

source

fn trait_ref_from_projection(&self, projection: &ProjectionTy<I>) -> TraitRef<I>

Given a projection <P0 as Trait<P1..Pn>>::Item<Pn..Pm>, returns the trait parameters [P0..Pn] (see split_projection).

source

fn split_associated_ty_value_parameters<'p, P>( &self, parameters: &'p [P], associated_ty_value: &AssociatedTyValue<I> ) -> (&'p [P], &'p [P])

Given the full set of parameters (or binders) for an associated type value (which appears in an impl), splits them into the substitutions for the impl and those for the associated type.

§Example
impl<T> Iterable for Vec<T> {
    type Iter<'a>;
}

in this example, the full set of parameters would be ['x, Y], where 'x is the value for 'a and Y is the value for T.

§Returns

Returns the pair of:

  • the parameters for the impl ([Y], in our example)
  • the parameters for the associated type value (['a], in our example)
source

fn impl_parameters_and_projection_from_associated_ty_value<'p>( &self, parameters: &'p [GenericArg<I>], associated_ty_value: &AssociatedTyValue<I> ) -> (&'p [GenericArg<I>], ProjectionTy<I>)

Given the full set of parameters for an associated type value (which appears in an impl), returns the trait reference and projection that are being satisfied by that value.

§Example
impl<T> Iterable for Vec<T> {
    type Iter<'a>;
}

Here we expect the full set of parameters for Iter, which would be ['x, Y], where 'x is the value for 'a and Y is the value for T.

Returns the pair of:

  • the parameters that apply to the impl (Y, in our example)
  • the projection <Vec<Y> as Iterable>::Iter<'x>
source

fn split_associated_ty_parameters<'p, P>( &self, parameters: &'p [P], associated_ty_datum: &AssociatedTyDatum<I> ) -> (&'p [P], &'p [P])

Given the full set of parameters (or binders) for an associated type datum (the one appearing in a trait), splits them into the parameters for the trait and those for the associated type.

§Example
trait Foo<T> {
    type Assoc<'a>;
}

in this example, the full set of parameters would be ['x, Y], where 'x is the value for 'a and Y is the value for T.

§Returns

Returns the tuple of:

  • the parameters for the impl ([Y], in our example)
  • the parameters for the associated type value (['a], in our example)

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<DB: RustIrDatabase<I> + ?Sized, I: Interner> Split<I> for DB