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

@@ -89,6 +89,12 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
Some(LangItem::Sized) => {
self.assemble_builtin_sized_candidate(obligation, &mut candidates);
}
Some(LangItem::MetaSized) => {
self.assemble_builtin_sized_candidate(obligation, &mut candidates);
}
Some(LangItem::PointeeSized) => {
self.assemble_builtin_sized_candidate(obligation, &mut candidates);
}
Some(LangItem::Unsize) => {
self.assemble_candidates_for_unsizing(obligation, &mut candidates);
}

View File

@@ -252,6 +252,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
let trait_def = obligation.predicate.def_id();
let conditions = match tcx.as_lang_item(trait_def) {
Some(LangItem::Sized) => self.sized_conditions(obligation),
Some(LangItem::MetaSized) => self.sized_conditions(obligation),
Some(LangItem::PointeeSized) => self.sized_conditions(obligation),
Some(LangItem::Copy | LangItem::Clone) => self.copy_clone_conditions(obligation),
Some(LangItem::FusedIterator) => self.fused_iterator_conditions(obligation),
other => bug!("unexpected builtin trait {trait_def:?} ({other:?})"),