@@ -25,7 +25,7 @@ use rustc_data_structures::unord::UnordMap;
25
25
use rustc_errors:: {
26
26
Applicability , Diag , DiagCtxtHandle , E0228 , ErrorGuaranteed , StashKey , struct_span_code_err,
27
27
} ;
28
- use rustc_hir:: def:: DefKind ;
28
+ use rustc_hir:: def:: { DefKind , Res } ;
29
29
use rustc_hir:: def_id:: { DefId , LocalDefId } ;
30
30
use rustc_hir:: intravisit:: { self , Visitor , walk_generics} ;
31
31
use rustc_hir:: { self as hir, GenericParamKind , Node } ;
@@ -85,7 +85,7 @@ pub fn provide(providers: &mut Providers) {
85
85
coroutine_kind,
86
86
coroutine_for_closure,
87
87
opaque_ty_origin,
88
- rendered_precise_capturing_args ,
88
+ opt_precise_capturing_args ,
89
89
..* providers
90
90
} ;
91
91
}
@@ -1865,20 +1865,38 @@ fn opaque_ty_origin<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> hir::OpaqueT
1865
1865
}
1866
1866
}
1867
1867
1868
- fn rendered_precise_capturing_args < ' tcx > (
1868
+ fn opt_precise_capturing_args < ' tcx > (
1869
1869
tcx : TyCtxt < ' tcx > ,
1870
1870
def_id : LocalDefId ,
1871
- ) -> Option < & ' tcx [ Symbol ] > {
1871
+ ) -> Option < ty :: EarlyBinder < ' tcx , & ' tcx [ ty :: GenericArg < ' tcx > ] > > {
1872
1872
if let Some ( ty:: ImplTraitInTraitData :: Trait { opaque_def_id, .. } ) =
1873
1873
tcx. opt_rpitit_info ( def_id. to_def_id ( ) )
1874
1874
{
1875
- return tcx. rendered_precise_capturing_args ( opaque_def_id) ;
1875
+ return tcx. opt_precise_capturing_args ( opaque_def_id) ;
1876
1876
}
1877
1877
1878
+ let icx = ItemCtxt :: new ( tcx, def_id) ;
1879
+
1878
1880
tcx. hir_node_by_def_id ( def_id) . expect_item ( ) . expect_opaque_ty ( ) . bounds . iter ( ) . find_map (
1879
1881
|bound| match bound {
1880
1882
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
+ } ) ) ) )
1882
1900
}
1883
1901
_ => None ,
1884
1902
} ,
0 commit comments