summary refs log tree commit diff
path: root/src/libsyntax/parse/token.rs
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2014-01-10 14:02:36 -0800
committerHuon Wilson <dbau.pp+github@gmail.com>2014-02-02 01:44:48 +1100
commit8e52b85d5a6f6e3aaa2f15d7c1e907d0ce8589ee (patch)
treeafcac214c65f792304926a71117ffdf37a0fd060 /src/libsyntax/parse/token.rs
parent70c5a0fbf784d6a89b1c2c50f9fe83093bd21abc (diff)
downloadrust-8e52b85d5a6f6e3aaa2f15d7c1e907d0ce8589ee.tar.gz
rust-8e52b85d5a6f6e3aaa2f15d7c1e907d0ce8589ee.zip
libsyntax: De-`@str` literal strings in the AST
Diffstat (limited to 'src/libsyntax/parse/token.rs')
-rw-r--r--src/libsyntax/parse/token.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs
index 97b9b4d53a4..9291cba54f6 100644
--- a/src/libsyntax/parse/token.rs
+++ b/src/libsyntax/parse/token.rs
@@ -20,6 +20,7 @@ use std::cast;
 use std::char;
 use std::fmt;
 use std::local_data;
+use std::path::BytesContainer;
 
 #[allow(non_camel_case_types)]
 #[deriving(Clone, Encodable, Decodable, Eq, IterBytes)]
@@ -537,7 +538,7 @@ pub fn get_ident_interner() -> @IdentInterner {
 /// be fixed in the future by just leaking all strings until task death
 /// somehow.
 #[no_send]
-#[deriving(Clone, Eq, IterBytes, TotalEq, TotalOrd)]
+#[deriving(Clone, Eq, IterBytes, Ord, TotalEq, TotalOrd)]
 pub struct InternedString {
     priv string: @str,
 }
@@ -571,6 +572,17 @@ impl InternedString {
     }
 }
 
+impl BytesContainer for InternedString {
+    fn container_as_bytes<'a>(&'a self) -> &'a [u8] {
+        // XXX(pcwalton): This is a workaround for the incorrect signature of
+        // `BytesContainer`, which is itself a workaround for the lack of DST.
+        unsafe {
+            let this = self.get();
+            cast::transmute(this.container_as_bytes())
+        }
+    }
+}
+
 impl fmt::Default for InternedString {
     fn fmt(obj: &InternedString, f: &mut fmt::Formatter) {
         write!(f.buf, "{}", obj.string);