@@ -24,7 +24,7 @@ fn anon_const_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> {
24
24
let hir_id = tcx. local_def_id_to_hir_id ( def_id) ;
25
25
26
26
let node = tcx. hir_node ( hir_id) ;
27
- let Node :: AnonConst ( _ ) = node else {
27
+ let Node :: AnonConst ( & AnonConst { span , .. } ) = node else {
28
28
span_bug ! (
29
29
tcx. def_span( def_id) ,
30
30
"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> {
134
134
// I dont think it's possible to reach this but I'm not 100% sure - BoxyUwU
135
135
return Ty :: new_error_with_message (
136
136
tcx,
137
- tcx . def_span ( def_id ) ,
137
+ span ,
138
138
"unexpected non-GAT usage of an anon const" ,
139
139
) ;
140
140
}
@@ -152,7 +152,7 @@ fn anon_const_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> {
152
152
let Some ( type_dependent_def) = tables. type_dependent_def_id ( parent_node_id) else {
153
153
return Ty :: new_error_with_message (
154
154
tcx,
155
- tcx . def_span ( def_id ) ,
155
+ span ,
156
156
format ! ( "unable to find type-dependent def for {parent_node_id:?}" ) ,
157
157
) ;
158
158
} ;
@@ -194,15 +194,15 @@ fn anon_const_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> {
194
194
} else {
195
195
return Ty :: new_error_with_message (
196
196
tcx,
197
- tcx . def_span ( def_id ) ,
197
+ span ,
198
198
format ! ( "unable to find const parent for {hir_id} in pat {pat:?}" ) ,
199
199
) ;
200
200
}
201
201
}
202
202
_ => {
203
203
return Ty :: new_error_with_message (
204
204
tcx,
205
- tcx . def_span ( def_id ) ,
205
+ span ,
206
206
format ! ( "unexpected const parent path {parent_node:?}" ) ,
207
207
) ;
208
208
}
@@ -226,19 +226,15 @@ fn anon_const_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> {
226
226
. map ( |idx| ( idx, seg) )
227
227
} )
228
228
} ) 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" ) ;
234
230
} ;
235
231
236
232
let generics = match tcx. res_generics_def_id ( segment. res ) {
237
233
Some ( def_id) => tcx. generics_of ( def_id) ,
238
234
None => {
239
235
return Ty :: new_error_with_message (
240
236
tcx,
241
- tcx . def_span ( def_id ) ,
237
+ span ,
242
238
format ! ( "unexpected anon const res {:?} in path: {:?}" , segment. res, path) ,
243
239
) ;
244
240
}
@@ -250,7 +246,7 @@ fn anon_const_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> {
250
246
_ => {
251
247
return Ty :: new_error_with_message (
252
248
tcx,
253
- tcx . def_span ( def_id ) ,
249
+ span ,
254
250
format ! ( "unexpected const parent in type_of(): {parent_node:?}" ) ,
255
251
) ;
256
252
}
@@ -278,7 +274,7 @@ fn anon_const_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> {
278
274
} else {
279
275
return Ty :: new_error_with_message (
280
276
tcx,
281
- tcx . def_span ( def_id ) ,
277
+ span ,
282
278
format ! ( "const generic parameter not found in {generics:?} at position {arg_idx:?}" ) ,
283
279
) ;
284
280
}
0 commit comments