@@ -174,7 +174,7 @@ enum ImplTraitContext<'a> {
174
174
/// We store a DefId here so we can look up necessary information later
175
175
///
176
176
/// Newly generated parameters should be inserted into the given `Vec`
177
- Universal ( DefId , & ' a mut Vec < hir:: TyParam > ) ,
177
+ Universal ( DefId , & ' a mut Vec < hir:: GenericParam > ) ,
178
178
179
179
/// Treat `impl Trait` as shorthand for a new universal existential parameter.
180
180
/// Example: `fn foo() -> impl Debug`, where `impl Debug` is conceptually
@@ -183,7 +183,7 @@ enum ImplTraitContext<'a> {
183
183
/// We store a DefId here so we can look up necessary information later
184
184
///
185
185
/// All generics of the surrounding function must go into the generated existential type
186
- Existential ( DefId , & ' a [ hir:: TyParam ] , & ' a hir:: Generics ) ,
186
+ Existential ( DefId , & ' a [ hir:: GenericParam ] , & ' a hir:: Generics ) ,
187
187
188
188
/// `impl Trait` is not accepted in this position.
189
189
Disallowed ,
@@ -656,7 +656,7 @@ impl<'a> LoweringContext<'a> {
656
656
f : F ,
657
657
) -> ( Vec < hir:: GenericParam > , T )
658
658
where
659
- F : FnOnce ( & mut LoweringContext ) -> ( Vec < hir:: TyParam > , T ) ,
659
+ F : FnOnce ( & mut LoweringContext ) -> ( Vec < hir:: GenericParam > , T ) ,
660
660
{
661
661
assert ! ( !self . is_collecting_in_band_lifetimes) ;
662
662
assert ! ( self . lifetimes_to_define. is_empty( ) ) ;
@@ -804,7 +804,7 @@ impl<'a> LoweringContext<'a> {
804
804
f : F ,
805
805
) -> ( hir:: Generics , T )
806
806
where
807
- F : FnOnce ( & mut LoweringContext , & mut Vec < hir:: TyParam > , & hir:: Generics ) -> T ,
807
+ F : FnOnce ( & mut LoweringContext , & mut Vec < hir:: GenericParam > , & hir:: Generics ) -> T ,
808
808
{
809
809
let ( in_band_defs, ( mut lowered_generics, res) ) = self . with_in_scope_lifetime_defs (
810
810
& generics. params ,
@@ -1045,7 +1045,7 @@ impl<'a> LoweringContext<'a> {
1045
1045
-> hir:: GenericArg {
1046
1046
match arg {
1047
1047
ast:: GenericArg :: Lifetime ( lt) => GenericArg :: Lifetime ( self . lower_lifetime ( & lt) ) ,
1048
- ast:: GenericArg :: Type ( ty) => GenericArg :: Type ( self . lower_ty ( & ty, itctx) ) ,
1048
+ ast:: GenericArg :: Type ( ty) => GenericArg :: Type ( self . lower_ty_direct ( & ty, itctx) ) ,
1049
1049
}
1050
1050
}
1051
1051
@@ -1175,7 +1175,7 @@ impl<'a> LoweringContext<'a> {
1175
1175
lctx. lower_param_bounds ( bounds, itctx)
1176
1176
} ) ;
1177
1177
1178
- let ( path_params , params ) = self . generics_from_impl_trait_bounds (
1178
+ let ( params , lifetimes ) = self . generics_from_impl_trait_bounds (
1179
1179
def_node_id,
1180
1180
exist_ty_def_index,
1181
1181
& hir_bounds,
@@ -1222,7 +1222,7 @@ impl<'a> LoweringContext<'a> {
1222
1222
id : exist_ty_id. node_id
1223
1223
} ,
1224
1224
DefId :: local ( exist_ty_def_index) ,
1225
- path_params . lifetimes ,
1225
+ lifetimes,
1226
1226
)
1227
1227
} )
1228
1228
}
@@ -1241,7 +1241,7 @@ impl<'a> LoweringContext<'a> {
1241
1241
) ;
1242
1242
// Set the name to `impl Bound1 + Bound2`
1243
1243
let name = Symbol :: intern ( & pprust:: ty_to_string ( t) ) ;
1244
- self . in_band_ty_params . push ( hir:: GenericParam {
1244
+ in_band_ty_params. push ( hir:: GenericParam {
1245
1245
id : def_node_id,
1246
1246
name : ParamName :: Plain ( name) ,
1247
1247
span,
@@ -1292,7 +1292,7 @@ impl<'a> LoweringContext<'a> {
1292
1292
exist_ty_id : NodeId ,
1293
1293
parent_index : DefIndex ,
1294
1294
bounds : & hir:: GenericBounds ,
1295
- ) -> ( hir:: PathParameters , HirVec < hir:: GenericParam > ) {
1295
+ ) -> ( HirVec < hir:: GenericParam > , HirVec < hir:: Lifetime > ) {
1296
1296
// This visitor walks over impl trait bounds and creates defs for all lifetimes which
1297
1297
// appear in the bounds, excluding lifetimes that are created within the bounds.
1298
1298
// e.g. 'a, 'b, but not 'c in `impl for<'c> SomeTrait<'a, 'b, 'c>`
@@ -1408,23 +1408,23 @@ impl<'a> LoweringContext<'a> {
1408
1408
lifetime. span ,
1409
1409
) ;
1410
1410
1411
- let name = match name {
1411
+ let ( in_band , name) = match name {
1412
1412
hir:: LifetimeName :: Underscore => {
1413
- hir:: ParamName :: Plain ( keywords:: UnderscoreLifetime . name ( ) )
1413
+ ( true , hir:: ParamName :: Plain ( keywords:: UnderscoreLifetime . name ( ) ) )
1414
1414
}
1415
- hir:: LifetimeName :: Param ( param_name) => param_name,
1415
+ hir:: LifetimeName :: Param ( param_name) => ( false , param_name) ,
1416
1416
_ => bug ! ( "expected LifetimeName::Param or ParamName::Plain" ) ,
1417
1417
} ;
1418
1418
1419
- self . output_lifetime_params . push ( hir:: GenericParam {
1419
+ self . output_params . push ( hir:: GenericParam {
1420
1420
id : def_node_id,
1421
1421
name,
1422
1422
span : lifetime. span ,
1423
1423
pure_wrt_drop : false ,
1424
1424
attrs : hir_vec ! [ ] ,
1425
1425
bounds : hir_vec ! [ ] ,
1426
1426
kind : hir:: GenericParamKind :: Lifetime {
1427
- in_band : false ,
1427
+ in_band,
1428
1428
}
1429
1429
} ) ;
1430
1430
}
@@ -1447,13 +1447,8 @@ impl<'a> LoweringContext<'a> {
1447
1447
}
1448
1448
1449
1449
(
1450
- hir:: PathParameters {
1451
- lifetimes : lifetime_collector. output_lifetimes . into ( ) ,
1452
- types : HirVec :: new ( ) ,
1453
- bindings : HirVec :: new ( ) ,
1454
- parenthesized : false ,
1455
- } ,
1456
1450
lifetime_collector. output_params . into ( ) ,
1451
+ lifetime_collector. output_lifetimes . into ( ) ,
1457
1452
)
1458
1453
}
1459
1454
@@ -1844,7 +1839,7 @@ impl<'a> LoweringContext<'a> {
1844
1839
fn lower_fn_decl (
1845
1840
& mut self ,
1846
1841
decl : & FnDecl ,
1847
- mut in_band_ty_params : Option < ( DefId , & mut Vec < hir:: TyParam > , & hir:: Generics ) > ,
1842
+ mut in_band_ty_params : Option < ( DefId , & mut Vec < hir:: GenericParam > , & hir:: Generics ) > ,
1848
1843
impl_trait_return_allow : bool ,
1849
1844
) -> P < hir:: FnDecl > {
1850
1845
// NOTE: The two last parameters here have to do with impl Trait. If fn_def_id is Some,
@@ -1943,15 +1938,19 @@ impl<'a> LoweringContext<'a> {
1943
1938
add_bounds : & NodeMap < Vec < GenericBound > > ,
1944
1939
mut itctx : ImplTraitContext ,
1945
1940
) -> hir:: HirVec < hir:: GenericParam > {
1946
- params. iter ( ) . map ( |param| self . lower_generic_param ( param, add_bounds, itctx) ) . collect ( )
1941
+ params. iter ( ) . map ( |param| self . lower_generic_param (
1942
+ param,
1943
+ add_bounds,
1944
+ itctx. reborrow ( ) ,
1945
+ ) ) . collect ( )
1947
1946
}
1948
1947
1949
1948
fn lower_generic_param ( & mut self ,
1950
1949
param : & GenericParam ,
1951
1950
add_bounds : & NodeMap < Vec < GenericBound > > ,
1952
- itctx : ImplTraitContext )
1951
+ mut itctx : ImplTraitContext )
1953
1952
-> hir:: GenericParam {
1954
- let mut bounds = self . lower_param_bounds ( & param. bounds , itctx) ;
1953
+ let mut bounds = self . lower_param_bounds ( & param. bounds , itctx. reborrow ( ) ) ;
1955
1954
match param. kind {
1956
1955
GenericParamKind :: Lifetime => {
1957
1956
let was_collecting_in_band = self . is_collecting_in_band_lifetimes ;
@@ -2809,8 +2808,8 @@ impl<'a> LoweringContext<'a> {
2809
2808
path_span : Span ,
2810
2809
path_segment : & ' v PathSegment ,
2811
2810
) {
2812
- if let Some ( ref p) = path_segment. parameters {
2813
- if let PathParameters :: Parenthesized ( ..) = * * p {
2811
+ if let Some ( ref p) = path_segment. args {
2812
+ if let GenericArgs :: Parenthesized ( ..) = * * p {
2814
2813
return ;
2815
2814
}
2816
2815
}
0 commit comments