@@ -330,8 +330,12 @@ impl<'tcx> Printer<'tcx> for SymbolMangler<'tcx> {
330
330
ty:: Float ( FloatTy :: F128 ) => "C4f128" ,
331
331
ty:: Never => "z" ,
332
332
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 ! ( ) ,
335
339
336
340
_ => "" ,
337
341
} ;
@@ -416,12 +420,18 @@ impl<'tcx> Printer<'tcx> for SymbolMangler<'tcx> {
416
420
// Mangle all nominal types as paths.
417
421
ty:: Adt ( ty:: AdtDef ( Interned ( & ty:: AdtDefData { did : def_id, .. } , _) ) , args)
418
422
| ty:: FnDef ( def_id, args)
419
- | ty:: Alias ( ty:: Projection | ty:: Opaque , ty:: AliasTy { def_id, args, .. } )
420
423
| ty:: Closure ( def_id, args)
421
424
| ty:: CoroutineClosure ( def_id, args)
422
425
| ty:: Coroutine ( def_id, args) => {
423
426
self . print_def_path ( def_id, args) ?;
424
427
}
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
+
425
435
ty:: Foreign ( def_id) => {
426
436
self . print_def_path ( def_id, & [ ] ) ?;
427
437
}
@@ -467,8 +477,7 @@ impl<'tcx> Printer<'tcx> for SymbolMangler<'tcx> {
467
477
r. print ( self ) ?;
468
478
}
469
479
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" ) ,
472
481
ty:: CoroutineWitness ( ..) => bug ! ( "symbol_names: unexpected `CoroutineWitness`" ) ,
473
482
}
474
483
@@ -550,21 +559,26 @@ impl<'tcx> Printer<'tcx> for SymbolMangler<'tcx> {
550
559
let ( ct_ty, valtree) = match ct. kind ( ) {
551
560
ty:: ConstKind :: Value ( ty, val) => ( ty, val) ,
552
561
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 ( _) => {
564
566
// Never cached (single-character).
565
567
self . push ( "p" ) ;
566
568
return Ok ( ( ) ) ;
567
569
}
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 ! ( ) ,
568
582
} ;
569
583
570
584
if let Some ( & i) = self . consts . get ( & ct) {
0 commit comments