Skip to content

Commit f4d1fb5

Browse files
Do not expect aliases/infer/bound/placeholder/error in v0 symbol mangling
1 parent 46b0f8b commit f4d1fb5

File tree

1 file changed

+15
-16
lines changed
  • compiler/rustc_symbol_mangling/src

1 file changed

+15
-16
lines changed

compiler/rustc_symbol_mangling/src/v0.rs

+15-16
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,10 @@ 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+
ty::Param(_) => "p",
335+
336+
ty::Bound(..) | ty::Placeholder(_) | ty::Infer(_) | ty::Error(_) => bug!(),
335337

336338
_ => "",
337339
};
@@ -416,7 +418,6 @@ impl<'tcx> Printer<'tcx> for SymbolMangler<'tcx> {
416418
// Mangle all nominal types as paths.
417419
ty::Adt(ty::AdtDef(Interned(&ty::AdtDefData { did: def_id, .. }, _)), args)
418420
| ty::FnDef(def_id, args)
419-
| ty::Alias(ty::Projection | ty::Opaque, ty::AliasTy { def_id, args, .. })
420421
| ty::Closure(def_id, args)
421422
| ty::CoroutineClosure(def_id, args)
422423
| ty::Coroutine(def_id, args) => {
@@ -467,8 +468,7 @@ impl<'tcx> Printer<'tcx> for SymbolMangler<'tcx> {
467468
r.print(self)?;
468469
}
469470

470-
ty::Alias(ty::Inherent, _) => bug!("symbol_names: unexpected inherent projection"),
471-
ty::Alias(ty::Weak, _) => bug!("symbol_names: unexpected weak projection"),
471+
ty::Alias(..) => bug!("symbol_names: unexpected unnormalized alias"),
472472
ty::CoroutineWitness(..) => bug!("symbol_names: unexpected `CoroutineWitness`"),
473473
}
474474

@@ -550,21 +550,20 @@ impl<'tcx> Printer<'tcx> for SymbolMangler<'tcx> {
550550
let (ct_ty, valtree) = match ct.kind() {
551551
ty::ConstKind::Value(ty, val) => (ty, val),
552552

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(_) => {
553+
// Should only be encountered with polymorphization.
554+
ty::ConstKind::Param(_) => {
564555
// Never cached (single-character).
565556
self.push("p");
566557
return Ok(());
567558
}
559+
560+
ty::Unevaluated(..) => bug!("symbol_names: unexpected unnormalized alias"),
561+
562+
ty::ConstKind::Expr(_)
563+
| ty::ConstKind::Infer(_)
564+
| ty::ConstKind::Bound(..)
565+
| ty::ConstKind::Placeholder(_)
566+
| ty::ConstKind::Error(_) => bug!(),
568567
};
569568

570569
if let Some(&i) = self.consts.get(&ct) {

0 commit comments

Comments
 (0)