diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs index 6d0b142fb2409..e3cd2948d7af5 100644 --- a/src/librustc_resolve/build_reduced_graph.rs +++ b/src/librustc_resolve/build_reduced_graph.rs @@ -305,7 +305,7 @@ impl<'a> Resolver<'a> { } // Empty groups `a::b::{}` are turned into synthetic `self` imports - // `a::b::c::{self as __dummy}`, so that their prefixes are correctly + // `a::b::c::{self as _}`, so that their prefixes are correctly // resolved and checked for privacy/stability/etc. if items.is_empty() && !empty_for_self(&prefix) { let new_span = prefix[prefix.len() - 1].ident.span; @@ -314,7 +314,7 @@ impl<'a> Resolver<'a> { Ident::new(kw::SelfLower, new_span) ), kind: ast::UseTreeKind::Simple( - Some(Ident::from_str_and_span("__dummy", new_span).gensym()), + Some(Ident::new(kw::Underscore, new_span)), ast::DUMMY_NODE_ID, ast::DUMMY_NODE_ID, ), diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index fec7bf3b273ee..7f05e0f477c2d 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -1519,37 +1519,32 @@ impl<'a> NameBinding<'a> { /// /// All other types are defined somewhere and possibly imported, but the primitive ones need /// special handling, since they have no place of origin. -#[derive(Default)] struct PrimitiveTypeTable { primitive_types: FxHashMap, } impl PrimitiveTypeTable { fn new() -> PrimitiveTypeTable { - let mut table = PrimitiveTypeTable::default(); - - table.intern("bool", Bool); - table.intern("char", Char); - table.intern("f32", Float(FloatTy::F32)); - table.intern("f64", Float(FloatTy::F64)); - table.intern("isize", Int(IntTy::Isize)); - table.intern("i8", Int(IntTy::I8)); - table.intern("i16", Int(IntTy::I16)); - table.intern("i32", Int(IntTy::I32)); - table.intern("i64", Int(IntTy::I64)); - table.intern("i128", Int(IntTy::I128)); - table.intern("str", Str); - table.intern("usize", Uint(UintTy::Usize)); - table.intern("u8", Uint(UintTy::U8)); - table.intern("u16", Uint(UintTy::U16)); - table.intern("u32", Uint(UintTy::U32)); - table.intern("u64", Uint(UintTy::U64)); - table.intern("u128", Uint(UintTy::U128)); - table - } - - fn intern(&mut self, string: &str, primitive_type: PrimTy) { - self.primitive_types.insert(Symbol::intern(string), primitive_type); + let mut table = FxHashMap::default(); + + table.insert(sym::bool, Bool); + table.insert(sym::char, Char); + table.insert(sym::f32, Float(FloatTy::F32)); + table.insert(sym::f64, Float(FloatTy::F64)); + table.insert(sym::isize, Int(IntTy::Isize)); + table.insert(sym::i8, Int(IntTy::I8)); + table.insert(sym::i16, Int(IntTy::I16)); + table.insert(sym::i32, Int(IntTy::I32)); + table.insert(sym::i64, Int(IntTy::I64)); + table.insert(sym::i128, Int(IntTy::I128)); + table.insert(sym::str, Str); + table.insert(sym::usize, Uint(UintTy::Usize)); + table.insert(sym::u8, Uint(UintTy::U8)); + table.insert(sym::u16, Uint(UintTy::U16)); + table.insert(sym::u32, Uint(UintTy::U32)); + table.insert(sym::u64, Uint(UintTy::U64)); + table.insert(sym::u128, Uint(UintTy::U128)); + Self { primitive_types: table } } } diff --git a/src/libsyntax/diagnostics/plugin.rs b/src/libsyntax/diagnostics/plugin.rs index 98351048c3526..ee640a1603a6c 100644 --- a/src/libsyntax/diagnostics/plugin.rs +++ b/src/libsyntax/diagnostics/plugin.rs @@ -120,19 +120,7 @@ pub fn expand_register_diagnostic<'cx>(ecx: &'cx mut ExtCtxt<'_>, } }); - let span = span.apply_mark(ecx.current_expansion.mark); - - let name = Ident::from_str_and_span(&format!("__register_diagnostic_{}", code), span).gensym(); - - MacEager::items(smallvec![ - ecx.item_mod( - span, - span, - name, - vec![], - vec![], - ) - ]) + MacEager::items(smallvec![]) } #[allow(deprecated)] diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index 5dbf21867afa6..6b699464ba9a8 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -249,8 +249,9 @@ pub fn compile( def: &ast::Item, edition: Edition ) -> SyntaxExtension { - let lhs_nm = ast::Ident::from_str("lhs").gensym(); - let rhs_nm = ast::Ident::from_str("rhs").gensym(); + let lhs_nm = ast::Ident::new(sym::lhs, def.span); + let rhs_nm = ast::Ident::new(sym::rhs, def.span); + let tt_spec = ast::Ident::new(sym::tt, def.span); // Parse the macro_rules! invocation let body = match def.node { @@ -266,9 +267,9 @@ pub fn compile( let argument_gram = vec![ quoted::TokenTree::Sequence(DelimSpan::dummy(), Lrc::new(quoted::SequenceRepetition { tts: vec![ - quoted::TokenTree::MetaVarDecl(def.span, lhs_nm, ast::Ident::from_str("tt")), + quoted::TokenTree::MetaVarDecl(def.span, lhs_nm, tt_spec), quoted::TokenTree::token(token::FatArrow, def.span), - quoted::TokenTree::MetaVarDecl(def.span, rhs_nm, ast::Ident::from_str("tt")), + quoted::TokenTree::MetaVarDecl(def.span, rhs_nm, tt_spec), ], separator: Some(Token::new( if body.legacy { token::Semi } else { token::Comma }, def.span @@ -1115,10 +1116,9 @@ fn has_legal_fragment_specifier(sess: &ParseSess, tok: "ed::TokenTree) -> Result<(), String> { debug!("has_legal_fragment_specifier({:?})", tok); if let quoted::TokenTree::MetaVarDecl(_, _, ref frag_spec) = *tok { - let frag_name = frag_spec.as_str(); let frag_span = tok.span(); - if !is_legal_fragment_specifier(sess, features, attrs, &frag_name, frag_span) { - return Err(frag_name.to_string()); + if !is_legal_fragment_specifier(sess, features, attrs, frag_spec.name, frag_span) { + return Err(frag_spec.to_string()); } } Ok(()) @@ -1127,7 +1127,7 @@ fn has_legal_fragment_specifier(sess: &ParseSess, fn is_legal_fragment_specifier(_sess: &ParseSess, _features: &Features, _attrs: &[ast::Attribute], - frag_name: &str, + frag_name: Symbol, _frag_span: Span) -> bool { /* * If new fragment specifiers are invented in nightly, `_sess`, @@ -1136,9 +1136,9 @@ fn is_legal_fragment_specifier(_sess: &ParseSess, * this function. */ match frag_name { - "item" | "block" | "stmt" | "expr" | "pat" | "lifetime" | - "path" | "ty" | "ident" | "meta" | "tt" | "vis" | "literal" | - "" => true, + sym::item | sym::block | sym::stmt | sym::expr | sym::pat | + sym::lifetime | sym::path | sym::ty | sym::ident | sym::meta | sym::tt | + sym::vis | sym::literal | kw::Invalid => true, _ => false, } } diff --git a/src/libsyntax/test.rs b/src/libsyntax/test.rs index 1998ec19f13bf..cbaf12529c101 100644 --- a/src/libsyntax/test.rs +++ b/src/libsyntax/test.rs @@ -327,7 +327,7 @@ fn mk_main(cx: &mut TestCtxt<'_>) -> P { // } let sp = ignored_span(cx, DUMMY_SP); let ecx = &cx.ext_cx; - let test_id = ecx.ident_of("test").gensym(); + let test_id = Ident::with_empty_ctxt(sym::test); // test::test_main_static(...) let mut test_runner = cx.test_runner.clone().unwrap_or( @@ -350,7 +350,7 @@ fn mk_main(cx: &mut TestCtxt<'_>) -> P { let test_extern_stmt = ecx.stmt_item(sp, ecx.item(sp, test_id, vec![], - ast::ItemKind::ExternCrate(Some(sym::test)) + ast::ItemKind::ExternCrate(None) )); // pub fn main() { ... } diff --git a/src/libsyntax_pos/symbol.rs b/src/libsyntax_pos/symbol.rs index 9ca64a1231f08..f121fe17a720f 100644 --- a/src/libsyntax_pos/symbol.rs +++ b/src/libsyntax_pos/symbol.rs @@ -157,6 +157,7 @@ symbols! { bin, bind_by_move_pattern_guards, block, + bool, borrowck_graphviz_postflow, borrowck_graphviz_preflow, box_patterns, @@ -171,6 +172,7 @@ symbols! { cfg_target_has_atomic, cfg_target_thread_local, cfg_target_vendor, + char, clone, Clone, clone_closures, @@ -351,6 +353,7 @@ symbols! { label_break_value, lang, lang_items, + lhs, lib, lifetime, link, @@ -511,6 +514,7 @@ symbols! { result, Result, Return, + rhs, rlib, rt, rtm_target_feature,