@@ -1368,7 +1368,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1368
1368
modifier @ ( TraitBoundModifier :: None
1369
1369
| TraitBoundModifier :: MaybeConst
1370
1370
| TraitBoundModifier :: Negative ) ,
1371
- ) => Some ( this. lower_poly_trait_ref ( ty, itctx, modifier. to_constness ( ) ) ) ,
1371
+ ) => {
1372
+ Some ( this. lower_poly_trait_ref ( ty, itctx, modifier. to_constness ( ) ) )
1373
+ }
1372
1374
// `~const ?Bound` will cause an error during AST validation
1373
1375
// anyways, so treat it like `?Bound` as compilation proceeds.
1374
1376
GenericBound :: Trait (
@@ -2336,8 +2338,20 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
2336
2338
}
2337
2339
}
2338
2340
2339
- fn lower_trait_ref ( & mut self , constness : ast:: Const , p : & TraitRef , itctx : & ImplTraitContext ) -> hir:: TraitRef < ' hir > {
2340
- let path = match self . lower_qpath ( p. ref_id , & None , & p. path , ParamMode :: Explicit , itctx, Some ( constness) ) {
2341
+ fn lower_trait_ref (
2342
+ & mut self ,
2343
+ constness : ast:: Const ,
2344
+ p : & TraitRef ,
2345
+ itctx : & ImplTraitContext ,
2346
+ ) -> hir:: TraitRef < ' hir > {
2347
+ let path = match self . lower_qpath (
2348
+ p. ref_id ,
2349
+ & None ,
2350
+ & p. path ,
2351
+ ParamMode :: Explicit ,
2352
+ itctx,
2353
+ Some ( constness) ,
2354
+ ) {
2341
2355
hir:: QPath :: Resolved ( None , path) => path,
2342
2356
qpath => panic ! ( "lower_trait_ref: unexpected QPath `{qpath:?}`" ) ,
2343
2357
} ;
@@ -2353,7 +2367,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
2353
2367
) -> hir:: PolyTraitRef < ' hir > {
2354
2368
let bound_generic_params =
2355
2369
self . lower_lifetime_binder ( p. trait_ref . ref_id , & p. bound_generic_params ) ;
2356
- let trait_ref = self . lower_trait_ref ( constness, & p. trait_ref , itctx, ) ;
2370
+ let trait_ref = self . lower_trait_ref ( constness, & p. trait_ref , itctx) ;
2357
2371
hir:: PolyTraitRef { bound_generic_params, trait_ref, span : self . lower_span ( p. span ) }
2358
2372
}
2359
2373
@@ -2708,23 +2722,31 @@ struct GenericArgsCtor<'hir> {
2708
2722
2709
2723
impl < ' hir > GenericArgsCtor < ' hir > {
2710
2724
fn push_constness ( & mut self , lcx : & mut LoweringContext < ' _ , ' hir > , constness : ast:: Const ) {
2711
- let span = if let ast:: Const :: Yes ( sp) = constness {
2712
- sp
2713
- } else {
2714
- DUMMY_SP
2715
- } ;
2725
+ let span = if let ast:: Const :: Yes ( sp) = constness { sp } else { DUMMY_SP } ;
2716
2726
let id = lcx. next_node_id ( ) ;
2717
- lcx. lower_body ( |lcx| {
2718
- ( & [ ] , match constness {
2719
- ast:: Const :: Yes ( _) => lcx. expr_ident_mut ( span, Ident { name : sym:: host, span } , binding) ,
2720
- ast:: Const :: No => lcx. expr ( span, hir:: ExprKind :: Lit ( lcx. arena . alloc ( hir:: Lit { span, node : ast:: LitKind :: Bool ( true ) } ) ) ) ,
2721
- } )
2727
+ let hir_id = lcx. next_id ( ) ;
2728
+ let body = lcx. lower_body ( |lcx| {
2729
+ (
2730
+ & [ ] ,
2731
+ match constness {
2732
+ ast:: Const :: Yes ( _) => lcx. expr_ident_mut (
2733
+ span,
2734
+ Ident { name : sym:: host, span } ,
2735
+ lcx. host_param_id . unwrap ( ) ,
2736
+ ) ,
2737
+ ast:: Const :: No => lcx. expr (
2738
+ span,
2739
+ hir:: ExprKind :: Lit (
2740
+ lcx. arena . alloc ( hir:: Lit { span, node : ast:: LitKind :: Bool ( true ) } ) ,
2741
+ ) ,
2742
+ ) ,
2743
+ } ,
2744
+ )
2722
2745
} ) ;
2723
- let def = lcx. create_def ( lcx. current_hir_id_owner . def_id , id, DefPathData :: AnonConst , span) ;
2746
+ let def_id =
2747
+ lcx. create_def ( lcx. current_hir_id_owner . def_id , id, DefPathData :: AnonConst , span) ;
2724
2748
self . args . push ( hir:: GenericArg :: Const ( hir:: ConstArg {
2725
- value : hir:: AnonConst {
2726
- def_id,
2727
- } ,
2749
+ value : hir:: AnonConst { def_id, hir_id, body } ,
2728
2750
span,
2729
2751
} ) )
2730
2752
}
0 commit comments