@@ -24,7 +24,7 @@ fn anon_const_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> {
2424 let hir_id = tcx. local_def_id_to_hir_id ( def_id) ;
2525
2626 let node = tcx. hir_node ( hir_id) ;
27- let Node :: AnonConst ( _ ) = node else {
27+ let Node :: AnonConst ( & AnonConst { span , .. } ) = node else {
2828 span_bug ! (
2929 tcx. def_span( def_id) ,
3030 "expected anon const in `anon_const_type_of`, got {node:?}"
@@ -134,7 +134,7 @@ fn anon_const_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> {
134134 // I dont think it's possible to reach this but I'm not 100% sure - BoxyUwU
135135 return Ty :: new_error_with_message (
136136 tcx,
137- tcx . def_span ( def_id ) ,
137+ span ,
138138 "unexpected non-GAT usage of an anon const" ,
139139 ) ;
140140 }
@@ -152,7 +152,7 @@ fn anon_const_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> {
152152 let Some ( type_dependent_def) = tables. type_dependent_def_id ( parent_node_id) else {
153153 return Ty :: new_error_with_message (
154154 tcx,
155- tcx . def_span ( def_id ) ,
155+ span ,
156156 format ! ( "unable to find type-dependent def for {parent_node_id:?}" ) ,
157157 ) ;
158158 } ;
@@ -194,15 +194,15 @@ fn anon_const_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> {
194194 } else {
195195 return Ty :: new_error_with_message (
196196 tcx,
197- tcx . def_span ( def_id ) ,
197+ span ,
198198 format ! ( "unable to find const parent for {hir_id} in pat {pat:?}" ) ,
199199 ) ;
200200 }
201201 }
202202 _ => {
203203 return Ty :: new_error_with_message (
204204 tcx,
205- tcx . def_span ( def_id ) ,
205+ span ,
206206 format ! ( "unexpected const parent path {parent_node:?}" ) ,
207207 ) ;
208208 }
@@ -226,19 +226,15 @@ fn anon_const_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> {
226226 . map ( |idx| ( idx, seg) )
227227 } )
228228 } ) else {
229- return Ty :: new_error_with_message (
230- tcx,
231- tcx. def_span ( def_id) ,
232- "no arg matching AnonConst in path" ,
233- ) ;
229+ return Ty :: new_error_with_message ( tcx, span, "no arg matching AnonConst in path" ) ;
234230 } ;
235231
236232 let generics = match tcx. res_generics_def_id ( segment. res ) {
237233 Some ( def_id) => tcx. generics_of ( def_id) ,
238234 None => {
239235 return Ty :: new_error_with_message (
240236 tcx,
241- tcx . def_span ( def_id ) ,
237+ span ,
242238 format ! ( "unexpected anon const res {:?} in path: {:?}" , segment. res, path) ,
243239 ) ;
244240 }
@@ -250,7 +246,7 @@ fn anon_const_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> {
250246 _ => {
251247 return Ty :: new_error_with_message (
252248 tcx,
253- tcx . def_span ( def_id ) ,
249+ span ,
254250 format ! ( "unexpected const parent in type_of(): {parent_node:?}" ) ,
255251 ) ;
256252 }
@@ -278,7 +274,7 @@ fn anon_const_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> {
278274 } else {
279275 return Ty :: new_error_with_message (
280276 tcx,
281- tcx . def_span ( def_id ) ,
277+ span ,
282278 format ! ( "const generic parameter not found in {generics:?} at position {arg_idx:?}" ) ,
283279 ) ;
284280 }
0 commit comments