about summary refs log tree commit diff
path: root/src/librustc/back/link.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/librustc/back/link.rs')
-rw-r--r--src/librustc/back/link.rs44
1 files changed, 24 insertions, 20 deletions
diff --git a/src/librustc/back/link.rs b/src/librustc/back/link.rs
index 01ad3507b83..af23696cbc1 100644
--- a/src/librustc/back/link.rs
+++ b/src/librustc/back/link.rs
@@ -19,6 +19,7 @@ use lib;
 use metadata::common::LinkMeta;
 use metadata::{encoder, csearch, cstore};
 use middle::trans::context::CrateContext;
+use middle::trans::common::gensym_name;
 use middle::ty;
 use util::ppaux;
 
@@ -37,6 +38,7 @@ use syntax::ast;
 use syntax::ast_map::{path, path_mod, path_name};
 use syntax::attr;
 use syntax::print::pprust;
+use syntax::parse::token;
 
 #[deriving(Eq)]
 pub enum output_type {
@@ -640,15 +642,15 @@ pub fn sanitize(s: &str) -> ~str {
     for s.iter().advance |c| {
         match c {
             // Escape these with $ sequences
-            '@' => result += "$SP$",
-            '~' => result += "$UP$",
-            '*' => result += "$RP$",
-            '&' => result += "$BP$",
-            '<' => result += "$LT$",
-            '>' => result += "$GT$",
-            '(' => result += "$LP$",
-            ')' => result += "$RP$",
-            ',' => result += "$C$",
+            '@' => result.push_str("$SP$"),
+            '~' => result.push_str("$UP$"),
+            '*' => result.push_str("$RP$"),
+            '&' => result.push_str("$BP$"),
+            '<' => result.push_str("$LT$"),
+            '>' => result.push_str("$GT$"),
+            '(' => result.push_str("$LP$"),
+            ')' => result.push_str("$RP$"),
+            ',' => result.push_str("$C$"),
 
             // '.' doesn't occur in types and functions, so reuse it
             // for ':'
@@ -684,12 +686,14 @@ pub fn mangle(sess: Session, ss: path) -> ~str {
     let mut n = ~"_ZN"; // Begin name-sequence.
 
     for ss.iter().advance |s| {
-        match *s { path_name(s) | path_mod(s) => {
-          let sani = sanitize(sess.str_of(s));
-          n += fmt!("%u%s", sani.len(), sani);
-        } }
+        match *s {
+            path_name(s) | path_mod(s) => {
+                let sani = sanitize(sess.str_of(s));
+                n.push_str(fmt!("%u%s", sani.len(), sani));
+            }
+        }
     }
-    n += "E"; // End name-sequence.
+    n.push_char('E'); // End name-sequence.
     n
 }
 
@@ -731,22 +735,22 @@ pub fn mangle_internal_name_by_type_and_seq(ccx: &mut CrateContext,
     return mangle(ccx.sess,
         ~[path_name(ccx.sess.ident_of(s)),
           path_name(ccx.sess.ident_of(hash)),
-          path_name((ccx.names)(name))]);
+          path_name(gensym_name(name))]);
 }
 
 pub fn mangle_internal_name_by_path_and_seq(ccx: &mut CrateContext,
-                                            path: path,
+                                            mut path: path,
                                             flav: &str) -> ~str {
-    mangle(ccx.sess,
-           vec::append_one(path, path_name((ccx.names)(flav))))
+    path.push(path_name(gensym_name(flav)));
+    mangle(ccx.sess, path)
 }
 
 pub fn mangle_internal_name_by_path(ccx: &mut CrateContext, path: path) -> ~str {
     mangle(ccx.sess, path)
 }
 
-pub fn mangle_internal_name_by_seq(ccx: &mut CrateContext, flav: &str) -> ~str {
-    fmt!("%s_%u", flav, (ccx.names)(flav).name)
+pub fn mangle_internal_name_by_seq(_ccx: &mut CrateContext, flav: &str) -> ~str {
+    return fmt!("%s_%u", flav, token::gensym(flav));
 }