diff options
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/attr.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/parse/comments.rs | 1 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 14 | ||||
| -rw-r--r-- | src/libsyntax/parse/token.rs | 14 |
4 files changed, 24 insertions, 9 deletions
diff --git a/src/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs index bc9f7e4b195..c9bea78d02d 100644 --- a/src/libsyntax/parse/attr.rs +++ b/src/libsyntax/parse/attr.rs @@ -45,7 +45,7 @@ impl ParserAttr for Parser { } token::DOC_COMMENT(s) => { let attr = ::attr::mk_sugared_doc_attr( - self.id_to_str(s), + self.id_to_interned_str(s), self.span.lo, self.span.hi ); @@ -133,7 +133,7 @@ impl ParserAttr for Parser { } token::DOC_COMMENT(s) => { self.bump(); - ::attr::mk_sugared_doc_attr(self.id_to_str(s), + ::attr::mk_sugared_doc_attr(self.id_to_interned_str(s), self.span.lo, self.span.hi) } diff --git a/src/libsyntax/parse/comments.rs b/src/libsyntax/parse/comments.rs index aa5e4e01ae0..21a34ab5e1e 100644 --- a/src/libsyntax/parse/comments.rs +++ b/src/libsyntax/parse/comments.rs @@ -54,7 +54,6 @@ pub fn doc_comment_style(comment: &str) -> ast::AttrStyle { } pub fn strip_doc_comment_decoration(comment: &str) -> ~str { - /// remove whitespace-only lines from the start/end of lines fn vertical_trim(lines: ~[~str]) -> ~[~str] { let mut i = 0u; diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 93264f5a6c6..636dc504ff2 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -345,7 +345,7 @@ pub struct Parser { /// extra detail when the same error is seen twice obsolete_set: HashSet<ObsoleteSyntax>, /// Used to determine the path to externally loaded source files - mod_path_stack: ~[@str], + mod_path_stack: ~[InternedString], /// Stack of spans of open delimiters. Used for error message. open_braces: ~[Span], /* do not copy the parser; its state is tied to outside state */ @@ -1408,8 +1408,12 @@ impl Parser { token::LIT_FLOAT(s, ft) => LitFloat(self.id_to_str(s), ft), token::LIT_FLOAT_UNSUFFIXED(s) => LitFloatUnsuffixed(self.id_to_str(s)), - token::LIT_STR(s) => LitStr(self.id_to_str(s), ast::CookedStr), - token::LIT_STR_RAW(s, n) => LitStr(self.id_to_str(s), ast::RawStr(n)), + token::LIT_STR(s) => { + LitStr(self.id_to_interned_str(s), ast::CookedStr) + } + token::LIT_STR_RAW(s, n) => { + LitStr(self.id_to_interned_str(s), ast::RawStr(n)) + } token::LPAREN => { self.expect(&token::RPAREN); LitNil }, _ => { self.unexpected_last(tok); } } @@ -4146,11 +4150,11 @@ impl Parser { } fn push_mod_path(&mut self, id: Ident, attrs: &[Attribute]) { - let default_path = token::interner_get(id.name); + let default_path = self.id_to_interned_str(id); let file_path = match ::attr::first_attr_value_str_by_name(attrs, "path") { Some(d) => d, - None => default_path + None => default_path, }; self.mod_path_stack.push(file_path) } 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); |
