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§
sourcefn split_projection<'p>(
&self,
projection: &'p ProjectionTy<I>,
) -> (Arc<AssociatedTyDatum<I>>, &'p [GenericArg<I>], &'p [GenericArg<I>])
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.
sourcefn trait_parameters_from_projection<'p>(
&self,
projection: &'p ProjectionTy<I>,
) -> &'p [GenericArg<I>]
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
).
sourcefn trait_ref_from_projection(&self, projection: &ProjectionTy<I>) -> TraitRef<I>
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
).
sourcefn split_associated_ty_value_parameters<'p, P>(
&self,
parameters: &'p [P],
associated_ty_value: &AssociatedTyValue<I>,
) -> (&'p [P], &'p [P])
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)
sourcefn 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 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>
sourcefn split_associated_ty_parameters<'p, P>(
&self,
parameters: &'p [P],
associated_ty_datum: &AssociatedTyDatum<I>,
) -> (&'p [P], &'p [P])
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)