about summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2014-01-31 16:42:33 -0800
committerHuon Wilson <dbau.pp+github@gmail.com>2014-02-02 01:44:49 +1100
commit8b8419293cb69d208a0d4f3a89dd01b0d394a6c6 (patch)
treecef113f731bbd16c556f52242191b744396a7e42 /src/libsyntax/parse
parent7a80fa647ad7f634c9626e7fed1caa618e1fd6cc (diff)
downloadrust-8b8419293cb69d208a0d4f3a89dd01b0d394a6c6.tar.gz
rust-8b8419293cb69d208a0d4f3a89dd01b0d394a6c6.zip
libsyntax: Remove `@str` from the interner
Diffstat (limited to 'src/libsyntax/parse')
-rw-r--r--src/libsyntax/parse/parser.rs3
-rw-r--r--src/libsyntax/parse/token.rs22
2 files changed, 14 insertions, 11 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 86913711801..dc16f32b872 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -3979,8 +3979,9 @@ impl Parser {
                 fields.push(self.parse_struct_decl_field());
             }
             if fields.len() == 0 {
+                let string = get_ident_interner().get(class_name.name);
                 self.fatal(format!("Unit-like struct definition should be written as `struct {};`",
-                                get_ident_interner().get(class_name.name)));
+                                   string.as_slice()));
             }
             self.bump();
         } else if self.token == token::LPAREN {
diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs
index 806c84c5553..eb2fa151f51 100644
--- a/src/libsyntax/parse/token.rs
+++ b/src/libsyntax/parse/token.rs
@@ -12,7 +12,7 @@ use ast;
 use ast::{P, Name, Mrk};
 use ast_util;
 use parse::token;
-use util::interner::StrInterner;
+use util::interner::{RcStr, StrInterner};
 use util::interner;
 
 use extra::serialize::{Decodable, Decoder, Encodable, Encoder};
@@ -214,8 +214,11 @@ pub fn to_str(input: @IdentInterner, t: &Token) -> ~str {
       }
 
       /* Name components */
-      IDENT(s, _) => input.get(s.name).to_owned(),
-      LIFETIME(s) => format!("'{}", input.get(s.name)),
+      IDENT(s, _) => input.get(s.name).into_owned(),
+      LIFETIME(s) => {
+          let name = input.get(s.name);
+          format!("'{}", name.as_slice())
+      }
       UNDERSCORE => ~"_",
 
       /* Other */
@@ -549,7 +552,7 @@ pub fn get_ident_interner() -> @IdentInterner {
 #[no_send]
 #[deriving(Clone, Eq, IterBytes, Ord, TotalEq, TotalOrd)]
 pub struct InternedString {
-    priv string: @str,
+    priv string: RcStr,
 }
 
 #[unsafe_destructor]
@@ -563,13 +566,12 @@ impl InternedString {
     #[inline]
     pub fn new(string: &'static str) -> InternedString {
         InternedString {
-            string: string.to_managed(),
+            string: RcStr::new(string),
         }
     }
 
-    // NB: Do not make this public. We are trying to remove `@str`.
     #[inline]
-    fn new_from_at_str(string: @str) -> InternedString {
+    fn new_from_rc_str(string: RcStr) -> InternedString {
         InternedString {
             string: string,
         }
@@ -594,7 +596,7 @@ impl BytesContainer for InternedString {
 
 impl fmt::Default for InternedString {
     fn fmt(obj: &InternedString, f: &mut fmt::Formatter) {
-        write!(f.buf, "{}", obj.string);
+        write!(f.buf, "{}", obj.string.as_slice());
     }
 }
 
@@ -613,7 +615,7 @@ impl<D:Decoder> Decodable<D> for InternedString {
 
 impl<E:Encoder> Encodable<E> for InternedString {
     fn encode(&self, e: &mut E) {
-        e.emit_str(self.string)
+        e.emit_str(self.string.as_slice())
     }
 }
 
@@ -622,7 +624,7 @@ impl<E:Encoder> Encodable<E> for InternedString {
 #[inline]
 pub fn get_ident(idx: Name) -> InternedString {
     let interner = get_ident_interner();
-    InternedString::new_from_at_str(interner.get(idx))
+    InternedString::new_from_rc_str(interner.get(idx))
 }
 
 /// Interns and returns the string contents of an identifier, using the