@@ -1380,28 +1380,6 @@ impl FnDecl {
13801380 pub ( crate ) fn self_type ( & self ) -> Option < SelfTy > {
13811381 self . inputs . values . get ( 0 ) . and_then ( |v| v. to_self ( ) )
13821382 }
1383-
1384- /// Returns the sugared return type for an async function.
1385- ///
1386- /// For example, if the return type is `impl std::future::Future<Output = i32>`, this function
1387- /// will return `i32`.
1388- ///
1389- /// # Panics
1390- ///
1391- /// This function will panic if the return type does not match the expected sugaring for async
1392- /// functions.
1393- pub ( crate ) fn sugared_async_return_type ( & self ) -> Type {
1394- if let Type :: ImplTrait ( v) = & self . output &&
1395- let [ GenericBound :: TraitBound ( PolyTrait { trait_, .. } , _ ) ] = & v[ ..]
1396- {
1397- let bindings = trait_. bindings ( ) . unwrap ( ) ;
1398- let ret_ty = bindings[ 0 ] . term ( ) ;
1399- let ty = ret_ty. ty ( ) . expect ( "Unexpected constant return term" ) ;
1400- ty. clone ( )
1401- } else {
1402- panic ! ( "unexpected desugaring of async function" )
1403- }
1404- }
14051383}
14061384
14071385#[ derive( Clone , PartialEq , Eq , Debug , Hash ) ]
@@ -1613,6 +1591,28 @@ impl Type {
16131591 }
16141592 }
16151593
1594+ /// Returns the sugared return type for an async function.
1595+ ///
1596+ /// For example, if the return type is `impl std::future::Future<Output = i32>`, this function
1597+ /// will return `i32`.
1598+ ///
1599+ /// # Panics
1600+ ///
1601+ /// This function will panic if the return type does not match the expected sugaring for async
1602+ /// functions.
1603+ pub ( crate ) fn sugared_async_return_type ( & self ) -> Type {
1604+ if let Type :: ImplTrait ( v) = self &&
1605+ let [ GenericBound :: TraitBound ( PolyTrait { trait_, .. } , _ ) ] = & v[ ..]
1606+ {
1607+ let bindings = trait_. bindings ( ) . unwrap ( ) ;
1608+ let ret_ty = bindings[ 0 ] . term ( ) ;
1609+ let ty = ret_ty. ty ( ) . expect ( "unexpected constant in async fn return term" ) ;
1610+ ty. clone ( )
1611+ } else {
1612+ panic ! ( "unexpected async fn return type" )
1613+ }
1614+ }
1615+
16161616 /// Checks if this is a `T::Name` path for an associated type.
16171617 pub ( crate ) fn is_assoc_ty ( & self ) -> bool {
16181618 match self {
0 commit comments