Skip to content

Commit d2f8fb0

Browse files
committedNov 20, 2016
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
// ____________________________________________________________________________________________

0 commit comments

Comments
 (0)