@@ -1157,6 +1157,15 @@ impl<'a> LoweringContext<'a> {
1157
1157
match arg {
1158
1158
ast:: GenericArg :: Lifetime ( lt) => GenericArg :: Lifetime ( self . lower_lifetime ( & lt) ) ,
1159
1159
ast:: GenericArg :: Type ( ty) => GenericArg :: Type ( self . lower_ty_direct ( & ty, itctx) ) ,
1160
+ ast:: GenericArg :: Const ( ct) => {
1161
+ // FIXME(const_generics): const generics are not yet defined in the HIR.
1162
+ self . sess . struct_span_err (
1163
+ ct. value . span ,
1164
+ "const generics in any position are currently unsupported" ,
1165
+ ) . emit ( ) ;
1166
+ self . sess . abort_if_errors ( ) ;
1167
+ bug ! ( ) ;
1168
+ }
1160
1169
}
1161
1170
}
1162
1171
@@ -2441,7 +2450,7 @@ impl<'a> LoweringContext<'a> {
2441
2450
|this| this. lower_param_bounds ( & param. bounds , itctx. reborrow ( ) ) ,
2442
2451
) ;
2443
2452
2444
- match param. kind {
2453
+ let ( name , kind ) = match param. kind {
2445
2454
GenericParamKind :: Lifetime => {
2446
2455
let was_collecting_in_band = self . is_collecting_in_band_lifetimes ;
2447
2456
self . is_collecting_in_band_lifetimes = false ;
@@ -2457,22 +2466,14 @@ impl<'a> LoweringContext<'a> {
2457
2466
| hir:: LifetimeName :: Static => hir:: ParamName :: Plain ( lt. name . ident ( ) ) ,
2458
2467
hir:: LifetimeName :: Error => ParamName :: Error ,
2459
2468
} ;
2460
- let param = hir:: GenericParam {
2461
- id : lt. id ,
2462
- hir_id : lt. hir_id ,
2463
- name : param_name,
2464
- span : lt. span ,
2465
- pure_wrt_drop : attr:: contains_name ( & param. attrs , "may_dangle" ) ,
2466
- attrs : self . lower_attrs ( & param. attrs ) ,
2467
- bounds,
2468
- kind : hir:: GenericParamKind :: Lifetime {
2469
- kind : hir:: LifetimeParamKind :: Explicit ,
2470
- }
2469
+
2470
+ let kind = hir:: GenericParamKind :: Lifetime {
2471
+ kind : hir:: LifetimeParamKind :: Explicit
2471
2472
} ;
2472
2473
2473
2474
self . is_collecting_in_band_lifetimes = was_collecting_in_band;
2474
2475
2475
- param
2476
+ ( param_name , kind )
2476
2477
}
2477
2478
GenericParamKind :: Type { ref default, .. } => {
2478
2479
// Don't expose `Self` (recovered "keyword used as ident" parse error).
@@ -2491,27 +2492,41 @@ impl<'a> LoweringContext<'a> {
2491
2492
. chain ( params)
2492
2493
. collect ( ) ;
2493
2494
}
2494
- let LoweredNodeId { node_id, hir_id } = self . lower_node_id ( param. id ) ;
2495
2495
2496
- hir:: GenericParam {
2497
- id : node_id,
2498
- hir_id,
2499
- name : hir:: ParamName :: Plain ( ident) ,
2500
- pure_wrt_drop : attr:: contains_name ( & param. attrs , "may_dangle" ) ,
2501
- attrs : self . lower_attrs ( & param. attrs ) ,
2502
- bounds,
2503
- span : ident. span ,
2504
- kind : hir:: GenericParamKind :: Type {
2505
- default : default. as_ref ( ) . map ( |x| {
2506
- self . lower_ty ( x, ImplTraitContext :: disallowed ( ) )
2507
- } ) ,
2508
- synthetic : param. attrs . iter ( )
2509
- . filter ( |attr| attr. check_name ( "rustc_synthetic" ) )
2510
- . map ( |_| hir:: SyntheticTyParamKind :: ImplTrait )
2511
- . next ( ) ,
2512
- }
2513
- }
2496
+ let kind = hir:: GenericParamKind :: Type {
2497
+ default : default. as_ref ( ) . map ( |x| {
2498
+ self . lower_ty ( x, ImplTraitContext :: disallowed ( ) )
2499
+ } ) ,
2500
+ synthetic : param. attrs . iter ( )
2501
+ . filter ( |attr| attr. check_name ( "rustc_synthetic" ) )
2502
+ . map ( |_| hir:: SyntheticTyParamKind :: ImplTrait )
2503
+ . next ( ) ,
2504
+ } ;
2505
+
2506
+ ( hir:: ParamName :: Plain ( ident) , kind)
2514
2507
}
2508
+ GenericParamKind :: Const { .. } => {
2509
+ // FIXME(const_generics): const generics are not yet defined in the HIR.
2510
+ self . sess . struct_span_err (
2511
+ param. ident . span ,
2512
+ "const generics in any position are currently unsupported" ,
2513
+ ) . emit ( ) ;
2514
+ self . sess . abort_if_errors ( ) ;
2515
+ bug ! ( ) ;
2516
+ }
2517
+ } ;
2518
+
2519
+ let LoweredNodeId { node_id, hir_id } = self . lower_node_id ( param. id ) ;
2520
+
2521
+ hir:: GenericParam {
2522
+ id : node_id,
2523
+ hir_id,
2524
+ name,
2525
+ span : param. ident . span ,
2526
+ pure_wrt_drop : attr:: contains_name ( & param. attrs , "may_dangle" ) ,
2527
+ attrs : self . lower_attrs ( & param. attrs ) ,
2528
+ bounds,
2529
+ kind,
2515
2530
}
2516
2531
}
2517
2532
0 commit comments