about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorMatthias Krüger <476013+matthiaskrgr@users.noreply.github.com>2025-09-25 18:15:08 +0200
committerGitHub <noreply@github.com>2025-09-25 18:15:08 +0200
commit958d1438b6916ade1b89d8527c898254159685c3 (patch)
tree6de6a4b8942bf4eb2bd4b2815b37cff9904c6cd1 /compiler
parente3f762673241c2892951be3477b99753b68e41e1 (diff)
parent739e89980f2c5602851c9271fd61f7381007e87a (diff)
downloadrust-958d1438b6916ade1b89d8527c898254159685c3.tar.gz
rust-958d1438b6916ade1b89d8527c898254159685c3.zip
Rollup merge of #142401 - oli-obk:pattern-mango, r=petrochenkov
Add proper name mangling for pattern types

requires adding demangler support first https://github.com/rust-lang/rustc-demangle/pull/81

needed for https://github.com/rust-lang/rust/pull/136006#discussion_r2139792593 as otherwise we will have symbol collisions
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_symbol_mangling/src/v0.rs14
1 files changed, 6 insertions, 8 deletions
diff --git a/compiler/rustc_symbol_mangling/src/v0.rs b/compiler/rustc_symbol_mangling/src/v0.rs
index 9fa7e2f1003..d24924b424a 100644
--- a/compiler/rustc_symbol_mangling/src/v0.rs
+++ b/compiler/rustc_symbol_mangling/src/v0.rs
@@ -262,15 +262,16 @@ impl<'tcx> V0SymbolMangler<'tcx> {
     fn print_pat(&mut self, pat: ty::Pattern<'tcx>) -> Result<(), std::fmt::Error> {
         Ok(match *pat {
             ty::PatternKind::Range { start, end } => {
-                let consts = [start, end];
-                for ct in consts {
-                    Ty::new_array_with_const_len(self.tcx, self.tcx.types.unit, ct).print(self)?;
-                }
+                self.push("R");
+                self.print_const(start)?;
+                self.print_const(end)?;
             }
             ty::PatternKind::Or(patterns) => {
+                self.push("O");
                 for pat in patterns {
                     self.print_pat(pat)?;
                 }
+                self.push("E");
             }
         })
     }
@@ -498,12 +499,9 @@ impl<'tcx> Printer<'tcx> for V0SymbolMangler<'tcx> {
             }
 
             ty::Pat(ty, pat) => {
-                // HACK: Represent as tuple until we have something better.
-                // HACK: constants are used in arrays, even if the types don't match.
-                self.push("T");
+                self.push("W");
                 ty.print(self)?;
                 self.print_pat(pat)?;
-                self.push("E");
             }
 
             ty::Array(ty, len) => {