1
Fork 0

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:
Nicholas Nethercote 2024-12-13 10:29:23 +11:00
parent 7e6bf003f3
commit 2620eb42d7
335 changed files with 371 additions and 617 deletions

View file

@ -2,8 +2,7 @@ use rustc_ast::token::{self, Delimiter};
use rustc_ast::{self as ast, Attribute, attr};
use rustc_errors::codes::*;
use rustc_errors::{Diag, PResult};
use rustc_span::symbol::kw;
use rustc_span::{BytePos, Span};
use rustc_span::{BytePos, Span, kw};
use thin_vec::ThinVec;
use tracing::debug;

View file

@ -22,8 +22,8 @@ use rustc_errors::{
use rustc_session::errors::ExprParenthesesNeeded;
use rustc_span::edit_distance::find_best_match_for_name;
use rustc_span::source_map::Spanned;
use rustc_span::symbol::{AllKeywords, Ident, kw, sym};
use rustc_span::{BytePos, DUMMY_SP, Span, SpanSnippetError, Symbol};
use rustc_span::symbol::AllKeywords;
use rustc_span::{BytePos, DUMMY_SP, Ident, Span, SpanSnippetError, Symbol, kw, sym};
use thin_vec::{ThinVec, thin_vec};
use tracing::{debug, trace};

View file

@ -26,8 +26,7 @@ use rustc_session::errors::{ExprParenthesesNeeded, report_lit_error};
use rustc_session::lint::BuiltinLintDiag;
use rustc_session::lint::builtin::BREAK_WITH_LABEL_AND_LOOP;
use rustc_span::source_map::{self, Spanned};
use rustc_span::symbol::{Ident, Symbol, kw, sym};
use rustc_span::{BytePos, ErrorGuaranteed, Pos, Span};
use rustc_span::{BytePos, ErrorGuaranteed, Ident, Pos, Span, Symbol, kw, sym};
use thin_vec::{ThinVec, thin_vec};
use tracing::instrument;

View file

@ -4,8 +4,7 @@ use rustc_ast::{
WhereClause, token,
};
use rustc_errors::{Applicability, PResult};
use rustc_span::Span;
use rustc_span::symbol::{Ident, kw};
use rustc_span::{Ident, Span, kw};
use thin_vec::ThinVec;
use super::{ForceCollect, Parser, Trailing, UsePreAttrPos};

View file

@ -13,8 +13,7 @@ use rustc_errors::codes::*;
use rustc_errors::{Applicability, PResult, StashKey, struct_span_code_err};
use rustc_span::edit_distance::edit_distance;
use rustc_span::edition::Edition;
use rustc_span::symbol::{Ident, Symbol, kw, sym};
use rustc_span::{DUMMY_SP, ErrorGuaranteed, Span, source_map};
use rustc_span::{DUMMY_SP, ErrorGuaranteed, Ident, Span, Symbol, kw, source_map, sym};
use thin_vec::{ThinVec, thin_vec};
use tracing::debug;

View file

@ -39,8 +39,7 @@ use rustc_data_structures::sync::Lrc;
use rustc_errors::{Applicability, Diag, FatalError, MultiSpan, PResult};
use rustc_index::interval::IntervalSet;
use rustc_session::parse::ParseSess;
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;
use tracing::debug;

View file

@ -1,8 +1,7 @@
use rustc_ast as ast;
use rustc_ast::mut_visit::MutVisitor;
use rustc_ast_pretty::pprust;
use rustc_span::create_default_session_globals_then;
use rustc_span::symbol::Ident;
use rustc_span::{Ident, create_default_session_globals_then};
use crate::parser::tests::{matches_codepattern, string_to_crate};

View file

@ -9,7 +9,7 @@ use rustc_ast::token::{
use rustc_ast_pretty::pprust;
use rustc_data_structures::sync::Lrc;
use rustc_errors::PResult;
use rustc_span::symbol::{Ident, kw};
use rustc_span::{Ident, kw};
use crate::errors::UnexpectedNonterminal;
use crate::parser::pat::{CommaRecoveryMode, RecoverColon, RecoverComma};

View file

@ -13,8 +13,7 @@ use rustc_ast_pretty::pprust;
use rustc_errors::{Applicability, Diag, DiagArgValue, PResult, StashKey};
use rustc_session::errors::ExprParenthesesNeeded;
use rustc_span::source_map::{Spanned, respan};
use rustc_span::symbol::{Ident, kw, sym};
use rustc_span::{BytePos, ErrorGuaranteed, Span};
use rustc_span::{BytePos, ErrorGuaranteed, Ident, Span, kw, sym};
use thin_vec::{ThinVec, thin_vec};
use super::{ForceCollect, Parser, PathStyle, Restrictions, Trailing, UsePreAttrPos};

View file

@ -9,8 +9,7 @@ use rustc_ast::{
Path, PathSegment, QSelf,
};
use rustc_errors::{Applicability, Diag, PResult};
use rustc_span::symbol::{Ident, kw, sym};
use rustc_span::{BytePos, Span};
use rustc_span::{BytePos, Ident, Span, kw, sym};
use thin_vec::ThinVec;
use tracing::debug;

View file

@ -12,8 +12,7 @@ use rustc_ast::{
LocalKind, MacCall, MacCallStmt, MacStmtStyle, Recovered, Stmt, StmtKind,
};
use rustc_errors::{Applicability, Diag, PResult};
use rustc_span::symbol::{Ident, kw, sym};
use rustc_span::{BytePos, ErrorGuaranteed, Span};
use rustc_span::{BytePos, ErrorGuaranteed, Ident, Span, kw, sym};
use thin_vec::{ThinVec, thin_vec};
use super::attr::InnerAttrForbiddenReason;

View file

@ -18,8 +18,9 @@ use rustc_errors::emitter::{HumanEmitter, OutputTheme};
use rustc_errors::{DiagCtxt, MultiSpan, PResult};
use rustc_session::parse::ParseSess;
use rustc_span::source_map::{FilePathMapping, SourceMap};
use rustc_span::symbol::{Symbol, kw, sym};
use rustc_span::{BytePos, FileName, Pos, Span, create_default_session_globals_then};
use rustc_span::{
BytePos, FileName, Pos, Span, Symbol, create_default_session_globals_then, kw, sym,
};
use termcolor::WriteColor;
use crate::parser::{ForceCollect, Parser};

View file

@ -8,8 +8,7 @@ use rustc_ast::{
TyKind, UnsafeBinderTy,
};
use rustc_errors::{Applicability, PResult};
use rustc_span::symbol::{Ident, kw, sym};
use rustc_span::{ErrorGuaranteed, Span};
use rustc_span::{ErrorGuaranteed, Ident, Span, kw, sym};
use thin_vec::{ThinVec, thin_vec};
use super::{Parser, PathStyle, SeqSep, TokenType, Trailing};