@@ -2283,8 +2283,12 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
22832283 // `ExprKind::Paren(ExprKind::Underscore)` and should also be lowered to `GenericArg::Infer`
22842284 match c. value . peel_parens ( ) . kind {
22852285 ExprKind :: Underscore => {
2286- let ct_kind = hir:: ConstArgKind :: Infer ( self . lower_span ( c. value . span ) , ( ) ) ;
2287- self . arena . alloc ( hir:: ConstArg { hir_id : self . lower_node_id ( c. id ) , kind : ct_kind } )
2286+ let ct_kind = hir:: ConstArgKind :: Infer ( ( ) ) ;
2287+ self . arena . alloc ( hir:: ConstArg {
2288+ hir_id : self . lower_node_id ( c. id ) ,
2289+ kind : ct_kind,
2290+ span : self . lower_span ( c. value . span ) ,
2291+ } )
22882292 }
22892293 _ => self . lower_anon_const_to_const_arg ( c) ,
22902294 }
@@ -2354,7 +2358,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
23542358 hir:: ConstArgKind :: Anon ( ct)
23552359 } ;
23562360
2357- self . arena . alloc ( hir:: ConstArg { hir_id : self . next_id ( ) , kind : ct_kind } )
2361+ self . arena . alloc ( hir:: ConstArg { hir_id : self . next_id ( ) , kind : ct_kind, span } )
23582362 }
23592363
23602364 fn lower_const_item_rhs (
@@ -2371,9 +2375,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
23712375 let const_arg = ConstArg {
23722376 hir_id : self . next_id ( ) ,
23732377 kind : hir:: ConstArgKind :: Error (
2374- DUMMY_SP ,
23752378 self . dcx ( ) . span_delayed_bug ( DUMMY_SP , "no block" ) ,
23762379 ) ,
2380+ span : DUMMY_SP ,
23772381 } ;
23782382 hir:: ConstItemRhs :: TypeConst ( self . arena . alloc ( const_arg) )
23792383 }
@@ -2392,7 +2396,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
23922396 "complex const arguments must be placed inside of a `const` block" ,
23932397 ) ;
23942398
2395- ConstArg { hir_id : this. next_id ( ) , kind : hir:: ConstArgKind :: Error ( expr. span , e. emit ( ) ) }
2399+ ConstArg {
2400+ hir_id : this. next_id ( ) ,
2401+ kind : hir:: ConstArgKind :: Error ( e. emit ( ) ) ,
2402+ span : expr. span ,
2403+ }
23962404 } ;
23972405
23982406 match & expr. kind {
@@ -2423,6 +2431,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
24232431 ConstArg {
24242432 hir_id : self . next_id ( ) ,
24252433 kind : hir:: ConstArgKind :: TupleCall ( qpath, lowered_args) ,
2434+ span : expr. span ,
24262435 }
24272436 }
24282437 ExprKind :: Tup ( exprs) => {
@@ -2440,7 +2449,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
24402449 & * self . arena . alloc ( expr)
24412450 } ) ) ;
24422451
2443- ConstArg { hir_id : self . next_id ( ) , kind : hir:: ConstArgKind :: Tup ( expr. span , exprs) }
2452+ ConstArg {
2453+ hir_id : self . next_id ( ) ,
2454+ kind : hir:: ConstArgKind :: Tup ( exprs) ,
2455+ span : expr. span ,
2456+ }
24442457 }
24452458 ExprKind :: Path ( qself, path) => {
24462459 let qpath = self . lower_qpath (
@@ -2454,7 +2467,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
24542467 None ,
24552468 ) ;
24562469
2457- ConstArg { hir_id : self . next_id ( ) , kind : hir:: ConstArgKind :: Path ( qpath) }
2470+ ConstArg {
2471+ hir_id : self . next_id ( ) ,
2472+ kind : hir:: ConstArgKind :: Path ( qpath) ,
2473+ span : expr. span ,
2474+ }
24582475 }
24592476 ExprKind :: Struct ( se) => {
24602477 let path = self . lower_qpath (
@@ -2495,11 +2512,16 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
24952512 } )
24962513 } ) ) ;
24972514
2498- ConstArg { hir_id : self . next_id ( ) , kind : hir:: ConstArgKind :: Struct ( path, fields) }
2515+ ConstArg {
2516+ hir_id : self . next_id ( ) ,
2517+ kind : hir:: ConstArgKind :: Struct ( path, fields) ,
2518+ span : expr. span ,
2519+ }
24992520 }
25002521 ExprKind :: Underscore => ConstArg {
25012522 hir_id : self . lower_node_id ( expr. id ) ,
2502- kind : hir:: ConstArgKind :: Infer ( expr. span , ( ) ) ,
2523+ kind : hir:: ConstArgKind :: Infer ( ( ) ) ,
2524+ span : expr. span ,
25032525 } ,
25042526 ExprKind :: Block ( block, _) => {
25052527 if let [ stmt] = block. stmts . as_slice ( )
@@ -2541,7 +2563,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
25412563 return match anon. mgca_disambiguation {
25422564 MgcaDisambiguation :: AnonConst => {
25432565 let lowered_anon = self . lower_anon_const_to_anon_const ( anon) ;
2544- ConstArg { hir_id : self . next_id ( ) , kind : hir:: ConstArgKind :: Anon ( lowered_anon) }
2566+ ConstArg {
2567+ hir_id : self . next_id ( ) ,
2568+ kind : hir:: ConstArgKind :: Anon ( lowered_anon) ,
2569+ span : lowered_anon. span ,
2570+ }
25452571 }
25462572 MgcaDisambiguation :: Direct => self . lower_expr_to_const_arg_direct ( & anon. value ) ,
25472573 } ;
@@ -2578,11 +2604,16 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
25782604 return ConstArg {
25792605 hir_id : self . lower_node_id ( anon. id ) ,
25802606 kind : hir:: ConstArgKind :: Path ( qpath) ,
2607+ span : expr. span ,
25812608 } ;
25822609 }
25832610
25842611 let lowered_anon = self . lower_anon_const_to_anon_const ( anon) ;
2585- ConstArg { hir_id : self . next_id ( ) , kind : hir:: ConstArgKind :: Anon ( lowered_anon) }
2612+ ConstArg {
2613+ hir_id : self . next_id ( ) ,
2614+ kind : hir:: ConstArgKind :: Anon ( lowered_anon) ,
2615+ span : expr. span ,
2616+ }
25862617 }
25872618
25882619 /// See [`hir::ConstArg`] for when to use this function vs
0 commit comments