Re-export more rustc_span::symbol
things from rustc_span
.
`rustc_span::symbol` defines some things that are re-exported from `rustc_span`, such as `Symbol` and `sym`. But it doesn't re-export some closely related things such as `Ident` and `kw`. So you can do `use rustc_span::{Symbol, sym}` but you have to do `use rustc_span::symbol::{Ident, kw}`, which is inconsistent for no good reason. This commit re-exports `Ident`, `kw`, and `MacroRulesNormalizedIdent`, and changes many `rustc_span::symbol::` qualifiers in `compiler/` to `rustc_span::`. This is a 200+ net line of code reduction, mostly because many files with two `use rustc_span` items can be reduced to one.
This commit is contained in:
parent
7e6bf003f3
commit
2620eb42d7
335 changed files with 371 additions and 617 deletions
|
@ -25,8 +25,7 @@ use rustc_span::def_id::{CrateNum, DefId, LocalDefId};
|
|||
use rustc_span::edition::Edition;
|
||||
use rustc_span::hygiene::{AstPass, ExpnData, ExpnKind, LocalExpnId, MacroKind};
|
||||
use rustc_span::source_map::SourceMap;
|
||||
use rustc_span::symbol::{Ident, Symbol, kw, sym};
|
||||
use rustc_span::{DUMMY_SP, FileName, Span};
|
||||
use rustc_span::{DUMMY_SP, FileName, Ident, Span, Symbol, kw, sym};
|
||||
use smallvec::{SmallVec, smallvec};
|
||||
use thin_vec::ThinVec;
|
||||
|
||||
|
|
|
@ -4,8 +4,7 @@ use rustc_ast::{
|
|||
self as ast, AttrVec, BlockCheckMode, Expr, LocalKind, MatchKind, PatKind, UnOp, attr, token,
|
||||
};
|
||||
use rustc_span::source_map::Spanned;
|
||||
use rustc_span::symbol::{Ident, Symbol, kw, sym};
|
||||
use rustc_span::{DUMMY_SP, Span};
|
||||
use rustc_span::{DUMMY_SP, Ident, Span, Symbol, kw, sym};
|
||||
use thin_vec::{ThinVec, thin_vec};
|
||||
|
||||
use crate::base::ExtCtxt;
|
||||
|
|
|
@ -18,8 +18,7 @@ use rustc_lint_defs::BuiltinLintDiag;
|
|||
use rustc_parse::validate_attr;
|
||||
use rustc_session::Session;
|
||||
use rustc_session::parse::feature_err;
|
||||
use rustc_span::Span;
|
||||
use rustc_span::symbol::{Symbol, sym};
|
||||
use rustc_span::{Span, Symbol, sym};
|
||||
use thin_vec::ThinVec;
|
||||
use tracing::instrument;
|
||||
|
||||
|
|
|
@ -4,8 +4,7 @@ use rustc_ast::ast;
|
|||
use rustc_errors::codes::*;
|
||||
use rustc_macros::{Diagnostic, Subdiagnostic};
|
||||
use rustc_session::Limit;
|
||||
use rustc_span::symbol::{Ident, MacroRulesNormalizedIdent};
|
||||
use rustc_span::{Span, Symbol};
|
||||
use rustc_span::{Ident, MacroRulesNormalizedIdent, Span, Symbol};
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(expand_expr_repeat_no_syntax_vars)]
|
||||
|
|
|
@ -29,8 +29,7 @@ use rustc_session::lint::builtin::{UNUSED_ATTRIBUTES, UNUSED_DOC_COMMENTS};
|
|||
use rustc_session::parse::feature_err;
|
||||
use rustc_session::{Limit, Session};
|
||||
use rustc_span::hygiene::SyntaxContext;
|
||||
use rustc_span::symbol::{Ident, sym};
|
||||
use rustc_span::{ErrorGuaranteed, FileName, LocalExpnId, Span};
|
||||
use rustc_span::{ErrorGuaranteed, FileName, Ident, LocalExpnId, Span, sym};
|
||||
use smallvec::SmallVec;
|
||||
|
||||
use crate::base::*;
|
||||
|
|
|
@ -16,8 +16,7 @@ use metavar_expr::MetaVarExpr;
|
|||
use rustc_ast::token::{Delimiter, NonterminalKind, Token, TokenKind};
|
||||
use rustc_ast::tokenstream::{DelimSpacing, DelimSpan};
|
||||
use rustc_macros::{Decodable, Encodable};
|
||||
use rustc_span::Span;
|
||||
use rustc_span::symbol::Ident;
|
||||
use rustc_span::{Ident, Span};
|
||||
|
||||
/// Contains the sub-token-trees of a "delimited" token tree such as `(a b c)`.
|
||||
/// The delimiters are not represented explicitly in the `tts` vector.
|
||||
|
|
|
@ -7,8 +7,7 @@ use rustc_macros::Subdiagnostic;
|
|||
use rustc_parse::parser::{Parser, Recovery, token_descr};
|
||||
use rustc_session::parse::ParseSess;
|
||||
use rustc_span::source_map::SourceMap;
|
||||
use rustc_span::symbol::Ident;
|
||||
use rustc_span::{ErrorGuaranteed, Span};
|
||||
use rustc_span::{ErrorGuaranteed, Ident, Span};
|
||||
use tracing::debug;
|
||||
|
||||
use super::macro_rules::{NoopTracker, parser_from_cx};
|
||||
|
|
|
@ -115,8 +115,7 @@ use rustc_lint_defs::BuiltinLintDiag;
|
|||
use rustc_session::lint::builtin::{META_VARIABLE_MISUSE, MISSING_FRAGMENT_SPECIFIER};
|
||||
use rustc_session::parse::ParseSess;
|
||||
use rustc_span::edition::Edition;
|
||||
use rustc_span::symbol::{MacroRulesNormalizedIdent, kw};
|
||||
use rustc_span::{ErrorGuaranteed, Span};
|
||||
use rustc_span::{ErrorGuaranteed, MacroRulesNormalizedIdent, Span, kw};
|
||||
use smallvec::SmallVec;
|
||||
|
||||
use super::quoted::VALID_FRAGMENT_NAMES_MSG;
|
||||
|
|
|
@ -82,8 +82,7 @@ use rustc_data_structures::fx::FxHashMap;
|
|||
use rustc_errors::ErrorGuaranteed;
|
||||
use rustc_lint_defs::pluralize;
|
||||
use rustc_parse::parser::{ParseNtResult, Parser, token_descr};
|
||||
use rustc_span::Span;
|
||||
use rustc_span::symbol::{Ident, MacroRulesNormalizedIdent};
|
||||
use rustc_span::{Ident, MacroRulesNormalizedIdent, Span};
|
||||
|
||||
use crate::mbe::macro_rules::Tracker;
|
||||
use crate::mbe::{KleeneOp, TokenTree};
|
||||
|
|
|
@ -21,10 +21,9 @@ use rustc_lint_defs::builtin::{
|
|||
use rustc_parse::parser::{ParseNtResult, Parser, Recovery};
|
||||
use rustc_session::Session;
|
||||
use rustc_session::parse::ParseSess;
|
||||
use rustc_span::Span;
|
||||
use rustc_span::edition::Edition;
|
||||
use rustc_span::hygiene::Transparency;
|
||||
use rustc_span::symbol::{Ident, MacroRulesNormalizedIdent, kw, sym};
|
||||
use rustc_span::{Ident, MacroRulesNormalizedIdent, Span, kw, sym};
|
||||
use tracing::{debug, instrument, trace, trace_span};
|
||||
|
||||
use super::diagnostics;
|
||||
|
|
|
@ -5,8 +5,7 @@ use rustc_ast_pretty::pprust;
|
|||
use rustc_errors::{Applicability, PResult};
|
||||
use rustc_macros::{Decodable, Encodable};
|
||||
use rustc_session::parse::ParseSess;
|
||||
use rustc_span::symbol::Ident;
|
||||
use rustc_span::{Span, Symbol};
|
||||
use rustc_span::{Ident, Span, Symbol};
|
||||
|
||||
pub(crate) const RAW_IDENT_ERR: &str = "`${concat(..)}` currently does not support raw identifiers";
|
||||
pub(crate) const UNSUPPORTED_CONCAT_ELEM_ERR: &str = "expected identifier or string literal";
|
||||
|
|
|
@ -4,9 +4,8 @@ use rustc_ast_pretty::pprust;
|
|||
use rustc_feature::Features;
|
||||
use rustc_session::Session;
|
||||
use rustc_session::parse::feature_err;
|
||||
use rustc_span::Span;
|
||||
use rustc_span::edition::Edition;
|
||||
use rustc_span::symbol::{Ident, kw, sym};
|
||||
use rustc_span::{Ident, Span, kw, sym};
|
||||
|
||||
use crate::errors;
|
||||
use crate::mbe::macro_parser::count_metavar_decls;
|
||||
|
|
|
@ -11,8 +11,9 @@ use rustc_parse::lexer::nfc_normalize;
|
|||
use rustc_parse::parser::ParseNtResult;
|
||||
use rustc_session::parse::{ParseSess, SymbolGallery};
|
||||
use rustc_span::hygiene::{LocalExpnId, Transparency};
|
||||
use rustc_span::symbol::{Ident, MacroRulesNormalizedIdent, sym};
|
||||
use rustc_span::{Span, Symbol, SyntaxContext, with_metavar_spans};
|
||||
use rustc_span::{
|
||||
Ident, MacroRulesNormalizedIdent, Span, Symbol, SyntaxContext, sym, with_metavar_spans,
|
||||
};
|
||||
use smallvec::{SmallVec, smallvec};
|
||||
|
||||
use crate::errors::{
|
||||
|
|
|
@ -7,8 +7,7 @@ use rustc_errors::{Diag, ErrorGuaranteed};
|
|||
use rustc_parse::{new_parser_from_file, unwrap_or_emit_fatal, validate_attr};
|
||||
use rustc_session::Session;
|
||||
use rustc_session::parse::ParseSess;
|
||||
use rustc_span::Span;
|
||||
use rustc_span::symbol::{Ident, sym};
|
||||
use rustc_span::{Ident, Span, sym};
|
||||
use thin_vec::ThinVec;
|
||||
|
||||
use crate::base::ModuleData;
|
||||
|
|
|
@ -4,8 +4,7 @@ use rustc_ast::token::Delimiter;
|
|||
use rustc_ast::visit::AssocCtxt;
|
||||
use rustc_ast::{self as ast, Safety};
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_span::DUMMY_SP;
|
||||
use rustc_span::symbol::Ident;
|
||||
use rustc_span::{DUMMY_SP, Ident};
|
||||
use smallvec::{SmallVec, smallvec};
|
||||
use thin_vec::ThinVec;
|
||||
|
||||
|
|
|
@ -18,8 +18,7 @@ use rustc_parse::parser::Parser;
|
|||
use rustc_parse::{new_parser_from_source_str, source_str_to_stream, unwrap_or_emit_fatal};
|
||||
use rustc_session::parse::ParseSess;
|
||||
use rustc_span::def_id::CrateNum;
|
||||
use rustc_span::symbol::{self, Symbol, sym};
|
||||
use rustc_span::{BytePos, FileName, Pos, SourceFile, Span};
|
||||
use rustc_span::{BytePos, FileName, Pos, SourceFile, Span, Symbol, sym};
|
||||
use smallvec::{SmallVec, smallvec};
|
||||
|
||||
use crate::base::ExtCtxt;
|
||||
|
@ -230,7 +229,7 @@ impl FromInternal<(TokenStream, &mut Rustc<'_, '_>)> for Vec<TokenTree<TokenStre
|
|||
})),
|
||||
|
||||
Lifetime(name, is_raw) => {
|
||||
let ident = symbol::Ident::new(name, span).without_first_quote();
|
||||
let ident = rustc_span::Ident::new(name, span).without_first_quote();
|
||||
trees.extend([
|
||||
TokenTree::Punct(Punct { ch: b'\'', joint: true, span }),
|
||||
TokenTree::Ident(Ident { sym: ident.name, is_raw: is_raw.into(), span }),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue