1
Fork 0

opaque types may also be sized

This commit is contained in:
Michael Goulet 2022-02-13 19:57:23 -08:00
parent ef0ba1d2ce
commit 1d834cb657
3 changed files with 37 additions and 13 deletions

View file

@ -2282,19 +2282,18 @@ impl<'tcx> Ty<'tcx> {
ty::Str | ty::Slice(_) => (tcx.types.usize, false),
ty::Dynamic(..) => {
let dyn_metadata = tcx.lang_items().dyn_metadata().unwrap();
(tcx.type_of(dyn_metadata).subst(tcx, &[self.into()]), false)
(tcx.type_of(dyn_metadata).subst(tcx, &[tail.into()]), false)
},
// type parameters only have unit metadata if they're sized, so return true
// to make sure we double check this during confirmation
ty::Param(_) | ty::Projection(_) => (tcx.types.unit, true),
ty::Param(_) | ty::Projection(_) | ty::Opaque(..) => (tcx.types.unit, true),
ty::Opaque(..)
| ty::Infer(ty::TyVar(_))
ty::Infer(ty::TyVar(_))
| ty::Bound(..)
| ty::Placeholder(..)
| ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => {
bug!("`ptr_metadata_ty` applied to unexpected type: {:?}", self)
bug!("`ptr_metadata_ty` applied to unexpected type: {:?} (tail = {:?})", self, tail)
}
}
}