@@ -256,15 +256,18 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> {
256256 // figure out which generic parameter it corresponds to and return
257257 // the relevant type.
258258 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) => {
260261 tcx. generics_of ( tcx. parent ( def_id) . unwrap ( ) )
261262 }
262263 Res :: Def ( _, def_id) => tcx. generics_of ( def_id) ,
263- Res :: Err => return tcx. types . err ,
264264 res => {
265265 tcx. sess . delay_span_bug (
266266 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+ ) ,
268271 ) ;
269272 return tcx. types . err ;
270273 }
@@ -284,7 +287,16 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> {
284287 . map ( |param| tcx. type_of ( param. def_id ) )
285288 // This is no generic parameter associated with the arg. This is
286289 // 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+ } )
288300 } else {
289301 tcx. sess . delay_span_bug (
290302 DUMMY_SP ,
0 commit comments