Skip to content

Commit 714c550

Browse files
committed
Add proper name mangling for pattern types
1 parent 1c04750 commit 714c550

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

compiler/rustc_symbol_mangling/src/v0.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -262,15 +262,16 @@ impl<'tcx> SymbolMangler<'tcx> {
262262
fn print_pat(&mut self, pat: ty::Pattern<'tcx>) -> Result<(), std::fmt::Error> {
263263
Ok(match *pat {
264264
ty::PatternKind::Range { start, end } => {
265-
let consts = [start, end];
266-
for ct in consts {
267-
Ty::new_array_with_const_len(self.tcx, self.tcx.types.unit, ct).print(self)?;
268-
}
265+
self.push("R");
266+
self.print_const(start)?;
267+
self.print_const(end)?;
269268
}
270269
ty::PatternKind::Or(patterns) => {
270+
self.push("O");
271271
for pat in patterns {
272272
self.print_pat(pat)?;
273273
}
274+
self.push("E");
274275
}
275276
})
276277
}
@@ -498,12 +499,9 @@ impl<'tcx> Printer<'tcx> for SymbolMangler<'tcx> {
498499
}
499500

500501
ty::Pat(ty, pat) => {
501-
// HACK: Represent as tuple until we have something better.
502-
// HACK: constants are used in arrays, even if the types don't match.
503-
self.push("T");
502+
self.push("W");
504503
ty.print(self)?;
505504
self.print_pat(pat)?;
506-
self.push("E");
507505
}
508506

509507
ty::Array(ty, len) => {

tests/codegen/pattern_type_symbols.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub fn bar() {
1616
// CHECK: call pattern_type_symbols::foo::<u32>
1717
// CHECK: call void @_RINvC[[CRATE_IDENT:[a-zA-Z0-9]{12}]]_20pattern_type_symbols3foomEB2_
1818
foo::<u32>();
19-
// CHECK: call pattern_type_symbols::foo::<(u32, [(); 0], [(); 999999999])>
20-
// CHECK: call void @_RINvC[[CRATE_IDENT]]_20pattern_type_symbols3fooTmAum0_Aum3b9ac9ff_EEB2_
19+
// CHECK: call pattern_type_symbols::foo::<u32 is 0..=999999999>
20+
// CHECK: call void @_RINvC[[CRATE_IDENT]]_20pattern_type_symbols3fooWmRm0_m3b9ac9ff_EB2_
2121
foo::<NanoU32>();
2222
}

0 commit comments

Comments
 (0)