diff options
Diffstat (limited to 'src/libsyntax/parse/token.rs')
| -rw-r--r-- | src/libsyntax/parse/token.rs | 14 |
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); |
