@@ -1604,14 +1604,16 @@ impl Type {
1604
1604
///
1605
1605
/// This function will panic if the return type does not match the expected sugaring for async
1606
1606
/// functions.
1607
- pub ( crate ) fn sugared_async_return_type ( & self ) -> Type {
1608
- if let Type :: ImplTrait ( v) = self &&
1609
- let [ GenericBound :: TraitBound ( PolyTrait { trait_, .. } , _ ) ] = & v[ ..]
1607
+ pub ( crate ) fn sugared_async_return_type ( self ) -> Type {
1608
+ if let Type :: ImplTrait ( mut v) = self
1609
+ && let Some ( GenericBound :: TraitBound ( PolyTrait { mut trait_, .. } , _ ) ) = v. pop ( )
1610
+ && let Some ( segment) = trait_. segments . pop ( )
1611
+ && let GenericArgs :: AngleBracketed { mut bindings, .. } = segment. args
1612
+ && let Some ( binding) = bindings. pop ( )
1613
+ && let TypeBindingKind :: Equality { term } = binding. kind
1614
+ && let Term :: Type ( ty) = term
1610
1615
{
1611
- let bindings = trait_. bindings ( ) . unwrap ( ) ;
1612
- let ret_ty = bindings[ 0 ] . term ( ) ;
1613
- let ty = ret_ty. ty ( ) . expect ( "unexpected constant in async fn return term" ) ;
1614
- ty. clone ( )
1616
+ ty
1615
1617
} else {
1616
1618
panic ! ( "unexpected async fn return type" )
1617
1619
}
@@ -2189,16 +2191,6 @@ impl Path {
2189
2191
}
2190
2192
} )
2191
2193
}
2192
-
2193
- pub ( crate ) fn bindings ( & self ) -> Option < & [ TypeBinding ] > {
2194
- self . segments . last ( ) . and_then ( |seg| {
2195
- if let GenericArgs :: AngleBracketed { ref bindings, .. } = seg. args {
2196
- Some ( & * * bindings)
2197
- } else {
2198
- None
2199
- }
2200
- } )
2201
- }
2202
2194
}
2203
2195
2204
2196
#[ derive( Clone , PartialEq , Eq , Debug , Hash ) ]
@@ -2478,15 +2470,6 @@ pub(crate) enum TypeBindingKind {
2478
2470
Constraint { bounds : Vec < GenericBound > } ,
2479
2471
}
2480
2472
2481
- impl TypeBinding {
2482
- pub ( crate ) fn term ( & self ) -> & Term {
2483
- match self . kind {
2484
- TypeBindingKind :: Equality { ref term } => term,
2485
- _ => panic ! ( "expected equality type binding for parenthesized generic args" ) ,
2486
- }
2487
- }
2488
- }
2489
-
2490
2473
/// The type, lifetime, or constant that a private type alias's parameter should be
2491
2474
/// replaced with when expanding a use of that type alias.
2492
2475
///
0 commit comments