@@ -330,8 +330,12 @@ impl<'tcx> Printer<'tcx> for SymbolMangler<'tcx> {
330330 ty:: Float ( FloatTy :: F128 ) => "C4f128" ,
331331 ty:: Never => "z" ,
332332
333- // Placeholders (should be demangled as `_`).
334- ty:: Param ( _) | ty:: Bound ( ..) | ty:: Placeholder ( _) | ty:: Infer ( _) | ty:: Error ( _) => "p" ,
333+ // Should only be encountered with polymorphization,
334+ // or within the identity-substituted impl header of an
335+ // item nested within an impl item.
336+ ty:: Param ( _) => "p" ,
337+
338+ ty:: Bound ( ..) | ty:: Placeholder ( _) | ty:: Infer ( _) | ty:: Error ( _) => bug ! ( ) ,
335339
336340 _ => "" ,
337341 } ;
@@ -416,12 +420,18 @@ impl<'tcx> Printer<'tcx> for SymbolMangler<'tcx> {
416420 // Mangle all nominal types as paths.
417421 ty:: Adt ( ty:: AdtDef ( Interned ( & ty:: AdtDefData { did : def_id, .. } , _) ) , args)
418422 | ty:: FnDef ( def_id, args)
419- | ty:: Alias ( ty:: Projection | ty:: Opaque , ty:: AliasTy { def_id, args, .. } )
420423 | ty:: Closure ( def_id, args)
421424 | ty:: CoroutineClosure ( def_id, args)
422425 | ty:: Coroutine ( def_id, args) => {
423426 self . print_def_path ( def_id, args) ?;
424427 }
428+
429+ // We may still encounter projections here due to the printing
430+ // logic sometimes passing identity-substituted impl headers.
431+ ty:: Alias ( ty:: Projection , ty:: AliasTy { def_id, args, .. } ) => {
432+ self . print_def_path ( def_id, args) ?;
433+ }
434+
425435 ty:: Foreign ( def_id) => {
426436 self . print_def_path ( def_id, & [ ] ) ?;
427437 }
@@ -467,8 +477,7 @@ impl<'tcx> Printer<'tcx> for SymbolMangler<'tcx> {
467477 r. print ( self ) ?;
468478 }
469479
470- ty:: Alias ( ty:: Inherent , _) => bug ! ( "symbol_names: unexpected inherent projection" ) ,
471- ty:: Alias ( ty:: Weak , _) => bug ! ( "symbol_names: unexpected weak projection" ) ,
480+ ty:: Alias ( ..) => bug ! ( "symbol_names: unexpected alias" ) ,
472481 ty:: CoroutineWitness ( ..) => bug ! ( "symbol_names: unexpected `CoroutineWitness`" ) ,
473482 }
474483
@@ -550,21 +559,26 @@ impl<'tcx> Printer<'tcx> for SymbolMangler<'tcx> {
550559 let ( ct_ty, valtree) = match ct. kind ( ) {
551560 ty:: ConstKind :: Value ( ty, val) => ( ty, val) ,
552561
553- // Placeholders (should be demangled as `_`).
554- // NOTE(eddyb) despite `Unevaluated` having a `DefId` (and therefore
555- // a path), even for it we still need to encode a placeholder, as
556- // the path could refer back to e.g. an `impl` using the constant.
557- ty:: ConstKind :: Unevaluated ( _)
558- | ty:: ConstKind :: Expr ( _)
559- | ty:: ConstKind :: Param ( _)
560- | ty:: ConstKind :: Infer ( _)
561- | ty:: ConstKind :: Bound ( ..)
562- | ty:: ConstKind :: Placeholder ( _)
563- | ty:: ConstKind :: Error ( _) => {
562+ // Should only be encountered with polymorphization,
563+ // or within the identity-substituted impl header of an
564+ // item nested within an impl item.
565+ ty:: ConstKind :: Param ( _) => {
564566 // Never cached (single-character).
565567 self . push ( "p" ) ;
566568 return Ok ( ( ) ) ;
567569 }
570+
571+ // We may still encounter unevaluated consts due to the printing
572+ // logic sometimes passing identity-substituted impl headers.
573+ ty:: Unevaluated ( ty:: UnevaluatedConst { def, args, .. } ) => {
574+ return self . print_def_path ( def, args) ;
575+ }
576+
577+ ty:: ConstKind :: Expr ( _)
578+ | ty:: ConstKind :: Infer ( _)
579+ | ty:: ConstKind :: Bound ( ..)
580+ | ty:: ConstKind :: Placeholder ( _)
581+ | ty:: ConstKind :: Error ( _) => bug ! ( ) ,
568582 } ;
569583
570584 if let Some ( & i) = self . consts . get ( & ct) {
0 commit comments