@@ -181,7 +181,7 @@ enum ImplTraitContext<'a> {
181
181
/// We store a DefId here so we can look up necessary information later
182
182
///
183
183
/// All generics of the surrounding function must go into the generated existential type
184
- Existential ( DefId , & ' a [ hir:: TyParam ] ) ,
184
+ Existential ( DefId , & ' a [ hir:: TyParam ] , & ' a hir :: Generics ) ,
185
185
186
186
/// `impl Trait` is not accepted in this position.
187
187
Disallowed ,
@@ -192,7 +192,7 @@ impl<'a> ImplTraitContext<'a> {
192
192
use self :: ImplTraitContext :: * ;
193
193
match self {
194
194
Universal ( did, params) => Universal ( * did, params) ,
195
- Existential ( did, params) => Existential ( * did, params) ,
195
+ Existential ( did, params, generics ) => Existential ( * did, params, generics ) ,
196
196
Disallowed => Disallowed ,
197
197
}
198
198
}
@@ -809,7 +809,7 @@ impl<'a> LoweringContext<'a> {
809
809
f : F ,
810
810
) -> ( hir:: Generics , T )
811
811
where
812
- F : FnOnce ( & mut LoweringContext , & mut Vec < hir:: TyParam > ) -> T ,
812
+ F : FnOnce ( & mut LoweringContext , & mut Vec < hir:: TyParam > , & hir :: Generics ) -> T ,
813
813
{
814
814
let ( in_band_defs, ( mut lowered_generics, res) ) = self . with_in_scope_lifetime_defs (
815
815
generics. params . iter ( ) . filter_map ( |p| match p {
@@ -823,7 +823,7 @@ impl<'a> LoweringContext<'a> {
823
823
generics,
824
824
ImplTraitContext :: Universal ( parent_id, & mut params) ,
825
825
) ;
826
- let res = f ( this, & mut params) ;
826
+ let res = f ( this, & mut params, & generics ) ;
827
827
( params, ( generics, res) )
828
828
} )
829
829
} ,
@@ -1142,7 +1142,7 @@ impl<'a> LoweringContext<'a> {
1142
1142
TyKind :: ImplTrait ( exist_ty_node_id, ref bounds) => {
1143
1143
let span = t. span ;
1144
1144
match itctx {
1145
- ImplTraitContext :: Existential ( fn_def_id, _) => {
1145
+ ImplTraitContext :: Existential ( fn_def_id, _, _ ) => {
1146
1146
// Make sure we know that some funky desugaring has been going on here.
1147
1147
// This is a first: there is code in other places like for loop
1148
1148
// desugaring that explicitly states that we don't want to track that.
@@ -1848,7 +1848,7 @@ impl<'a> LoweringContext<'a> {
1848
1848
fn lower_fn_decl (
1849
1849
& mut self ,
1850
1850
decl : & FnDecl ,
1851
- mut in_band_ty_params : Option < ( DefId , & mut Vec < hir:: TyParam > ) > ,
1851
+ mut in_band_ty_params : Option < ( DefId , & mut Vec < hir:: TyParam > , & hir :: Generics ) > ,
1852
1852
impl_trait_return_allow : bool ,
1853
1853
) -> P < hir:: FnDecl > {
1854
1854
// NOTE: The two last parameters here have to do with impl Trait. If fn_def_id is Some,
@@ -1862,7 +1862,7 @@ impl<'a> LoweringContext<'a> {
1862
1862
inputs : decl. inputs
1863
1863
. iter ( )
1864
1864
. map ( |arg| {
1865
- if let Some ( ( def_id, ibty) ) = in_band_ty_params. as_mut ( ) {
1865
+ if let Some ( ( def_id, ibty, _ ) ) = in_band_ty_params. as_mut ( ) {
1866
1866
self . lower_ty ( & arg. ty , ImplTraitContext :: Universal ( * def_id, ibty) )
1867
1867
} else {
1868
1868
self . lower_ty ( & arg. ty , ImplTraitContext :: Disallowed )
@@ -1871,8 +1871,12 @@ impl<'a> LoweringContext<'a> {
1871
1871
. collect ( ) ,
1872
1872
output : match decl. output {
1873
1873
FunctionRetTy :: Ty ( ref ty) => match in_band_ty_params {
1874
- Some ( ( def_id, ref mut ibty) ) if impl_trait_return_allow => {
1875
- hir:: Return ( self . lower_ty ( ty, ImplTraitContext :: Existential ( def_id, ibty) ) )
1874
+ Some ( ( def_id, ref mut ibty, generics) ) if impl_trait_return_allow => {
1875
+ hir:: Return ( self . lower_ty ( ty, ImplTraitContext :: Existential (
1876
+ def_id,
1877
+ ibty,
1878
+ generics,
1879
+ ) ) )
1876
1880
}
1877
1881
_ => hir:: Return ( self . lower_ty ( ty, ImplTraitContext :: Disallowed ) ) ,
1878
1882
} ,
@@ -2321,7 +2325,11 @@ impl<'a> LoweringContext<'a> {
2321
2325
generics,
2322
2326
fn_def_id,
2323
2327
AnonymousLifetimeMode :: PassThrough ,
2324
- |this, idty| this. lower_fn_decl ( decl, Some ( ( fn_def_id, idty) ) , true ) ,
2328
+ |this, idty, generics| this. lower_fn_decl (
2329
+ decl,
2330
+ Some ( ( fn_def_id, idty, generics) ) ,
2331
+ true ,
2332
+ ) ,
2325
2333
) ;
2326
2334
2327
2335
hir:: ItemFn (
@@ -2393,7 +2401,7 @@ impl<'a> LoweringContext<'a> {
2393
2401
ast_generics,
2394
2402
def_id,
2395
2403
AnonymousLifetimeMode :: CreateParameter ,
2396
- |this, _| {
2404
+ |this, _, _ | {
2397
2405
let trait_ref = trait_ref. as_ref ( ) . map ( |trait_ref| {
2398
2406
this. lower_trait_ref ( trait_ref, ImplTraitContext :: Disallowed )
2399
2407
} ) ;
@@ -2891,7 +2899,7 @@ impl<'a> LoweringContext<'a> {
2891
2899
generics,
2892
2900
def_id,
2893
2901
AnonymousLifetimeMode :: PassThrough ,
2894
- |this, _| {
2902
+ |this, _, _ | {
2895
2903
(
2896
2904
// Disallow impl Trait in foreign items
2897
2905
this. lower_fn_decl ( fdec, None , false ) ,
@@ -2926,9 +2934,9 @@ impl<'a> LoweringContext<'a> {
2926
2934
generics,
2927
2935
fn_def_id,
2928
2936
AnonymousLifetimeMode :: PassThrough ,
2929
- |this, idty| this. lower_fn_decl (
2937
+ |this, idty, generics | this. lower_fn_decl (
2930
2938
& sig. decl ,
2931
- Some ( ( fn_def_id, idty) ) ,
2939
+ Some ( ( fn_def_id, idty, generics ) ) ,
2932
2940
impl_trait_return_allow,
2933
2941
) ,
2934
2942
) ;
0 commit comments