@@ -25,7 +25,7 @@ use rustc_data_structures::unord::UnordMap;
2525use rustc_errors:: {
2626 Applicability , Diag , DiagCtxtHandle , E0228 , ErrorGuaranteed , StashKey , struct_span_code_err,
2727} ;
28- use rustc_hir:: def:: DefKind ;
28+ use rustc_hir:: def:: { DefKind , Res } ;
2929use rustc_hir:: def_id:: { DefId , LocalDefId } ;
3030use rustc_hir:: intravisit:: { self , Visitor , walk_generics} ;
3131use rustc_hir:: { self as hir, GenericParamKind , Node } ;
@@ -85,7 +85,7 @@ pub fn provide(providers: &mut Providers) {
8585 coroutine_kind,
8686 coroutine_for_closure,
8787 opaque_ty_origin,
88- rendered_precise_capturing_args ,
88+ opt_precise_capturing_args ,
8989 ..* providers
9090 } ;
9191}
@@ -1865,20 +1865,38 @@ fn opaque_ty_origin<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> hir::OpaqueT
18651865 }
18661866}
18671867
1868- fn rendered_precise_capturing_args < ' tcx > (
1868+ fn opt_precise_capturing_args < ' tcx > (
18691869 tcx : TyCtxt < ' tcx > ,
18701870 def_id : LocalDefId ,
1871- ) -> Option < & ' tcx [ Symbol ] > {
1871+ ) -> Option < ty :: EarlyBinder < ' tcx , & ' tcx [ ty :: GenericArg < ' tcx > ] > > {
18721872 if let Some ( ty:: ImplTraitInTraitData :: Trait { opaque_def_id, .. } ) =
18731873 tcx. opt_rpitit_info ( def_id. to_def_id ( ) )
18741874 {
1875- return tcx. rendered_precise_capturing_args ( opaque_def_id) ;
1875+ return tcx. opt_precise_capturing_args ( opaque_def_id) ;
18761876 }
18771877
1878+ let icx = ItemCtxt :: new ( tcx, def_id) ;
1879+
18781880 tcx. hir_node_by_def_id ( def_id) . expect_item ( ) . expect_opaque_ty ( ) . bounds . iter ( ) . find_map (
18791881 |bound| match bound {
18801882 hir:: GenericBound :: Use ( args, ..) => {
1881- Some ( & * tcx. arena . alloc_from_iter ( args. iter ( ) . map ( |arg| arg. name ( ) ) ) )
1883+ Some ( ty:: EarlyBinder :: bind ( & * tcx. arena . alloc_from_iter ( args. iter ( ) . map ( |arg| {
1884+ match arg {
1885+ hir:: PreciseCapturingArg :: Lifetime ( lt) => icx
1886+ . lowerer ( )
1887+ . lower_lifetime ( * lt, RegionInferReason :: OutlivesBound )
1888+ . into ( ) ,
1889+ hir:: PreciseCapturingArg :: Param ( arg) => match arg. res {
1890+ Res :: Def ( DefKind :: TyParam , _) => {
1891+ icx. lowerer ( ) . lower_ty_param ( arg. hir_id ) . into ( )
1892+ }
1893+ Res :: Def ( DefKind :: ConstParam , _) => {
1894+ icx. lowerer ( ) . lower_const_param ( arg. hir_id ) . into ( )
1895+ }
1896+ _ => unreachable ! ( ) ,
1897+ } ,
1898+ }
1899+ } ) ) ) )
18821900 }
18831901 _ => None ,
18841902 } ,
0 commit comments