Skip to content

Commit ed3f028

Browse files
Add TyKind::TyAlias support in rustc_symbol_mangling
1 parent 61705b3 commit ed3f028

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,12 @@ fn encode_ty<'tcx>(
641641
typeid.push_str(&s);
642642
}
643643

644+
ty::TyAlias(def_id, substs) => {
645+
let binder_ty = tcx.bound_type_of(*def_id);
646+
let ty = binder_ty.subst(tcx, substs);
647+
return encode_ty(tcx, ty, dict, options);
648+
}
649+
644650
// Unexpected types
645651
ty::Bound(..)
646652
| ty::Error(..)
@@ -795,6 +801,12 @@ fn transform_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, options: TransformTyOptio
795801
}
796802
}
797803

804+
ty::TyAlias(def_id, substs) => {
805+
let binder_ty = tcx.bound_type_of(*def_id);
806+
let ty = binder_ty.subst(tcx, substs);
807+
return transform_ty(tcx, ty, options);
808+
}
809+
798810
ty::Bound(..)
799811
| ty::Error(..)
800812
| ty::GeneratorWitness(..)

compiler/rustc_symbol_mangling/src/v0.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,8 @@ impl<'tcx> Printer<'tcx> for &mut SymbolMangler<'tcx> {
387387
}
388388
let start = self.out.len();
389389

390+
let ty = self.tcx.peel_off_ty_alias(ty);
391+
390392
match *ty.kind() {
391393
// Basic types, handled above.
392394
ty::Bool | ty::Char | ty::Str | ty::Int(_) | ty::Uint(_) | ty::Float(_) | ty::Never => {
@@ -439,9 +441,9 @@ impl<'tcx> Printer<'tcx> for &mut SymbolMangler<'tcx> {
439441
// Mangle all nominal types as paths.
440442
ty::Adt(ty::AdtDef(Interned(&ty::AdtDefData { did: def_id, .. }, _)), substs)
441443
| ty::FnDef(def_id, substs)
444+
| ty::Closure(def_id, substs)
442445
| ty::Opaque(def_id, substs)
443446
| ty::Projection(ty::ProjectionTy { item_def_id: def_id, substs })
444-
| ty::Closure(def_id, substs)
445447
| ty::Generator(def_id, substs, _) => {
446448
self = self.print_def_path(def_id, substs)?;
447449
}
@@ -490,6 +492,8 @@ impl<'tcx> Printer<'tcx> for &mut SymbolMangler<'tcx> {
490492
}
491493

492494
ty::GeneratorWitness(_) => bug!("symbol_names: unexpected `GeneratorWitness`"),
495+
496+
ty::TyAlias(..) => bug!("symbol_names: unexpected projection"),
493497
}
494498

495499
// Only cache types that do not refer to an enclosing

0 commit comments

Comments
 (0)