trait_sel: {Meta,Pointee}Sized on Sized types

Introduce the `MetaSized` and `PointeeSized` traits as supertraits of
`Sized` and initially implement it on everything that currently
implements `Sized` to isolate any changes that simply adding the
traits introduces.
This commit is contained in:
David Wood
2025-01-16 11:30:39 +00:00
parent d9ca9bd014
commit d43da6f4de
15 changed files with 253 additions and 1 deletions

View File

@@ -212,6 +212,24 @@ where
goal: Goal<I, Self>,
) -> Result<Candidate<I>, NoSolution>;
/// A type is `MetaSized` if its tail component is `MetaSized`.
///
/// These components are given by built-in rules from
/// [`structural_traits::instantiate_constituent_tys_for_sized_trait`].
fn consider_builtin_meta_sized_candidate(
ecx: &mut EvalCtxt<'_, D>,
goal: Goal<I, Self>,
) -> Result<Candidate<I>, NoSolution>;
/// A type is `PointeeSized` if its tail component is `PointeeSized`.
///
/// These components are given by built-in rules from
/// [`structural_traits::instantiate_constituent_tys_for_sized_trait`].
fn consider_builtin_pointee_sized_candidate(
ecx: &mut EvalCtxt<'_, D>,
goal: Goal<I, Self>,
) -> Result<Candidate<I>, NoSolution>;
/// A type is `Copy` or `Clone` if its components are `Copy` or `Clone`.
///
/// These components are given by built-in rules from
@@ -467,6 +485,12 @@ where
} else {
match cx.as_lang_item(trait_def_id) {
Some(TraitSolverLangItem::Sized) => G::consider_builtin_sized_candidate(self, goal),
Some(TraitSolverLangItem::MetaSized) => {
G::consider_builtin_meta_sized_candidate(self, goal)
}
Some(TraitSolverLangItem::PointeeSized) => {
G::consider_builtin_pointee_sized_candidate(self, goal)
}
Some(TraitSolverLangItem::Copy | TraitSolverLangItem::Clone) => {
G::consider_builtin_copy_clone_candidate(self, goal)
}