diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 99c299861e05c..103e2a949df19 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -1764,9 +1764,7 @@ mod tests { use std::rc::Rc; use super::{OutputType, OutputTypes, Externs}; use rustc_back::PanicStrategy; - use syntax::{ast, attr}; - use syntax::parse::token::InternedString; - use syntax::codemap::dummy_spanned; + use syntax::symbol::Symbol; fn optgroups() -> Vec { super::rustc_optgroups().into_iter() @@ -1795,9 +1793,7 @@ mod tests { let (sessopts, cfg) = build_session_options_and_crate_config(matches); let sess = build_session(sessopts, &dep_graph, None, registry, Rc::new(DummyCrateStore)); let cfg = build_configuration(&sess, cfg); - assert!(attr::contains(&cfg, &dummy_spanned(ast::MetaItemKind::Word({ - InternedString::new("test") - })))); + assert!(cfg.contains(&(Symbol::intern("test"), None))); } // When the user supplies --test and --cfg test, don't implicitly add @@ -1818,7 +1814,7 @@ mod tests { let sess = build_session(sessopts, &dep_graph, None, registry, Rc::new(DummyCrateStore)); let cfg = build_configuration(&sess, cfg); - let mut test_items = cfg.iter().filter(|m| m.name() == "test"); + let mut test_items = cfg.iter().filter(|&&(name, _)| name == "test"); assert!(test_items.next().is_some()); assert!(test_items.next().is_none()); } diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 3a9729d5d45c1..228119e6cc7da 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -54,7 +54,7 @@ use syntax::{ast, diagnostics, visit}; use syntax::attr; use syntax::ext::base::ExtCtxt; use syntax::parse::{self, PResult}; -use syntax::symbol::{self, Symbol}; +use syntax::symbol::Symbol; use syntax::util::node_count::NodeCounter; use syntax; use syntax_ext; diff --git a/src/librustc_driver/test.rs b/src/librustc_driver/test.rs index 782c74c8c78c7..a4f0e29038477 100644 --- a/src/librustc_driver/test.rs +++ b/src/librustc_driver/test.rs @@ -34,8 +34,8 @@ use syntax::codemap::CodeMap; use errors; use errors::emitter::Emitter; use errors::{Level, DiagnosticBuilder}; -use syntax::parse::token; use syntax::feature_gate::UnstableFeatures; +use syntax::symbol::Symbol; use rustc::hir; @@ -288,11 +288,11 @@ impl<'a, 'gcx, 'tcx> Env<'a, 'gcx, 'tcx> { pub fn t_param(&self, index: u32) -> Ty<'tcx> { let name = format!("T{}", index); - self.infcx.tcx.mk_param(index, token::intern(&name[..])) + self.infcx.tcx.mk_param(index, Symbol::intern(&name[..])) } pub fn re_early_bound(&self, index: u32, name: &'static str) -> &'tcx ty::Region { - let name = token::intern(name); + let name = Symbol::intern(name); self.infcx.tcx.mk_region(ty::ReEarlyBound(ty::EarlyBoundRegion { index: index, name: name, diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index a141d0e4788dd..2cc1882ce3eae 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -24,9 +24,9 @@ use syntax::abi::Abi; use syntax::ast; use syntax::attr; use syntax::codemap::Spanned; -use syntax::parse::token::keywords; use syntax::ptr::P; use syntax::print::pprust as syntax_pprust; +use syntax::symbol::keywords; use syntax_pos::{self, DUMMY_SP, Pos}; use rustc_trans::back::link; @@ -242,7 +242,7 @@ impl Clean for CrateNum { } }); ExternalCrate { - name: (&cx.sess().cstore.crate_name(self.0)[..]).to_owned(), + name: cx.sess().cstore.crate_name(self.0).to_string(), attrs: cx.sess().cstore.item_attrs(root).clean(cx), primitives: primitives, } @@ -2577,7 +2577,7 @@ impl Clean> for doctree::Import { // #[doc(no_inline)] attribute is present. // Don't inline doc(hidden) imports so they can be stripped at a later stage. let denied = self.vis != hir::Public || self.attrs.iter().any(|a| { - &a.name()[..] == "doc" && match a.meta_item_list() { + a.name() == "doc" && match a.meta_item_list() { Some(l) => attr::list_contains_name(l, "no_inline") || attr::list_contains_name(l, "hidden"), None => false, diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index 49012ad036a9a..3cdfa718eabae 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -871,6 +871,7 @@ impl CodeMapper for CodeMap { #[cfg(test)] mod tests { use super::*; + use symbol::keywords; use std::rc::Rc; #[test] @@ -1097,10 +1098,9 @@ mod tests { #[test] fn t11() { // Test span_to_expanded_string works with expansion - use ast::Name; let cm = init_code_map(); let root = Span { lo: BytePos(0), hi: BytePos(11), expn_id: NO_EXPANSION }; - let format = ExpnFormat::MacroBang(Name(0u32)); + let format = ExpnFormat::MacroBang(keywords::Invalid.name()); let callee = NameAndSpan { format: format, allow_internal_unstable: false, span: None }; @@ -1197,11 +1197,9 @@ mod tests { fn init_expansion_chain(cm: &CodeMap) -> Span { // Creates an expansion chain containing two recursive calls // root -> expA -> expA -> expB -> expB -> end - use ast::Name; - let root = Span { lo: BytePos(0), hi: BytePos(11), expn_id: NO_EXPANSION }; - let format_root = ExpnFormat::MacroBang(Name(0u32)); + let format_root = ExpnFormat::MacroBang(keywords::Invalid.name()); let callee_root = NameAndSpan { format: format_root, allow_internal_unstable: false, span: Some(root) }; @@ -1210,7 +1208,7 @@ mod tests { let id_a1 = cm.record_expansion(info_a1); let span_a1 = Span { lo: BytePos(12), hi: BytePos(23), expn_id: id_a1 }; - let format_a = ExpnFormat::MacroBang(Name(1u32)); + let format_a = ExpnFormat::MacroBang(keywords::As.name()); let callee_a = NameAndSpan { format: format_a, allow_internal_unstable: false, span: Some(span_a1) }; @@ -1223,7 +1221,7 @@ mod tests { let id_b1 = cm.record_expansion(info_b1); let span_b1 = Span { lo: BytePos(25), hi: BytePos(36), expn_id: id_b1 }; - let format_b = ExpnFormat::MacroBang(Name(2u32)); + let format_b = ExpnFormat::MacroBang(keywords::Box.name()); let callee_b = NameAndSpan { format: format_b, allow_internal_unstable: false, span: None }; diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 44ce8668c549a..ff0255a2f21f2 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -1332,9 +1332,8 @@ pub fn noop_fold_vis(vis: Visibility, folder: &mut T) -> Visibility { #[cfg(test)] mod tests { use std::io; - use ast; + use ast::{self, Ident}; use util::parser_testing::{string_to_crate, matches_codepattern}; - use parse::token; use print::pprust; use fold; use super::*; @@ -1350,7 +1349,7 @@ mod tests { impl Folder for ToZzIdentFolder { fn fold_ident(&mut self, _: ast::Ident) -> ast::Ident { - token::str_to_ident("zz") + Ident::from_str("zz") } fn fold_mac(&mut self, mac: ast::Mac) -> ast::Mac { fold::noop_fold_mac(mac, self) diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index 7048be1478b82..681dec0ab564d 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -1702,6 +1702,7 @@ mod tests { use super::*; use ast::Ident; + use symbol::Symbol; use syntax_pos::{BytePos, Span, NO_EXPANSION}; use codemap::CodeMap; use errors; @@ -1752,7 +1753,7 @@ mod tests { // read another token: let tok3 = string_reader.next_token(); let tok4 = TokenAndSpan { - tok: token::Ident(str_to_ident("main")), + tok: token::Ident(Ident::from_str("main")), sp: Span { lo: BytePos(24), hi: BytePos(28), @@ -1774,7 +1775,7 @@ mod tests { // make the identifier by looking up the string in the interner fn mk_ident(id: &str) -> token::Token { - token::Ident(str_to_ident(id)) + token::Ident(Ident::from_str(id)) } #[test] @@ -1838,7 +1839,7 @@ mod tests { let cm = Rc::new(CodeMap::new()); let sh = mk_sh(cm.clone()); assert_eq!(setup(&cm, &sh, "'abc".to_string()).next_token().tok, - token::Lifetime(token::str_to_ident("'abc"))); + token::Lifetime(Ident::from_str("'abc"))); } #[test] @@ -1848,7 +1849,7 @@ mod tests { assert_eq!(setup(&cm, &sh, "r###\"\"#a\\b\x00c\"\"###".to_string()) .next_token() .tok, - token::Literal(token::StrRaw(Symol::intern("\"#a\\b\x00c\""), 3), None)); + token::Literal(token::StrRaw(Symbol::intern("\"#a\\b\x00c\""), 3), None)); } #[test] diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index c811514c3073d..be340a5b5aa93 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -597,12 +597,11 @@ mod tests { use std::rc::Rc; use syntax_pos::{self, Span, BytePos, Pos, NO_EXPANSION}; use codemap::Spanned; - use ast::{self, PatKind}; + use ast::{self, Ident, PatKind}; use abi::Abi; use attr::first_attr_value_str_by_name; use parse; use parse::parser::Parser; - use parse::token::{str_to_ident}; use print::pprust::item_to_string; use ptr::P; use tokenstream::{self, TokenTree}; @@ -624,7 +623,7 @@ mod tests { global: false, segments: vec![ ast::PathSegment { - identifier: str_to_ident("a"), + identifier: Ident::from_str("a"), parameters: ast::PathParameters::none(), } ], @@ -643,11 +642,11 @@ mod tests { global: true, segments: vec![ ast::PathSegment { - identifier: str_to_ident("a"), + identifier: Ident::from_str("a"), parameters: ast::PathParameters::none(), }, ast::PathSegment { - identifier: str_to_ident("b"), + identifier: Ident::from_str("b"), parameters: ast::PathParameters::none(), } ] @@ -676,8 +675,8 @@ mod tests { Some(&TokenTree::Token(_, token::Ident(name_zip))), Some(&TokenTree::Delimited(_, ref macro_delimed)), ) - if name_macro_rules.name.as_str() == "macro_rules" - && name_zip.name.as_str() == "zip" => { + if name_macro_rules.name == "macro_rules" + && name_zip.name == "zip" => { let tts = ¯o_delimed.tts[..]; match (tts.len(), tts.get(0), tts.get(1), tts.get(2)) { ( @@ -694,8 +693,7 @@ mod tests { Some(&TokenTree::Token(_, token::Dollar)), Some(&TokenTree::Token(_, token::Ident(ident))), ) - if first_delimed.delim == token::Paren - && ident.name.as_str() == "a" => {}, + if first_delimed.delim == token::Paren && ident.name == "a" => {}, _ => panic!("value 3: {:?}", **first_delimed), } let tts = &second_delimed.tts[..]; @@ -706,7 +704,7 @@ mod tests { Some(&TokenTree::Token(_, token::Ident(ident))), ) if second_delimed.delim == token::Paren - && ident.name.as_str() == "a" => {}, + && ident.name == "a" => {}, _ => panic!("value 4: {:?}", **second_delimed), } }, @@ -722,17 +720,17 @@ mod tests { let tts = string_to_tts("fn a (b : i32) { b; }".to_string()); let expected = vec![ - TokenTree::Token(sp(0, 2), token::Ident(str_to_ident("fn"))), - TokenTree::Token(sp(3, 4), token::Ident(str_to_ident("a"))), + TokenTree::Token(sp(0, 2), token::Ident(Ident::from_str("fn"))), + TokenTree::Token(sp(3, 4), token::Ident(Ident::from_str("a"))), TokenTree::Delimited( sp(5, 14), Rc::new(tokenstream::Delimited { delim: token::DelimToken::Paren, open_span: sp(5, 6), tts: vec![ - TokenTree::Token(sp(6, 7), token::Ident(str_to_ident("b"))), + TokenTree::Token(sp(6, 7), token::Ident(Ident::from_str("b"))), TokenTree::Token(sp(8, 9), token::Colon), - TokenTree::Token(sp(10, 13), token::Ident(str_to_ident("i32"))), + TokenTree::Token(sp(10, 13), token::Ident(Ident::from_str("i32"))), ], close_span: sp(13, 14), })), @@ -742,7 +740,7 @@ mod tests { delim: token::DelimToken::Brace, open_span: sp(15, 16), tts: vec![ - TokenTree::Token(sp(17, 18), token::Ident(str_to_ident("b"))), + TokenTree::Token(sp(17, 18), token::Ident(Ident::from_str("b"))), TokenTree::Token(sp(18, 19), token::Semi), ], close_span: sp(20, 21), @@ -763,7 +761,7 @@ mod tests { global: false, segments: vec![ ast::PathSegment { - identifier: str_to_ident("d"), + identifier: Ident::from_str("d"), parameters: ast::PathParameters::none(), } ], @@ -786,7 +784,7 @@ mod tests { global:false, segments: vec![ ast::PathSegment { - identifier: str_to_ident("b"), + identifier: Ident::from_str("b"), parameters: ast::PathParameters::none(), } ], @@ -810,7 +808,7 @@ mod tests { id: ast::DUMMY_NODE_ID, node: PatKind::Ident(ast::BindingMode::ByValue(ast::Mutability::Immutable), Spanned{ span:sp(0, 1), - node: str_to_ident("b") + node: Ident::from_str("b") }, None), span: sp(0,1)})); @@ -822,7 +820,7 @@ mod tests { // this test depends on the intern order of "fn" and "i32" assert_eq!(string_to_item("fn a (b : i32) { b; }".to_string()), Some( - P(ast::Item{ident:str_to_ident("a"), + P(ast::Item{ident:Ident::from_str("a"), attrs:Vec::new(), id: ast::DUMMY_NODE_ID, node: ast::ItemKind::Fn(P(ast::FnDecl { @@ -833,8 +831,7 @@ mod tests { global:false, segments: vec![ ast::PathSegment { - identifier: - str_to_ident("i32"), + identifier: Ident::from_str("i32"), parameters: ast::PathParameters::none(), } ], @@ -847,7 +844,7 @@ mod tests { ast::BindingMode::ByValue(ast::Mutability::Immutable), Spanned{ span: sp(6,7), - node: str_to_ident("b")}, + node: Ident::from_str("b")}, None ), span: sp(6,7) @@ -882,9 +879,7 @@ mod tests { global:false, segments: vec![ ast::PathSegment { - identifier: - str_to_ident( - "b"), + identifier: Ident::from_str("b"), parameters: ast::PathParameters::none(), } @@ -996,12 +991,12 @@ mod tests { let item = parse_item_from_source_str(name.clone(), source, &sess) .unwrap().unwrap(); let doc = first_attr_value_str_by_name(&item.attrs, "doc").unwrap(); - assert_eq!(&doc[..], "/// doc comment"); + assert_eq!(doc, "/// doc comment"); let source = "/// doc comment\r\n/// line 2\r\nfn foo() {}".to_string(); let item = parse_item_from_source_str(name.clone(), source, &sess) .unwrap().unwrap(); - let docs = item.attrs.iter().filter(|a| &*a.name() == "doc") + let docs = item.attrs.iter().filter(|a| a.name() == "doc") .map(|a| a.value_str().unwrap().to_string()).collect::>(); let b: &[_] = &["/// doc comment".to_string(), "/// line 2".to_string()]; assert_eq!(&docs[..], b); @@ -1009,7 +1004,7 @@ mod tests { let source = "/** doc comment\r\n * with CRLF */\r\nfn foo() {}".to_string(); let item = parse_item_from_source_str(name, source, &sess).unwrap().unwrap(); let doc = first_attr_value_str_by_name(&item.attrs, "doc").unwrap(); - assert_eq!(&doc[..], "/** doc comment\n * with CRLF */"); + assert_eq!(doc, "/** doc comment\n * with CRLF */"); } #[test] diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 544b431e61cce..3820f5ea90ccc 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -3080,12 +3080,11 @@ mod tests { use ast; use codemap; - use parse::token; use syntax_pos; #[test] fn test_fun_to_string() { - let abba_ident = token::str_to_ident("abba"); + let abba_ident = ast::Ident::from_str("abba"); let decl = ast::FnDecl { inputs: Vec::new(), @@ -3101,7 +3100,7 @@ mod tests { #[test] fn test_variant_to_string() { - let ident = token::str_to_ident("principal_skinner"); + let ident = ast::Ident::from_str("principal_skinner"); let var = codemap::respan(syntax_pos::DUMMY_SP, ast::Variant_ { name: ident, diff --git a/src/libsyntax/tokenstream.rs b/src/libsyntax/tokenstream.rs index ee0c2f80891c7..0d5dcaf339feb 100644 --- a/src/libsyntax/tokenstream.rs +++ b/src/libsyntax/tokenstream.rs @@ -872,8 +872,9 @@ impl Index for InternalTS { #[cfg(test)] mod tests { use super::*; + use syntax::ast::Ident; use syntax_pos::{Span, BytePos, NO_EXPANSION, DUMMY_SP}; - use parse::token::{self, str_to_ident, Token}; + use parse::token::{self, Token}; use util::parser_testing::string_to_tts; use std::rc::Rc; @@ -968,15 +969,17 @@ mod tests { let test_res = TokenStream::from_tts(string_to_tts("foo::bar::baz".to_string())) .slice(2..3); let test_eqs = TokenStream::from_tts(vec![TokenTree::Token(sp(5,8), - token::Ident(str_to_ident("bar")))]); + token::Ident(Ident::from_str("bar")))]); assert_eq!(test_res, test_eqs) } #[test] fn test_is_empty() { let test0 = TokenStream::from_tts(Vec::new()); - let test1 = TokenStream::from_tts(vec![TokenTree::Token(sp(0, 1), - Token::Ident(str_to_ident("a")))]); + let test1 = TokenStream::from_tts( + vec![TokenTree::Token(sp(0, 1), Token::Ident(Ident::from_str("a")))] + ); + let test2 = TokenStream::from_tts(string_to_tts("foo(bar::baz)".to_string())); assert_eq!(test0.is_empty(), true); @@ -1036,20 +1039,20 @@ mod tests { assert_eq!(test0, None); let test1_expected = TokenStream::from_tts(vec![TokenTree::Token(sp(1, 4), - token::Ident(str_to_ident("bar"))), + token::Ident(Ident::from_str("bar"))), TokenTree::Token(sp(4, 6), token::ModSep), TokenTree::Token(sp(6, 9), - token::Ident(str_to_ident("baz")))]); + token::Ident(Ident::from_str("baz")))]); assert_eq!(test1, Some(test1_expected)); let test2_expected = TokenStream::from_tts(vec![TokenTree::Token(sp(1, 4), - token::Ident(str_to_ident("foo"))), + token::Ident(Ident::from_str("foo"))), TokenTree::Token(sp(4, 5), token::Comma), TokenTree::Token(sp(5, 8), - token::Ident(str_to_ident("bar"))), + token::Ident(Ident::from_str("bar"))), TokenTree::Token(sp(8, 9), token::Comma), TokenTree::Token(sp(9, 12), - token::Ident(str_to_ident("baz")))]); + token::Ident(Ident::from_str("baz")))]); assert_eq!(test2, Some(test2_expected)); assert_eq!(test3, None); @@ -1070,7 +1073,7 @@ mod tests { assert_eq!(test0, None); assert_eq!(test1, None); - assert_eq!(test2, Some(str_to_ident("foo"))); + assert_eq!(test2, Some(Ident::from_str("foo"))); assert_eq!(test3, None); assert_eq!(test4, None); } @@ -1080,9 +1083,9 @@ mod tests { let test0 = as_paren_delimited_stream(string_to_tts("foo,bar,".to_string())); let test1 = as_paren_delimited_stream(string_to_tts("baz(foo,bar)".to_string())); - let test0_tts = vec![TokenTree::Token(sp(0, 3), token::Ident(str_to_ident("foo"))), + let test0_tts = vec![TokenTree::Token(sp(0, 3), token::Ident(Ident::from_str("foo"))), TokenTree::Token(sp(3, 4), token::Comma), - TokenTree::Token(sp(4, 7), token::Ident(str_to_ident("bar"))), + TokenTree::Token(sp(4, 7), token::Ident(Ident::from_str("bar"))), TokenTree::Token(sp(7, 8), token::Comma)]; let test0_stream = TokenStream::from_tts(vec![TokenTree::Delimited(sp(0, 8), Rc::new(Delimited { @@ -1095,11 +1098,11 @@ mod tests { assert_eq!(test0, test0_stream); - let test1_tts = vec![TokenTree::Token(sp(4, 7), token::Ident(str_to_ident("foo"))), + let test1_tts = vec![TokenTree::Token(sp(4, 7), token::Ident(Ident::from_str("foo"))), TokenTree::Token(sp(7, 8), token::Comma), - TokenTree::Token(sp(8, 11), token::Ident(str_to_ident("bar")))]; + TokenTree::Token(sp(8, 11), token::Ident(Ident::from_str("bar")))]; - let test1_parse = vec![TokenTree::Token(sp(0, 3), token::Ident(str_to_ident("baz"))), + let test1_parse = vec![TokenTree::Token(sp(0, 3), token::Ident(Ident::from_str("baz"))), TokenTree::Delimited(sp(3, 12), Rc::new(Delimited { delim: token::DelimToken::Paren, diff --git a/src/libsyntax/util/parser_testing.rs b/src/libsyntax/util/parser_testing.rs index 76d3f2a063c18..e703dc6b4191c 100644 --- a/src/libsyntax/util/parser_testing.rs +++ b/src/libsyntax/util/parser_testing.rs @@ -8,11 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use ast; +use ast::{self, Ident}; use parse::{ParseSess,PResult,filemap_to_tts}; use parse::{lexer, new_parser_from_source_str}; use parse::parser::Parser; -use parse::token; use ptr::P; use tokenstream; use std::iter::Peekable; @@ -78,9 +77,9 @@ pub fn string_to_pat(source_str: String) -> P { }) } -/// Convert a vector of strings to a vector of ast::Ident's -pub fn strs_to_idents(ids: Vec<&str> ) -> Vec { - ids.iter().map(|u| token::str_to_ident(*u)).collect() +/// Convert a vector of strings to a vector of Ident's +pub fn strs_to_idents(ids: Vec<&str> ) -> Vec { + ids.iter().map(|u| Ident::from_str(*u)).collect() } /// Does the given string match the pattern? whitespace in the first string diff --git a/src/test/compile-fail-fulldeps/auxiliary/lint_plugin_test.rs b/src/test/compile-fail-fulldeps/auxiliary/lint_plugin_test.rs index 8ea131da338cb..8647797270f9a 100644 --- a/src/test/compile-fail-fulldeps/auxiliary/lint_plugin_test.rs +++ b/src/test/compile-fail-fulldeps/auxiliary/lint_plugin_test.rs @@ -36,7 +36,7 @@ impl LintPass for Pass { impl EarlyLintPass for Pass { fn check_item(&mut self, cx: &EarlyContext, it: &ast::Item) { - if it.ident.name.as_str() == "lintme" { + if it.ident.name == "lintme" { cx.span_lint(TEST_LINT, it.span, "item is named 'lintme'"); } } diff --git a/src/test/compile-fail-fulldeps/auxiliary/macro_crate_test.rs b/src/test/compile-fail-fulldeps/auxiliary/macro_crate_test.rs index 409f9dbf03c54..dc88bfc40595f 100644 --- a/src/test/compile-fail-fulldeps/auxiliary/macro_crate_test.rs +++ b/src/test/compile-fail-fulldeps/auxiliary/macro_crate_test.rs @@ -19,8 +19,9 @@ extern crate rustc_plugin; use syntax::ast::{self, Item, MetaItem, ItemKind}; use syntax::ext::base::*; -use syntax::parse::{self, token}; +use syntax::parse; use syntax::ptr::P; +use syntax::symbol::Symbol; use syntax::tokenstream::TokenTree; use syntax_pos::Span; use rustc_plugin::Registry; @@ -34,11 +35,11 @@ pub fn plugin_registrar(reg: &mut Registry) { reg.register_macro("make_a_1", expand_make_a_1); reg.register_macro("identity", expand_identity); reg.register_syntax_extension( - token::intern("into_multi_foo"), + Symbol::intern("into_multi_foo"), // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. MultiModifier(Box::new(expand_into_foo_multi))); reg.register_syntax_extension( - token::intern("duplicate"), + Symbol::intern("duplicate"), // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. MultiDecorator(Box::new(expand_duplicate))); } @@ -102,9 +103,9 @@ fn expand_duplicate(cx: &mut ExtCtxt, push: &mut FnMut(Annotatable)) { let copy_name = match mi.node { - ast::MetaItemKind::List(_, ref xs) => { + ast::MetaItemKind::List(ref xs) => { if let Some(word) = xs[0].word() { - token::str_to_ident(&word.name()) + ast::Ident::with_empty_ctxt(word.name()) } else { cx.span_err(mi.span, "Expected word"); return; diff --git a/src/test/compile-fail-fulldeps/qquote.rs b/src/test/compile-fail-fulldeps/qquote.rs index 4a7033d44b878..8acab3369e48f 100644 --- a/src/test/compile-fail-fulldeps/qquote.rs +++ b/src/test/compile-fail-fulldeps/qquote.rs @@ -16,8 +16,8 @@ extern crate syntax; extern crate syntax_pos; use syntax::ast; -use syntax::parse; use syntax::print::pprust; +use syntax::symbol::Symbol; use syntax_pos::DUMMY_SP; fn main() { @@ -30,7 +30,7 @@ fn main() { cx.bt_push(syntax::codemap::ExpnInfo { call_site: DUMMY_SP, callee: syntax::codemap::NameAndSpan { - format: syntax::codemap::MacroBang(parse::token::intern("")), + format: syntax::codemap::MacroBang(Symbol::intern("")), allow_internal_unstable: false, span: None, } diff --git a/src/test/parse-fail/attr-bad-meta.rs b/src/test/parse-fail/attr-bad-meta.rs index 7def91da5eca4..092adbf29e340 100644 --- a/src/test/parse-fail/attr-bad-meta.rs +++ b/src/test/parse-fail/attr-bad-meta.rs @@ -10,7 +10,7 @@ // compile-flags: -Z parse-only -// error-pattern:expected `]` +// error-pattern:expected one of `=` or `]` // asterisk is bogus #[attr*] diff --git a/src/test/run-fail-fulldeps/qquote.rs b/src/test/run-fail-fulldeps/qquote.rs index d2a16ac750704..d692bb519c149 100644 --- a/src/test/run-fail-fulldeps/qquote.rs +++ b/src/test/run-fail-fulldeps/qquote.rs @@ -19,8 +19,8 @@ extern crate syntax_pos; use syntax::ast; use syntax::codemap; -use syntax::parse; use syntax::print::pprust; +use syntax::symbol::Symbol; use syntax_pos::DUMMY_SP; fn main() { @@ -33,7 +33,7 @@ fn main() { cx.bt_push(syntax::codemap::ExpnInfo { call_site: DUMMY_SP, callee: syntax::codemap::NameAndSpan { - format: syntax::codemap::MacroBang(parse::token::intern("")), + format: syntax::codemap::MacroBang(Symbol::intern("")), allow_internal_unstable: false, span: None, } diff --git a/src/test/run-make/issue-19371/foo.rs b/src/test/run-make/issue-19371/foo.rs index ed127b017b6a9..0336fe277c51f 100644 --- a/src/test/run-make/issue-19371/foo.rs +++ b/src/test/run-make/issue-19371/foo.rs @@ -25,6 +25,7 @@ use rustc_driver::driver::{compile_input, CompileController, anon_src}; use rustc_metadata::cstore::CStore; use rustc_errors::registry::Registry; +use std::collections::HashSet; use std::path::PathBuf; use std::rc::Rc; @@ -65,7 +66,7 @@ fn basic_sess(sysroot: PathBuf) -> (Session, Rc) { fn compile(code: String, output: PathBuf, sysroot: PathBuf) { let (sess, cstore) = basic_sess(sysroot); - let cfg = build_configuration(&sess, vec![]); + let cfg = build_configuration(&sess, HashSet::new()); let control = CompileController::basic(); let input = Input::Str { name: anon_src(), input: code }; compile_input(&sess, &cstore, &input, &None, &Some(output), None, &control); diff --git a/src/test/run-pass-fulldeps/auxiliary/cond_noprelude_plugin.rs b/src/test/run-pass-fulldeps/auxiliary/cond_noprelude_plugin.rs index 48919fe876a22..664bb9da89a57 100644 --- a/src/test/run-pass-fulldeps/auxiliary/cond_noprelude_plugin.rs +++ b/src/test/run-pass-fulldeps/auxiliary/cond_noprelude_plugin.rs @@ -20,10 +20,10 @@ extern crate syntax; use proc_macro_tokens::build::ident_eq; +use syntax::ast::Ident; use syntax::ext::base::{ExtCtxt, MacResult}; use syntax::ext::proc_macro_shim::build_block_emitter; use syntax::tokenstream::{TokenTree, TokenStream}; -use syntax::parse::token::str_to_ident; use syntax::codemap::Span; use rustc_plugin::Registry; @@ -57,7 +57,7 @@ fn cond_rec(input: TokenStream) -> TokenStream { let test: TokenStream = clause.slice(0..1); let rhs: TokenStream = clause.slice_from(1..); - if ident_eq(&test[0], str_to_ident("else")) || rest.is_empty() { + if ident_eq(&test[0], Ident::from_str("else")) || rest.is_empty() { qquote!({unquote(rhs)}) } else { qquote!({if unquote(test) { unquote(rhs) } else { cond!(unquote(rest)) } }) diff --git a/src/test/run-pass-fulldeps/auxiliary/cond_plugin.rs b/src/test/run-pass-fulldeps/auxiliary/cond_plugin.rs index 0ea4cec75cdda..31a5f5968bab6 100644 --- a/src/test/run-pass-fulldeps/auxiliary/cond_plugin.rs +++ b/src/test/run-pass-fulldeps/auxiliary/cond_plugin.rs @@ -26,7 +26,7 @@ use syntax::ast::Ident; use syntax::codemap::{DUMMY_SP, Span}; use syntax::ext::proc_macro_shim::build_block_emitter; use syntax::ext::base::{ExtCtxt, MacResult}; -use syntax::parse::token::{self, Token, DelimToken, keywords, str_to_ident}; +use syntax::parse::token::{self, Token, DelimToken}; use syntax::tokenstream::{TokenTree, TokenStream}; #[plugin_registrar] @@ -58,7 +58,7 @@ fn cond_rec(input: TokenStream) -> TokenStream { let test: TokenStream = clause.slice(0..1); let rhs: TokenStream = clause.slice_from(1..); - if ident_eq(&test[0], str_to_ident("else")) || rest.is_empty() { + if ident_eq(&test[0], Ident::from_str("else")) || rest.is_empty() { qquote!({unquote(rhs)}) } else { qquote!({if unquote(test) { unquote(rhs) } else { cond!(unquote(rest)) } }) diff --git a/src/test/run-pass-fulldeps/auxiliary/cond_prelude_plugin.rs b/src/test/run-pass-fulldeps/auxiliary/cond_prelude_plugin.rs index 169c96b438529..6a2d159a4bdd9 100644 --- a/src/test/run-pass-fulldeps/auxiliary/cond_prelude_plugin.rs +++ b/src/test/run-pass-fulldeps/auxiliary/cond_prelude_plugin.rs @@ -52,7 +52,7 @@ fn cond_rec(input: TokenStream) -> TokenStream { let test: TokenStream = clause.slice(0..1); let rhs: TokenStream = clause.slice_from(1..); - if ident_eq(&test[0], str_to_ident("else")) || rest.is_empty() { + if ident_eq(&test[0], Ident::from_str("else")) || rest.is_empty() { qquote!({unquote(rhs)}) } else { qquote!({if unquote(test) { unquote(rhs) } else { cond!(unquote(rest)) } }) diff --git a/src/test/run-pass-fulldeps/auxiliary/custom_derive_partial_eq.rs b/src/test/run-pass-fulldeps/auxiliary/custom_derive_partial_eq.rs index e750d1fb1e3e6..da82545ca7210 100644 --- a/src/test/run-pass-fulldeps/auxiliary/custom_derive_partial_eq.rs +++ b/src/test/run-pass-fulldeps/auxiliary/custom_derive_partial_eq.rs @@ -25,12 +25,12 @@ use syntax::ast::*; use syntax::codemap::Span; use syntax::ext::base::*; use syntax::ext::build::AstBuilder; -use syntax::parse::token::{intern, InternedString}; +use syntax::symbol::Symbol; use syntax::ptr::P; #[plugin_registrar] pub fn plugin_registrar(reg: &mut Registry) { - reg.register_syntax_extension(intern("derive_CustomPartialEq"), + reg.register_syntax_extension(Symbol::intern("derive_CustomPartialEq"), MultiDecorator(Box::new(expand_deriving_partial_eq))); } @@ -52,7 +52,7 @@ fn expand_deriving_partial_eq(cx: &mut ExtCtxt, span: Span, mitem: &MetaItem, it substr) } - let inline = cx.meta_word(span, InternedString::new("inline")); + let inline = cx.meta_word(span, Symbol::intern("inline")); let attrs = vec![cx.attribute(span, inline)]; let methods = vec![MethodDef { name: "eq", diff --git a/src/test/run-pass-fulldeps/auxiliary/custom_derive_plugin.rs b/src/test/run-pass-fulldeps/auxiliary/custom_derive_plugin.rs index 6b688b006bd4a..07f7d6bad7bf2 100644 --- a/src/test/run-pass-fulldeps/auxiliary/custom_derive_plugin.rs +++ b/src/test/run-pass-fulldeps/auxiliary/custom_derive_plugin.rs @@ -23,7 +23,7 @@ extern crate rustc_plugin; use syntax::ast; use syntax::ext::base::{MultiDecorator, ExtCtxt, Annotatable}; use syntax::ext::build::AstBuilder; -use syntax::parse::token; +use syntax::symbol::Symbol; use syntax_ext::deriving::generic::{cs_fold, TraitDef, MethodDef, combine_substructure}; use syntax_ext::deriving::generic::ty::{Literal, LifetimeBounds, Path, borrowed_explicit_self}; use syntax_pos::Span; @@ -32,7 +32,7 @@ use rustc_plugin::Registry; #[plugin_registrar] pub fn plugin_registrar(reg: &mut Registry) { reg.register_syntax_extension( - token::intern("derive_TotalSum"), + Symbol::intern("derive_TotalSum"), MultiDecorator(box expand)); } @@ -66,7 +66,7 @@ fn expand(cx: &mut ExtCtxt, |cx, span, subexpr, field, _| { cx.expr_binary(span, ast::BinOpKind::Add, subexpr, cx.expr_method_call(span, field, - token::str_to_ident("total_sum"), vec![])) + ast::Ident::from_str("total_sum"), vec![])) }, zero, box |cx, span, _, _| { cx.span_bug(span, "wtf??"); }, diff --git a/src/test/run-pass-fulldeps/auxiliary/custom_derive_plugin_attr.rs b/src/test/run-pass-fulldeps/auxiliary/custom_derive_plugin_attr.rs index 6b58fee157584..50b16a0e26fb4 100644 --- a/src/test/run-pass-fulldeps/auxiliary/custom_derive_plugin_attr.rs +++ b/src/test/run-pass-fulldeps/auxiliary/custom_derive_plugin_attr.rs @@ -23,7 +23,7 @@ extern crate rustc_plugin; use syntax::ast; use syntax::ext::base::{MultiDecorator, ExtCtxt, Annotatable}; use syntax::ext::build::AstBuilder; -use syntax::parse::token; +use syntax::symbol::Symbol; use syntax::ptr::P; use syntax_ext::deriving::generic::{TraitDef, MethodDef, combine_substructure}; use syntax_ext::deriving::generic::{Substructure, Struct, EnumMatching}; @@ -34,7 +34,7 @@ use rustc_plugin::Registry; #[plugin_registrar] pub fn plugin_registrar(reg: &mut Registry) { reg.register_syntax_extension( - token::intern("derive_TotalSum"), + Symbol::intern("derive_TotalSum"), MultiDecorator(box expand)); } diff --git a/src/test/run-pass-fulldeps/auxiliary/lint_plugin_test.rs b/src/test/run-pass-fulldeps/auxiliary/lint_plugin_test.rs index 8ea131da338cb..8647797270f9a 100644 --- a/src/test/run-pass-fulldeps/auxiliary/lint_plugin_test.rs +++ b/src/test/run-pass-fulldeps/auxiliary/lint_plugin_test.rs @@ -36,7 +36,7 @@ impl LintPass for Pass { impl EarlyLintPass for Pass { fn check_item(&mut self, cx: &EarlyContext, it: &ast::Item) { - if it.ident.name.as_str() == "lintme" { + if it.ident.name == "lintme" { cx.span_lint(TEST_LINT, it.span, "item is named 'lintme'"); } } diff --git a/src/test/run-pass-fulldeps/auxiliary/macro_crate_test.rs b/src/test/run-pass-fulldeps/auxiliary/macro_crate_test.rs index 7257444ee8703..29cc6b7db9474 100644 --- a/src/test/run-pass-fulldeps/auxiliary/macro_crate_test.rs +++ b/src/test/run-pass-fulldeps/auxiliary/macro_crate_test.rs @@ -23,6 +23,7 @@ use syntax::ext::base::*; use syntax::ext::quote::rt::ToTokens; use syntax::parse::{self, token}; use syntax::ptr::P; +use syntax::symbol::Symbol; use syntax::tokenstream::TokenTree; use syntax_pos::Span; use rustc_plugin::Registry; @@ -36,15 +37,15 @@ pub fn plugin_registrar(reg: &mut Registry) { reg.register_macro("make_a_1", expand_make_a_1); reg.register_macro("identity", expand_identity); reg.register_syntax_extension( - token::intern("into_multi_foo"), + Symbol::intern("into_multi_foo"), // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. MultiModifier(Box::new(expand_into_foo_multi))); reg.register_syntax_extension( - token::intern("duplicate"), + Symbol::intern("duplicate"), // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. MultiDecorator(Box::new(expand_duplicate))); reg.register_syntax_extension( - token::intern("caller"), + Symbol::intern("caller"), // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. MultiDecorator(Box::new(expand_caller))); } @@ -108,9 +109,9 @@ fn expand_duplicate(cx: &mut ExtCtxt, it: &Annotatable, push: &mut FnMut(Annotatable)) { let copy_name = match mi.node { - ast::MetaItemKind::List(_, ref xs) => { + ast::MetaItemKind::List(ref xs) => { if let Some(word) = xs[0].word() { - token::str_to_ident(&word.name()) + ast::Ident::with_empty_ctxt(word.name()) } else { cx.span_err(mi.span, "Expected word"); return; @@ -179,7 +180,7 @@ fn expand_caller(cx: &mut ExtCtxt, } let fn_name = match list[0].name() { - Some(name) => token::str_to_ident(&name), + Some(name) => ast::Ident::with_empty_ctxt(name), None => cx.span_fatal(list[0].span(), "First parameter must be an ident.") }; diff --git a/src/test/run-pass-fulldeps/auxiliary/plugin_args.rs b/src/test/run-pass-fulldeps/auxiliary/plugin_args.rs index f21c914a76c9c..ba2af77cdb297 100644 --- a/src/test/run-pass-fulldeps/auxiliary/plugin_args.rs +++ b/src/test/run-pass-fulldeps/auxiliary/plugin_args.rs @@ -22,9 +22,9 @@ use std::borrow::ToOwned; use syntax::ast; use syntax::ext::build::AstBuilder; use syntax::ext::base::{TTMacroExpander, ExtCtxt, MacResult, MacEager, NormalTT}; -use syntax::parse::token; use syntax::print::pprust; use syntax::ptr::P; +use syntax::symbol::Symbol; use syntax_pos::Span; use syntax::tokenstream; use rustc_plugin::Registry; @@ -40,15 +40,14 @@ impl TTMacroExpander for Expander { _: &[tokenstream::TokenTree]) -> Box { let args = self.args.iter().map(|i| pprust::meta_list_item_to_string(i)) .collect::>().join(", "); - let interned = token::intern_and_get_ident(&args[..]); - MacEager::expr(ecx.expr_str(sp, interned)) + MacEager::expr(ecx.expr_str(sp, Symbol::intern(&args))) } } #[plugin_registrar] pub fn plugin_registrar(reg: &mut Registry) { let args = reg.args().to_owned(); - reg.register_syntax_extension(token::intern("plugin_args"), + reg.register_syntax_extension(Symbol::intern("plugin_args"), // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. NormalTT(Box::new(Expander { args: args, }), None, false)); } diff --git a/src/test/run-pass-fulldeps/auxiliary/proc_macro_def.rs b/src/test/run-pass-fulldeps/auxiliary/proc_macro_def.rs index 9fce19f46f65c..f97fb04aadf6a 100644 --- a/src/test/run-pass-fulldeps/auxiliary/proc_macro_def.rs +++ b/src/test/run-pass-fulldeps/auxiliary/proc_macro_def.rs @@ -18,18 +18,19 @@ use proc_macro_tokens::prelude::*; use rustc_plugin::Registry; use syntax::ext::base::SyntaxExtension; use syntax::ext::proc_macro_shim::prelude::*; +use syntax::symbol::Symbol; #[plugin_registrar] pub fn plugin_registrar(reg: &mut Registry) { - reg.register_syntax_extension(token::intern("attr_tru"), + reg.register_syntax_extension(Symbol::intern("attr_tru"), SyntaxExtension::AttrProcMacro(Box::new(attr_tru))); - reg.register_syntax_extension(token::intern("attr_identity"), + reg.register_syntax_extension(Symbol::intern("attr_identity"), SyntaxExtension::AttrProcMacro(Box::new(attr_identity))); - reg.register_syntax_extension(token::intern("tru"), + reg.register_syntax_extension(Symbol::intern("tru"), SyntaxExtension::ProcMacro(Box::new(tru))); - reg.register_syntax_extension(token::intern("ret_tru"), + reg.register_syntax_extension(Symbol::intern("ret_tru"), SyntaxExtension::ProcMacro(Box::new(ret_tru))); - reg.register_syntax_extension(token::intern("identity"), + reg.register_syntax_extension(Symbol::intern("identity"), SyntaxExtension::ProcMacro(Box::new(identity))); } diff --git a/src/test/run-pass-fulldeps/auxiliary/procedural_mbe_matching.rs b/src/test/run-pass-fulldeps/auxiliary/procedural_mbe_matching.rs index 6ac0d5ad1a3bc..2b3857048f367 100644 --- a/src/test/run-pass-fulldeps/auxiliary/procedural_mbe_matching.rs +++ b/src/test/run-pass-fulldeps/auxiliary/procedural_mbe_matching.rs @@ -18,8 +18,8 @@ extern crate syntax_pos; extern crate rustc; extern crate rustc_plugin; -use syntax::parse::token::{str_to_ident, NtExpr, NtPat}; -use syntax::ast::{Pat}; +use syntax::parse::token::{NtExpr, NtPat}; +use syntax::ast::{Ident, Pat}; use syntax::tokenstream::{TokenTree}; use syntax::ext::base::{ExtCtxt, MacResult, MacEager}; use syntax::ext::build::AstBuilder; @@ -44,12 +44,12 @@ fn expand_mbe_matches(cx: &mut ExtCtxt, _: Span, args: &[TokenTree]) } }; - let matched_nt = match *map[&str_to_ident("matched")] { + let matched_nt = match *map[&Ident::from_str("matched")] { MatchedNonterminal(ref nt) => nt.clone(), _ => unreachable!(), }; - let mac_expr = match (&*matched_nt, &*map[&str_to_ident("pat")]) { + let mac_expr = match (&*matched_nt, &*map[&Ident::from_str("pat")]) { (&NtExpr(ref matched_expr), &MatchedSeq(ref pats, seq_sp)) => { let pats: Vec> = pats.iter().map(|pat_nt| { match **pat_nt { diff --git a/src/test/run-pass-fulldeps/macro-quote-1.rs b/src/test/run-pass-fulldeps/macro-quote-1.rs index 914da3f746773..948b20c14771f 100644 --- a/src/test/run-pass-fulldeps/macro-quote-1.rs +++ b/src/test/run-pass-fulldeps/macro-quote-1.rs @@ -18,9 +18,6 @@ extern crate proc_macro_tokens; use proc_macro_tokens::prelude::*; extern crate syntax; -use syntax::ast::Ident; -use syntax::codemap::DUMMY_SP; -use syntax::parse::token::{self, Token, keywords, str_to_ident}; fn main() { let lex_true = lex("true"); diff --git a/src/test/run-pass-fulldeps/qquote.rs b/src/test/run-pass-fulldeps/qquote.rs index 7c0c24163fe61..b4ed57192ccf6 100644 --- a/src/test/run-pass-fulldeps/qquote.rs +++ b/src/test/run-pass-fulldeps/qquote.rs @@ -16,7 +16,7 @@ extern crate syntax; extern crate syntax_pos; use syntax::print::pprust::*; -use syntax::parse::token::intern; +use syntax::symbol::Symbol; use syntax_pos::DUMMY_SP; fn main() { @@ -29,7 +29,7 @@ fn main() { cx.bt_push(syntax::codemap::ExpnInfo { call_site: DUMMY_SP, callee: syntax::codemap::NameAndSpan { - format: syntax::codemap::MacroBang(intern("")), + format: syntax::codemap::MacroBang(Symbol::intern("")), allow_internal_unstable: false, span: None, } @@ -97,7 +97,7 @@ fn main() { // quote_meta_item! let meta = quote_meta_item!(cx, cfg(foo = "bar")); - check!(meta_item_to_string, meta, *quote_meta_item!(cx, $meta); r#"cfg(foo = "bar")"#); + check!(meta_item_to_string, meta, quote_meta_item!(cx, $meta); r#"cfg(foo = "bar")"#); let attr = quote_attr!(cx, #![$meta]); check!(attribute_to_string, attr; r#"#![cfg(foo = "bar")]"#);