Skip to content

Commit d2f8fb0

Browse files
committed
Move syntax::util::interner -> syntax::symbol, cleanup.
1 parent f177a00 commit d2f8fb0

File tree

102 files changed

+752
-806
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+752
-806
lines changed

src/libproc_macro_plugin/qquote.rs

+28-24
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ use syntax::codemap::Span;
3434
use syntax::ext::base::*;
3535
use syntax::ext::base;
3636
use syntax::ext::proc_macro_shim::build_block_emitter;
37-
use syntax::parse::token::{self, Token, gensym_ident, str_to_ident};
37+
use syntax::parse::token::{self, Token};
3838
use syntax::print::pprust;
39+
use syntax::symbol::Symbol;
3940
use syntax::tokenstream::{TokenTree, TokenStream};
4041

4142
// ____________________________________________________________________________________________
@@ -124,7 +125,7 @@ fn qquote_iter<'cx>(cx: &'cx mut ExtCtxt, depth: i64, ts: TokenStream) -> (Bindi
124125
} // produce an error or something first
125126
let exp = vec![exp.unwrap().to_owned()];
126127
debug!("RHS: {:?}", exp.clone());
127-
let new_id = gensym_ident("tmp");
128+
let new_id = Ident::with_empty_ctxt(Symbol::gensym("tmp"));
128129
debug!("RHS TS: {:?}", TokenStream::from_tts(exp.clone()));
129130
debug!("RHS TS TT: {:?}", TokenStream::from_tts(exp.clone()).to_vec());
130131
bindings.push((new_id, TokenStream::from_tts(exp)));
@@ -179,7 +180,7 @@ fn unravel_concats(tss: Vec<TokenStream>) -> TokenStream {
179180
};
180181

181182
while let Some(ts) = pushes.pop() {
182-
output = build_fn_call(str_to_ident("concat"),
183+
output = build_fn_call(Ident::from_str("concat"),
183184
concat(concat(ts,
184185
from_tokens(vec![Token::Comma])),
185186
output));
@@ -209,18 +210,19 @@ fn convert_complex_tts<'cx>(cx: &'cx mut ExtCtxt, tts: Vec<QTT>) -> (Bindings, T
209210
// FIXME handle sequence repetition tokens
210211
QTT::QDL(qdl) => {
211212
debug!(" QDL: {:?} ", qdl.tts);
212-
let new_id = gensym_ident("qdl_tmp");
213+
let new_id = Ident::with_empty_ctxt(Symbol::gensym("qdl_tmp"));
213214
let mut cct_rec = convert_complex_tts(cx, qdl.tts);
214215
bindings.append(&mut cct_rec.0);
215216
bindings.push((new_id, cct_rec.1));
216217

217218
let sep = build_delim_tok(qdl.delim);
218219

219-
pushes.push(build_mod_call(vec![str_to_ident("proc_macro_tokens"),
220-
str_to_ident("build"),
221-
str_to_ident("build_delimited")],
222-
concat(from_tokens(vec![Token::Ident(new_id)]),
223-
concat(lex(","), sep))));
220+
pushes.push(build_mod_call(
221+
vec![Ident::from_str("proc_macro_tokens"),
222+
Ident::from_str("build"),
223+
Ident::from_str("build_delimited")],
224+
concat(from_tokens(vec![Token::Ident(new_id)]), concat(lex(","), sep)),
225+
));
224226
}
225227
QTT::QIdent(t) => {
226228
pushes.push(TokenStream::from_tts(vec![t]));
@@ -250,13 +252,13 @@ fn unravel(binds: Bindings) -> TokenStream {
250252

251253
/// Checks if the Ident is `unquote`.
252254
fn is_unquote(id: Ident) -> bool {
253-
let qq = str_to_ident("unquote");
255+
let qq = Ident::from_str("unquote");
254256
id.name == qq.name // We disregard context; unquote is _reserved_
255257
}
256258

257259
/// Checks if the Ident is `quote`.
258260
fn is_qquote(id: Ident) -> bool {
259-
let qq = str_to_ident("qquote");
261+
let qq = Ident::from_str("qquote");
260262
id.name == qq.name // We disregard context; qquote is _reserved_
261263
}
262264

@@ -266,7 +268,8 @@ mod int_build {
266268

267269
use syntax::ast::{self, Ident};
268270
use syntax::codemap::{DUMMY_SP};
269-
use syntax::parse::token::{self, Token, keywords, str_to_ident};
271+
use syntax::parse::token::{self, Token, Lit};
272+
use syntax::symbol::keywords;
270273
use syntax::tokenstream::{TokenTree, TokenStream};
271274

272275
// ____________________________________________________________________________________________
@@ -277,19 +280,19 @@ mod int_build {
277280
build_paren_delimited(build_vec(build_token_tt(t))))
278281
}
279282

280-
pub fn emit_lit(l: token::Lit, n: Option<ast::Name>) -> TokenStream {
283+
pub fn emit_lit(l: Lit, n: Option<ast::Name>) -> TokenStream {
281284
let suf = match n {
282-
Some(n) => format!("Some(ast::Name({}))", n.0),
285+
Some(n) => format!("Some(ast::Name({}))", n.as_u32()),
283286
None => "None".to_string(),
284287
};
285288

286289
let lit = match l {
287-
token::Lit::Byte(n) => format!("Lit::Byte(token::intern(\"{}\"))", n.to_string()),
288-
token::Lit::Char(n) => format!("Lit::Char(token::intern(\"{}\"))", n.to_string()),
289-
token::Lit::Integer(n) => format!("Lit::Integer(token::intern(\"{}\"))", n.to_string()),
290-
token::Lit::Float(n) => format!("Lit::Float(token::intern(\"{}\"))", n.to_string()),
291-
token::Lit::Str_(n) => format!("Lit::Str_(token::intern(\"{}\"))", n.to_string()),
292-
token::Lit::ByteStr(n) => format!("Lit::ByteStr(token::intern(\"{}\"))", n.to_string()),
290+
Lit::Byte(n) => format!("Lit::Byte(Symbol::intern(\"{}\"))", n.to_string()),
291+
Lit::Char(n) => format!("Lit::Char(Symbol::intern(\"{}\"))", n.to_string()),
292+
Lit::Float(n) => format!("Lit::Float(Symbol::intern(\"{}\"))", n.to_string()),
293+
Lit::Str_(n) => format!("Lit::Str_(Symbol::intern(\"{}\"))", n.to_string()),
294+
Lit::Integer(n) => format!("Lit::Integer(Symbol::intern(\"{}\"))", n.to_string()),
295+
Lit::ByteStr(n) => format!("Lit::ByteStr(Symbol::intern(\"{}\"))", n.to_string()),
293296
_ => panic!("Unsupported literal"),
294297
};
295298

@@ -388,9 +391,10 @@ mod int_build {
388391
Token::Underscore => lex("_"),
389392
Token::Literal(lit, sfx) => emit_lit(lit, sfx),
390393
// fix ident expansion information... somehow
391-
Token::Ident(ident) => lex(&format!("Token::Ident(str_to_ident(\"{}\"))", ident.name)),
392-
Token::Lifetime(ident) => lex(&format!("Token::Ident(str_to_ident(\"{}\"))",
393-
ident.name)),
394+
Token::Ident(ident) =>
395+
lex(&format!("Token::Ident(Ident::from_str(\"{}\"))", ident.name)),
396+
Token::Lifetime(ident) =>
397+
lex(&format!("Token::Ident(Ident::from_str(\"{}\"))", ident.name)),
394398
_ => panic!("Unhandled case!"),
395399
}
396400
}
@@ -408,7 +412,7 @@ mod int_build {
408412

409413
/// Takes `input` and returns `vec![input]`.
410414
pub fn build_vec(ts: TokenStream) -> TokenStream {
411-
build_mac_call(str_to_ident("vec"), ts)
415+
build_mac_call(Ident::from_str("vec"), ts)
412416
// tts.clone().to_owned()
413417
}
414418

src/libproc_macro_tokens/build.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ extern crate syntax_pos;
1313

1414
use syntax::ast::Ident;
1515
use syntax::codemap::DUMMY_SP;
16-
use syntax::parse::token::{self, Token, keywords, str_to_ident};
16+
use syntax::parse::token::{self, Token};
17+
use syntax::symbol::keywords;
1718
use syntax::tokenstream::{self, TokenTree, TokenStream};
1819
use std::rc::Rc;
1920

@@ -43,13 +44,13 @@ pub fn ident_eq(tident: &TokenTree, id: Ident) -> bool {
4344

4445
/// Convert a `&str` into a Token.
4546
pub fn str_to_token_ident(s: &str) -> Token {
46-
Token::Ident(str_to_ident(s))
47+
Token::Ident(Ident::from_str(s))
4748
}
4849

4950
/// Converts a keyword (from `syntax::parse::token::keywords`) into a Token that
5051
/// corresponds to it.
5152
pub fn keyword_to_token_ident(kw: keywords::Keyword) -> Token {
52-
Token::Ident(str_to_ident(&kw.name().as_str()[..]))
53+
Token::Ident(Ident::from_str(&kw.name().as_str()[..]))
5354
}
5455

5556
// ____________________________________________________________________________________________

src/librustc/hir/lowering.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ use syntax::ast::*;
5353
use syntax::errors;
5454
use syntax::ptr::P;
5555
use syntax::codemap::{respan, Spanned};
56-
use syntax::parse::token;
5756
use syntax::std_inject;
57+
use syntax::symbol::{Symbol, keywords};
5858
use syntax::visit::{self, Visitor};
5959
use syntax_pos::Span;
6060

@@ -149,7 +149,7 @@ impl<'a> LoweringContext<'a> {
149149
}
150150

151151
fn str_to_ident(&self, s: &'static str) -> Name {
152-
token::gensym(s)
152+
Symbol::gensym(s)
153153
}
154154

155155
fn with_parent_def<T, F>(&mut self, parent_id: NodeId, f: F) -> T
@@ -400,8 +400,8 @@ impl<'a> LoweringContext<'a> {
400400
// Don't expose `Self` (recovered "keyword used as ident" parse error).
401401
// `rustc::ty` expects `Self` to be only used for a trait's `Self`.
402402
// Instead, use gensym("Self") to create a distinct name that looks the same.
403-
if name == token::keywords::SelfType.name() {
404-
name = token::gensym("Self");
403+
if name == keywords::SelfType.name() {
404+
name = Symbol::gensym("Self");
405405
}
406406

407407
hir::TyParam {
@@ -540,7 +540,7 @@ impl<'a> LoweringContext<'a> {
540540
hir::StructField {
541541
span: f.span,
542542
id: f.id,
543-
name: f.ident.map(|ident| ident.name).unwrap_or(token::intern(&index.to_string())),
543+
name: f.ident.map(|ident| ident.name).unwrap_or(Symbol::intern(&index.to_string())),
544544
vis: self.lower_visibility(&f.vis),
545545
ty: self.lower_ty(&f.ty),
546546
attrs: self.lower_attrs(&f.attrs),
@@ -1189,7 +1189,7 @@ impl<'a> LoweringContext<'a> {
11891189
e.span,
11901190
hir::PopUnstableBlock,
11911191
ThinVec::new());
1192-
this.field(token::intern(s), signal_block, ast_expr.span)
1192+
this.field(Symbol::intern(s), signal_block, ast_expr.span)
11931193
}).collect();
11941194
let attrs = ast_expr.attrs.clone();
11951195

@@ -1953,9 +1953,9 @@ impl<'a> LoweringContext<'a> {
19531953
fn std_path_components(&mut self, components: &[&str]) -> Vec<Name> {
19541954
let mut v = Vec::new();
19551955
if let Some(s) = self.crate_root {
1956-
v.push(token::intern(s));
1956+
v.push(Symbol::intern(s));
19571957
}
1958-
v.extend(components.iter().map(|s| token::intern(s)));
1958+
v.extend(components.iter().map(|s| Symbol::intern(s)));
19591959
return v;
19601960
}
19611961

src/librustc/hir/map/def_collector.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use middle::cstore::InlinedItem;
1919
use syntax::ast::*;
2020
use syntax::ext::hygiene::Mark;
2121
use syntax::visit;
22-
use syntax::parse::token::{self, keywords};
22+
use syntax::symbol::{Symbol, keywords};
2323

2424
/// Creates def ids for nodes in the HIR.
2525
pub struct DefCollector<'a> {
@@ -169,7 +169,7 @@ impl<'a> visit::Visitor for DefCollector<'a> {
169169
this.with_parent(variant_def_index, |this| {
170170
for (index, field) in v.node.data.fields().iter().enumerate() {
171171
let name = field.ident.map(|ident| ident.name)
172-
.unwrap_or_else(|| token::intern(&index.to_string()));
172+
.unwrap_or_else(|| Symbol::intern(&index.to_string()));
173173
this.create_def(field.id, DefPathData::Field(name.as_str()));
174174
}
175175

@@ -188,7 +188,7 @@ impl<'a> visit::Visitor for DefCollector<'a> {
188188

189189
for (index, field) in struct_def.fields().iter().enumerate() {
190190
let name = field.ident.map(|ident| ident.name.as_str())
191-
.unwrap_or(token::intern(&index.to_string()).as_str());
191+
.unwrap_or(Symbol::intern(&index.to_string()).as_str());
192192
this.create_def(field.id, DefPathData::Field(name));
193193
}
194194
}

src/librustc/hir/map/definitions.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use std::fmt::Write;
1414
use std::hash::{Hash, Hasher};
1515
use std::collections::hash_map::DefaultHasher;
1616
use syntax::ast;
17-
use syntax::parse::token::{self, InternedString};
17+
use syntax::symbol::{Symbol, InternedString};
1818
use ty::TyCtxt;
1919
use util::nodemap::NodeMap;
2020

@@ -328,7 +328,7 @@ impl DefPathData {
328328
LifetimeDef(ref name) |
329329
EnumVariant(ref name) |
330330
Binding(ref name) |
331-
Field(ref name) => Some(token::intern(name)),
331+
Field(ref name) => Some(Symbol::intern(name)),
332332

333333
Impl |
334334
CrateRoot |

src/librustc/hir/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ use syntax::codemap::{self, respan, Spanned};
4040
use syntax::abi::Abi;
4141
use syntax::ast::{Name, NodeId, DUMMY_NODE_ID, AsmDialect};
4242
use syntax::ast::{Attribute, Lit, StrStyle, FloatTy, IntTy, UintTy, MetaItem};
43-
use syntax::parse::token::{keywords, InternedString};
4443
use syntax::ptr::P;
44+
use syntax::symbol::{keywords, InternedString};
4545
use syntax::tokenstream::TokenTree;
4646
use syntax::util::ThinVec;
4747

src/librustc/hir/print.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@ pub use self::AnnNode::*;
1313
use syntax::abi::Abi;
1414
use syntax::ast;
1515
use syntax::codemap::{CodeMap, Spanned};
16-
use syntax::parse::token::{self, keywords, BinOpToken};
16+
use syntax::parse::token::{self, BinOpToken};
1717
use syntax::parse::lexer::comments;
1818
use syntax::print::pp::{self, break_offset, word, space, hardbreak};
1919
use syntax::print::pp::{Breaks, eof};
2020
use syntax::print::pp::Breaks::{Consistent, Inconsistent};
2121
use syntax::print::pprust::{self as ast_pp, PrintState};
2222
use syntax::ptr::P;
23+
use syntax::symbol::keywords;
2324
use syntax_pos::{self, BytePos};
2425
use errors;
2526

src/librustc/infer/error_reporting.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ use std::cell::{Cell, RefCell};
9191
use std::char::from_u32;
9292
use std::fmt;
9393
use syntax::ast;
94-
use syntax::parse::token;
9594
use syntax::ptr::P;
95+
use syntax::symbol::Symbol;
9696
use syntax_pos::{self, Pos, Span};
9797
use errors::DiagnosticBuilder;
9898

@@ -1219,7 +1219,7 @@ impl<'a, 'gcx, 'tcx> Rebuilder<'a, 'gcx, 'tcx> {
12191219
names.push(lt_name);
12201220
}
12211221
names.sort();
1222-
let name = token::intern(&names[0]);
1222+
let name = Symbol::intern(&names[0]);
12231223
return (name_to_dummy_lifetime(name), Kept);
12241224
}
12251225
return (self.life_giver.give_lifetime(), Fresh);
@@ -1931,7 +1931,7 @@ impl LifeGiver {
19311931
let mut s = String::from("'");
19321932
s.push_str(&num_to_string(self.counter.get()));
19331933
if !self.taken.contains(&s) {
1934-
lifetime = name_to_dummy_lifetime(token::intern(&s[..]));
1934+
lifetime = name_to_dummy_lifetime(Symbol::intern(&s));
19351935
self.generated.borrow_mut().push(lifetime);
19361936
break;
19371937
}

src/librustc/middle/const_val.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use syntax::parse::token::InternedString;
11+
use syntax::symbol::InternedString;
1212
use syntax::ast;
1313
use std::rc::Rc;
1414
use hir::def_id::DefId;

src/librustc/middle/cstore.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ use syntax::ast;
3939
use syntax::attr;
4040
use syntax::ext::base::SyntaxExtension;
4141
use syntax::ptr::P;
42-
use syntax::parse::token::InternedString;
42+
use syntax::symbol::InternedString;
4343
use syntax_pos::Span;
4444
use rustc_back::target::Target;
4545
use hir;

src/librustc/middle/lang_items.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use middle::weak_lang_items;
3030
use util::nodemap::FxHashMap;
3131

3232
use syntax::ast;
33-
use syntax::parse::token::InternedString;
33+
use syntax::symbol::InternedString;
3434
use hir::itemlikevisit::ItemLikeVisitor;
3535
use hir;
3636

src/librustc/middle/liveness.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ use std::io::prelude::*;
123123
use std::io;
124124
use std::rc::Rc;
125125
use syntax::ast::{self, NodeId};
126-
use syntax::parse::token::keywords;
127126
use syntax::ptr::P;
127+
use syntax::symbol::keywords;
128128
use syntax_pos::Span;
129129

130130
use hir::Expr;

src/librustc/middle/resolve_lifetime.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use middle::region;
2727
use ty;
2828
use std::mem::replace;
2929
use syntax::ast;
30-
use syntax::parse::token::keywords;
30+
use syntax::symbol::keywords;
3131
use syntax_pos::Span;
3232
use util::nodemap::NodeMap;
3333

src/librustc/middle/stability.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use hir::def::Def;
2121
use hir::def_id::{CrateNum, CRATE_DEF_INDEX, DefId, DefIndex, LOCAL_CRATE};
2222
use ty::{self, TyCtxt, AdtKind};
2323
use middle::privacy::AccessLevels;
24-
use syntax::parse::token::InternedString;
24+
use syntax::symbol::InternedString;
2525
use syntax_pos::{Span, DUMMY_SP};
2626
use syntax::ast;
2727
use syntax::ast::{NodeId, Attribute};

src/librustc/middle/weak_lang_items.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use middle::lang_items;
1616

1717
use rustc_back::PanicStrategy;
1818
use syntax::ast;
19-
use syntax::parse::token::InternedString;
19+
use syntax::symbol::InternedString;
2020
use syntax_pos::Span;
2121
use hir::intravisit::Visitor;
2222
use hir::intravisit;

0 commit comments

Comments
 (0)