diff options
| author | bors <bors@rust-lang.org> | 2019-05-18 02:10:21 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-05-18 02:10:21 +0000 |
| commit | 548add7f61bfcbe3bea3f5ccefb53c84da8fefe4 (patch) | |
| tree | c033c6bf9f7e7646613ea8ce0125c511fd2483c9 /src/libsyntax | |
| parent | a614cee22e8d79766c6a6d0f63c28f12eaec63f4 (diff) | |
| parent | 4ab5fe3f97a260f2cb2b3c06a9a841a05a659e57 (diff) | |
| download | rust-548add7f61bfcbe3bea3f5ccefb53c84da8fefe4.tar.gz rust-548add7f61bfcbe3bea3f5ccefb53c84da8fefe4.zip | |
Auto merge of #60910 - nnethercote:avoid-some-unnecessary-interning, r=petrochenkov
Avoid some unnecessary interning r? @petrochenkov
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/attr/mod.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 5 | ||||
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 9 | ||||
| -rw-r--r-- | src/libsyntax/std_inject.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/test.rs | 4 |
6 files changed, 22 insertions, 18 deletions
diff --git a/src/libsyntax/attr/mod.rs b/src/libsyntax/attr/mod.rs index d94a3165b0f..592b40df176 100644 --- a/src/libsyntax/attr/mod.rs +++ b/src/libsyntax/attr/mod.rs @@ -22,7 +22,7 @@ use crate::parse::parser::Parser; use crate::parse::{self, ParseSess, PResult}; use crate::parse::token::{self, Token}; use crate::ptr::P; -use crate::symbol::{keywords, Symbol}; +use crate::symbol::{keywords, Symbol, sym}; use crate::ThinVec; use crate::tokenstream::{TokenStream, TokenTree, DelimSpan}; use crate::GLOBALS; @@ -323,7 +323,7 @@ impl Attribute { if self.is_sugared_doc { let comment = self.value_str().unwrap(); let meta = mk_name_value_item_str( - Ident::from_str("doc"), + Ident::with_empty_ctxt(sym::doc), dummy_spanned(Symbol::intern(&strip_doc_comment_decoration(&comment.as_str())))); let mut attr = if self.style == ast::AttrStyle::Outer { mk_attr_outer(self.span, self.id, meta) @@ -414,7 +414,7 @@ pub fn mk_sugared_doc_attr(id: AttrId, text: Symbol, span: Span) -> Attribute { Attribute { id, style, - path: Path::from_ident(Ident::from_str("doc").with_span_pos(span)), + path: Path::from_ident(Ident::with_empty_ctxt(sym::doc).with_span_pos(span)), tokens: MetaItemKind::NameValue(lit).tokens(span), is_sugared_doc: true, span, diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index a286fd83e3c..019ebc8566f 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -1522,19 +1522,19 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> { let include_info = vec![ ast::NestedMetaItem::MetaItem( attr::mk_name_value_item_str( - Ident::from_str("file"), + Ident::with_empty_ctxt(sym::file), dummy_spanned(file), ), ), ast::NestedMetaItem::MetaItem( attr::mk_name_value_item_str( - Ident::from_str("contents"), + Ident::with_empty_ctxt(sym::contents), dummy_spanned(src_interned), ), ), ]; - let include_ident = Ident::from_str("include"); + let include_ident = Ident::with_empty_ctxt(sym::include); let item = attr::mk_list_item(DUMMY_SP, include_ident, include_info); items.push(ast::NestedMetaItem::MetaItem(item)); } @@ -1600,7 +1600,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> { } } - let meta = attr::mk_list_item(DUMMY_SP, Ident::from_str("doc"), items); + let meta = attr::mk_list_item(DUMMY_SP, Ident::with_empty_ctxt(sym::doc), items); match at.style { ast::AttrStyle::Inner => *at = attr::mk_spanned_attr_inner(at.span, at.id, meta), ast::AttrStyle::Outer => *at = attr::mk_spanned_attr_outer(at.span, at.id, meta), diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 3d55267b8e8..24d120376de 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -352,7 +352,7 @@ impl TokenCursor { let body = TokenTree::Delimited( delim_span, token::Bracket, - [TokenTree::Token(sp, token::Ident(ast::Ident::from_str("doc"), false)), + [TokenTree::Token(sp, token::Ident(ast::Ident::with_empty_ctxt(sym::doc), false)), TokenTree::Token(sp, token::Eq), TokenTree::Token(sp, token::Literal( token::StrRaw(Symbol::intern(&stripped), num_of_hashes), None)) @@ -7011,7 +7011,8 @@ impl<'a> Parser<'a> { let attr = Attribute { id: attr::mk_attr_id(), style: ast::AttrStyle::Outer, - path: ast::Path::from_ident(Ident::from_str("warn_directory_ownership")), + path: ast::Path::from_ident( + Ident::with_empty_ctxt(sym::warn_directory_ownership)), tokens: TokenStream::empty(), is_sugared_doc: false, span: syntax_pos::DUMMY_SP, diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 86db7a673d4..cd86d94f4b8 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -13,7 +13,7 @@ use crate::print::pp::{self, Breaks}; use crate::print::pp::Breaks::{Consistent, Inconsistent}; use crate::ptr::P; use crate::std_inject; -use crate::symbol::keywords; +use crate::symbol::{keywords, sym}; use crate::tokenstream::{self, TokenStream, TokenTree}; use rustc_target::spec::abi::{self, Abi}; @@ -89,13 +89,14 @@ pub fn print_crate<'a>(cm: &'a SourceMap, // of the feature gate, so we fake them up here. // #![feature(prelude_import)] - let pi_nested = attr::mk_nested_word_item(ast::Ident::from_str("prelude_import")); - let list = attr::mk_list_item(DUMMY_SP, ast::Ident::from_str("feature"), vec![pi_nested]); + let pi_nested = attr::mk_nested_word_item(ast::Ident::with_empty_ctxt(sym::prelude_import)); + let list = attr::mk_list_item( + DUMMY_SP, ast::Ident::with_empty_ctxt(sym::feature), vec![pi_nested]); let fake_attr = attr::mk_attr_inner(DUMMY_SP, attr::mk_attr_id(), list); s.print_attribute(&fake_attr)?; // #![no_std] - let no_std_meta = attr::mk_word_item(ast::Ident::from_str("no_std")); + let no_std_meta = attr::mk_word_item(ast::Ident::with_empty_ctxt(sym::no_std)); let fake_attr = attr::mk_attr_inner(DUMMY_SP, attr::mk_attr_id(), no_std_meta); s.print_attribute(&fake_attr)?; } diff --git a/src/libsyntax/std_inject.rs b/src/libsyntax/std_inject.rs index f08fdcc6fb5..6784a2abe55 100644 --- a/src/libsyntax/std_inject.rs +++ b/src/libsyntax/std_inject.rs @@ -77,9 +77,11 @@ pub fn maybe_inject_crates_ref( None }; krate.module.items.insert(0, P(ast::Item { - attrs: vec![attr::mk_attr_outer(DUMMY_SP, - attr::mk_attr_id(), - attr::mk_word_item(ast::Ident::from_str("macro_use")))], + attrs: vec![attr::mk_attr_outer( + DUMMY_SP, + attr::mk_attr_id(), + attr::mk_word_item(ast::Ident::with_empty_ctxt(sym::macro_use)) + )], vis: dummy_spanned(ast::VisibilityKind::Inherited), node: ast::ItemKind::ExternCrate(alt_std_name.or(orig_name)), ident: ast::Ident::with_empty_ctxt(rename), diff --git a/src/libsyntax/test.rs b/src/libsyntax/test.rs index 21bc236d00e..3fd0790161c 100644 --- a/src/libsyntax/test.rs +++ b/src/libsyntax/test.rs @@ -171,7 +171,7 @@ impl MutVisitor for EntryPointCleaner { EntryPointType::MainAttr | EntryPointType::Start => item.map(|ast::Item {id, ident, attrs, node, vis, span, tokens}| { - let allow_ident = Ident::from_str("allow"); + let allow_ident = Ident::with_empty_ctxt(sym::allow); let dc_nested = attr::mk_nested_word_item(Ident::from_str("dead_code")); let allow_dead_code_item = attr::mk_list_item(DUMMY_SP, allow_ident, vec![dc_nested]); @@ -215,7 +215,7 @@ fn mk_reexport_mod(cx: &mut TestCtxt<'_>, tests: Vec<Ident>, tested_submods: Vec<(Ident, Ident)>) -> (P<ast::Item>, Ident) { - let super_ = Ident::from_str("super"); + let super_ = Ident::with_empty_ctxt(keywords::Super.name()); let items = tests.into_iter().map(|r| { cx.ext_cx.item_use_simple(DUMMY_SP, dummy_spanned(ast::VisibilityKind::Public), |
