1
Fork 0

Rollup merge of #110545 - WaffleLapkin:generic_arg_as_x, r=cjgillot

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

This allows to make code nicer in some cases
This commit is contained in:
Matthias Krüger 2023-04-20 14:36:54 +02:00 committed by GitHub
commit 17f6763a14
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 84 additions and 110 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");
}
}