@@ -1178,14 +1178,17 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
11781178 tokens : None ,
11791179 } ;
11801180
1181- let ct = self . with_new_scopes ( span, |this| hir:: AnonConst {
1182- def_id,
1183- hir_id : this. lower_node_id ( node_id) ,
1184- body : this. lower_const_body ( path_expr. span , Some ( & path_expr) ) ,
1181+ let ct = self . with_new_scopes ( span, |this| {
1182+ self . arena . alloc ( hir:: AnonConst {
1183+ def_id,
1184+ hir_id : this. lower_node_id ( node_id) ,
1185+ body : this
1186+ . lower_const_body ( path_expr. span , Some ( & path_expr) ) ,
1187+ span,
1188+ } )
11851189 } ) ;
11861190 return GenericArg :: Const ( ConstArg {
11871191 value : ct,
1188- span,
11891192 is_desugared_from_effects : false ,
11901193 } ) ;
11911194 }
@@ -1197,7 +1200,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
11971200 }
11981201 ast:: GenericArg :: Const ( ct) => GenericArg :: Const ( ConstArg {
11991202 value : self . lower_anon_const ( ct) ,
1200- span : self . lower_span ( ct. value . span ) ,
12011203 is_desugared_from_effects : false ,
12021204 } ) ,
12031205 }
@@ -2315,7 +2317,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
23152317 }
23162318
23172319 #[ allow( rustc:: untranslatable_diagnostic) ] // FIXME: make this translatable
2318- fn lower_array_length ( & mut self , c : & AnonConst ) -> hir:: ArrayLen {
2320+ fn lower_array_length ( & mut self , c : & AnonConst ) -> hir:: ArrayLen < ' hir > {
23192321 match c. value . kind {
23202322 ExprKind :: Underscore => {
23212323 if self . tcx . features ( ) . generic_arg_infer {
@@ -2338,12 +2340,13 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
23382340 }
23392341 }
23402342
2341- fn lower_anon_const ( & mut self , c : & AnonConst ) -> hir:: AnonConst {
2342- self . with_new_scopes ( c. value . span , |this| hir:: AnonConst {
2343+ fn lower_anon_const ( & mut self , c : & AnonConst ) -> & ' hir hir:: AnonConst {
2344+ self . arena . alloc ( self . with_new_scopes ( c. value . span , |this| hir:: AnonConst {
23432345 def_id : this. local_def_id ( c. id ) ,
23442346 hir_id : this. lower_node_id ( c. id ) ,
23452347 body : this. lower_const_body ( c. value . span , Some ( & c. value ) ) ,
2346- } )
2348+ span : this. lower_span ( c. value . span ) ,
2349+ } ) )
23472350 }
23482351
23492352 fn lower_unsafe_source ( & mut self , u : UnsafeSource ) -> hir:: UnsafeSource {
@@ -2650,8 +2653,7 @@ impl<'hir> GenericArgsCtor<'hir> {
26502653
26512654 lcx. children . push ( ( def_id, hir:: MaybeOwner :: NonOwner ( hir_id) ) ) ;
26522655 self . args . push ( hir:: GenericArg :: Const ( hir:: ConstArg {
2653- value : hir:: AnonConst { def_id, hir_id, body } ,
2654- span,
2656+ value : lcx. arena . alloc ( hir:: AnonConst { def_id, hir_id, body, span } ) ,
26552657 is_desugared_from_effects : true ,
26562658 } ) )
26572659 }
0 commit comments