1
Fork 0

Add GenericArgKind::as_{type,const,region}

This commit is contained in:
Maybe Waffle 2023-04-19 14:13:22 +00:00
parent d7f9e81650
commit 3f15521396
8 changed files with 88 additions and 98 deletions

View file

@ -67,10 +67,10 @@ impl<'a, 'tcx> VirtualIndex {
/// ref of the type.
fn expect_dyn_trait_in_self(ty: Ty<'_>) -> ty::PolyExistentialTraitRef<'_> {
for arg in ty.peel_refs().walk() {
if let GenericArgKind::Type(ty) = arg.unpack() {
if let ty::Dynamic(data, _, _) = ty.kind() {
return data.principal().expect("expected principal trait object");
}
if let GenericArgKind::Type(ty) = arg.unpack()
&& let ty::Dynamic(data, _, _) = ty.kind()
{
return data.principal().expect("expected principal trait object");
}
}