@@ -256,15 +256,18 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> {
256
256
// figure out which generic parameter it corresponds to and return
257
257
// the relevant type.
258
258
let generics = match path. res {
259
- Res :: Def ( DefKind :: Ctor ( ..) , def_id) => {
259
+ Res :: Def ( DefKind :: Ctor ( ..) , def_id)
260
+ | Res :: Def ( DefKind :: AssocTy , def_id) => {
260
261
tcx. generics_of ( tcx. parent ( def_id) . unwrap ( ) )
261
262
}
262
263
Res :: Def ( _, def_id) => tcx. generics_of ( def_id) ,
263
- Res :: Err => return tcx. types . err ,
264
264
res => {
265
265
tcx. sess . delay_span_bug (
266
266
DUMMY_SP ,
267
- & format ! ( "unexpected const parent path def {:?}" , res, ) ,
267
+ & format ! (
268
+ "unexpected const parent path def, parent: {:?}, def: {:?}" ,
269
+ parent_node, res
270
+ ) ,
268
271
) ;
269
272
return tcx. types . err ;
270
273
}
@@ -284,7 +287,16 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> {
284
287
. map ( |param| tcx. type_of ( param. def_id ) )
285
288
// This is no generic parameter associated with the arg. This is
286
289
// probably from an extra arg where one is not needed.
287
- . unwrap_or ( tcx. types . err )
290
+ . unwrap_or_else ( || {
291
+ tcx. sess . delay_span_bug (
292
+ DUMMY_SP ,
293
+ & format ! (
294
+ "missing generic parameter for `AnonConst`, parent {:?}" ,
295
+ parent_node
296
+ ) ,
297
+ ) ;
298
+ tcx. types . err
299
+ } )
288
300
} else {
289
301
tcx. sess . delay_span_bug (
290
302
DUMMY_SP ,
0 commit comments