@@ -1368,7 +1368,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
13681368 modifier @ ( TraitBoundModifier :: None
13691369 | TraitBoundModifier :: MaybeConst
13701370 | 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+ }
13721374 // `~const ?Bound` will cause an error during AST validation
13731375 // anyways, so treat it like `?Bound` as compilation proceeds.
13741376 GenericBound :: Trait (
@@ -2336,8 +2338,20 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
23362338 }
23372339 }
23382340
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+ ) {
23412355 hir:: QPath :: Resolved ( None , path) => path,
23422356 qpath => panic ! ( "lower_trait_ref: unexpected QPath `{qpath:?}`" ) ,
23432357 } ;
@@ -2353,7 +2367,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
23532367 ) -> hir:: PolyTraitRef < ' hir > {
23542368 let bound_generic_params =
23552369 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) ;
23572371 hir:: PolyTraitRef { bound_generic_params, trait_ref, span : self . lower_span ( p. span ) }
23582372 }
23592373
@@ -2708,23 +2722,31 @@ struct GenericArgsCtor<'hir> {
27082722
27092723impl < ' hir > GenericArgsCtor < ' hir > {
27102724 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 } ;
27162726 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+ )
27222745 } ) ;
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) ;
27242748 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 } ,
27282750 span,
27292751 } ) )
27302752 }
0 commit comments