@@ -48,7 +48,7 @@ use triomphe::Arc;
4848
4949use crate :: {
5050 CallableDefId , FnAbi , ImplTraitId , MemoryMap , TraitEnvironment , consteval,
51- db:: { HirDatabase , InternedClosure } ,
51+ db:: { HirDatabase , InternedClosure , InternedCoroutine } ,
5252 generics:: generics,
5353 layout:: Layout ,
5454 mir:: pad16,
@@ -1389,33 +1389,6 @@ impl<'db> HirDisplay<'db> for Ty<'db> {
13891389 SizedByDefault :: Sized { anchor : krate } ,
13901390 ) ?;
13911391 }
1392- ImplTraitId :: AsyncBlockTypeImplTrait ( body, ..) => {
1393- let future_trait =
1394- LangItem :: Future . resolve_trait ( db, body. module ( db) . krate ( ) ) ;
1395- let output = future_trait. and_then ( |t| {
1396- t. trait_items ( db)
1397- . associated_type_by_name ( & Name :: new_symbol_root ( sym:: Output ) )
1398- } ) ;
1399- write ! ( f, "impl " ) ?;
1400- if let Some ( t) = future_trait {
1401- f. start_location_link ( t. into ( ) ) ;
1402- }
1403- write ! ( f, "Future" ) ?;
1404- if future_trait. is_some ( ) {
1405- f. end_location_link ( ) ;
1406- }
1407- write ! ( f, "<" ) ?;
1408- if let Some ( t) = output {
1409- f. start_location_link ( t. into ( ) ) ;
1410- }
1411- write ! ( f, "Output" ) ?;
1412- if output. is_some ( ) {
1413- f. end_location_link ( ) ;
1414- }
1415- write ! ( f, " = " ) ?;
1416- alias_ty. args . type_at ( 0 ) . hir_fmt ( f) ?;
1417- write ! ( f, ">" ) ?;
1418- }
14191392 }
14201393 }
14211394 TyKind :: Closure ( id, substs) => {
@@ -1567,23 +1540,56 @@ impl<'db> HirDisplay<'db> for Ty<'db> {
15671540 }
15681541 }
15691542 TyKind :: Infer ( ..) => write ! ( f, "_" ) ?,
1570- TyKind :: Coroutine ( _, subst) => {
1571- if f. display_kind . is_source_code ( ) {
1572- return Err ( HirDisplayError :: DisplaySourceCodeError (
1573- DisplaySourceCodeError :: Coroutine ,
1574- ) ) ;
1575- }
1543+ TyKind :: Coroutine ( coroutine_id, subst) => {
1544+ let InternedCoroutine ( owner, expr_id) = coroutine_id. 0 . loc ( db) ;
15761545 let CoroutineArgsParts { resume_ty, yield_ty, return_ty, .. } =
15771546 subst. split_coroutine_args ( ) ;
1578- write ! ( f, "|" ) ?;
1579- resume_ty. hir_fmt ( f) ?;
1580- write ! ( f, "|" ) ?;
1547+ let body = db. body ( owner) ;
1548+ match & body[ expr_id] {
1549+ hir_def:: hir:: Expr :: Async { .. } => {
1550+ let future_trait =
1551+ LangItem :: Future . resolve_trait ( db, owner. module ( db) . krate ( ) ) ;
1552+ let output = future_trait. and_then ( |t| {
1553+ t. trait_items ( db)
1554+ . associated_type_by_name ( & Name :: new_symbol_root ( sym:: Output ) )
1555+ } ) ;
1556+ write ! ( f, "impl " ) ?;
1557+ if let Some ( t) = future_trait {
1558+ f. start_location_link ( t. into ( ) ) ;
1559+ }
1560+ write ! ( f, "Future" ) ?;
1561+ if future_trait. is_some ( ) {
1562+ f. end_location_link ( ) ;
1563+ }
1564+ write ! ( f, "<" ) ?;
1565+ if let Some ( t) = output {
1566+ f. start_location_link ( t. into ( ) ) ;
1567+ }
1568+ write ! ( f, "Output" ) ?;
1569+ if output. is_some ( ) {
1570+ f. end_location_link ( ) ;
1571+ }
1572+ write ! ( f, " = " ) ?;
1573+ return_ty. hir_fmt ( f) ?;
1574+ write ! ( f, ">" ) ?;
1575+ }
1576+ _ => {
1577+ if f. display_kind . is_source_code ( ) {
1578+ return Err ( HirDisplayError :: DisplaySourceCodeError (
1579+ DisplaySourceCodeError :: Coroutine ,
1580+ ) ) ;
1581+ }
1582+ write ! ( f, "|" ) ?;
1583+ resume_ty. hir_fmt ( f) ?;
1584+ write ! ( f, "|" ) ?;
15811585
1582- write ! ( f, " yields " ) ?;
1583- yield_ty. hir_fmt ( f) ?;
1586+ write ! ( f, " yields " ) ?;
1587+ yield_ty. hir_fmt ( f) ?;
15841588
1585- write ! ( f, " -> " ) ?;
1586- return_ty. hir_fmt ( f) ?;
1589+ write ! ( f, " -> " ) ?;
1590+ return_ty. hir_fmt ( f) ?;
1591+ }
1592+ }
15871593 }
15881594 TyKind :: CoroutineWitness ( ..) => write ! ( f, "{{coroutine witness}}" ) ?,
15891595 TyKind :: Pat ( _, _) => write ! ( f, "{{pat}}" ) ?,
0 commit comments