Skip to content

Commit 353ea86

Browse files
committed
Add proper name mangling for pattern types
1 parent a7a1618 commit 353ea86

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
@@ -258,15 +258,16 @@ impl<'tcx> SymbolMangler<'tcx> {
258258
fn print_pat(&mut self, pat: ty::Pattern<'tcx>) -> Result<(), std::fmt::Error> {
259259
Ok(match *pat {
260260
ty::PatternKind::Range { start, end } => {
261-
let consts = [start, end];
262-
for ct in consts {
263-
Ty::new_array_with_const_len(self.tcx, self.tcx.types.unit, ct).print(self)?;
264-
}
261+
self.push("R");
262+
self.print_const(start)?;
263+
self.print_const(end)?;
265264
}
266265
ty::PatternKind::Or(patterns) => {
266+
self.push("O");
267267
for pat in patterns {
268268
self.print_pat(pat)?;
269269
}
270+
self.push("E");
270271
}
271272
})
272273
}
@@ -494,12 +495,9 @@ impl<'tcx> Printer<'tcx> for SymbolMangler<'tcx> {
494495
}
495496

496497
ty::Pat(ty, pat) => {
497-
// HACK: Represent as tuple until we have something better.
498-
// HACK: constants are used in arrays, even if the types don't match.
499-
self.push("T");
498+
self.push("W");
500499
ty.print(self)?;
501500
self.print_pat(pat)?;
502-
self.push("E");
503501
}
504502

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

tests/codegen-llvm/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)