Skip to content

Commit 3c9e9d3

Browse files
pcwaltonhuonw
authored andcommitted
libsyntax: Remove ident_to_str from the parser, which was returning
`@str` values
1 parent cbf9f5f commit 3c9e9d3

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

src/libsyntax/parse/obsolete.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ use codemap::{Span, respan};
2222
use parse::parser::Parser;
2323
use parse::token;
2424

25-
use std::str;
2625
use std::to_bytes;
2726

2827
/// The specific types of unsupported syntax
@@ -178,7 +177,8 @@ impl ParserObsoleteMethods for Parser {
178177
fn is_obsolete_ident(&mut self, ident: &str) -> bool {
179178
match self.token {
180179
token::IDENT(sid, _) => {
181-
str::eq_slice(self.id_to_str(sid), ident)
180+
let interned_string = token::get_ident(sid.name);
181+
interned_string.equiv(&ident)
182182
}
183183
_ => false
184184
}

src/libsyntax/parse/parser.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -531,10 +531,11 @@ impl Parser {
531531
// otherwise, eat it.
532532
pub fn expect_keyword(&mut self, kw: keywords::Keyword) {
533533
if !self.eat_keyword(kw) {
534-
let id_str = self.id_to_str(kw.to_ident()).to_str();
534+
let id_ident = kw.to_ident();
535+
let id_interned_str = token::get_ident(id_ident.name);
535536
let token_str = self.this_token_to_str();
536537
self.fatal(format!("expected `{}`, found `{}`",
537-
id_str,
538+
id_interned_str.get(),
538539
token_str))
539540
}
540541
}
@@ -802,10 +803,6 @@ impl Parser {
802803
self.sess.span_diagnostic.handler().abort_if_errors();
803804
}
804805

805-
pub fn id_to_str(&mut self, id: Ident) -> @str {
806-
get_ident_interner().get(id.name)
807-
}
808-
809806
pub fn id_to_interned_str(&mut self, id: Ident) -> InternedString {
810807
get_ident(id.name)
811808
}
@@ -3440,7 +3437,9 @@ impl Parser {
34403437
loop {
34413438
match self.token {
34423439
token::LIFETIME(lifetime) => {
3443-
if "static" == self.id_to_str(lifetime) {
3440+
let lifetime_interned_string =
3441+
token::get_ident(lifetime.name);
3442+
if lifetime_interned_string.equiv(&("static")) {
34443443
result.push(RegionTyParamBound);
34453444
} else {
34463445
self.span_err(self.span,
@@ -4871,7 +4870,6 @@ impl Parser {
48714870

48724871
let first_ident = self.parse_ident();
48734872
let mut path = ~[first_ident];
4874-
debug!("parsed view path: {}", self.id_to_str(first_ident));
48754873
match self.token {
48764874
token::EQ => {
48774875
// x = foo::bar

0 commit comments

Comments
 (0)