1
Fork 0

Auto merge of #134243 - nnethercote:re-export-more-rustc_span, r=jieyouxu

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 to `rustc_span::`. This is a 300+ net line of code reduction, mostly because many files with two `use rustc_span` items can be reduced to one.

r? `@jieyouxu`
This commit is contained in:
bors 2024-12-18 02:56:38 +00:00
commit a89ca2c85e
335 changed files with 371 additions and 617 deletions

View file

@ -86,8 +86,8 @@ macro_rules! arena_types {
[] dyn_compatibility_violations: rustc_middle::traits::DynCompatibilityViolation,
[] codegen_unit: rustc_middle::mir::mono::CodegenUnit<'tcx>,
[decode] attribute: rustc_hir::Attribute,
[] name_set: rustc_data_structures::unord::UnordSet<rustc_span::symbol::Symbol>,
[] ordered_name_set: rustc_data_structures::fx::FxIndexSet<rustc_span::symbol::Symbol>,
[] name_set: rustc_data_structures::unord::UnordSet<rustc_span::Symbol>,
[] ordered_name_set: rustc_data_structures::fx::FxIndexSet<rustc_span::Symbol>,
[] pats: rustc_middle::ty::PatternKind<'tcx>,
// Note that this deliberately duplicates items in the `rustc_hir::arena`,

View file

@ -64,7 +64,7 @@ pub use rustc_query_system::dep_graph::DepNode;
use rustc_query_system::dep_graph::FingerprintStyle;
pub use rustc_query_system::dep_graph::dep_node::DepKind;
pub(crate) use rustc_query_system::dep_graph::{DepContext, DepNodeParams};
use rustc_span::symbol::Symbol;
use rustc_span::Symbol;
use crate::mir::mono::MonoItem;
use crate::ty::TyCtxt;

View file

@ -12,8 +12,7 @@ use rustc_hir::*;
use rustc_hir_pretty as pprust_hir;
use rustc_middle::hir::nested_filter;
use rustc_span::def_id::StableCrateId;
use rustc_span::symbol::{Ident, Symbol, kw, sym};
use rustc_span::{ErrorGuaranteed, Span};
use rustc_span::{ErrorGuaranteed, Ident, Span, Symbol, kw, sym};
use crate::hir::ModuleItems;
use crate::middle::debugger_visualizer::DebuggerVisualizerFile;

View file

@ -9,7 +9,7 @@ use rustc_session::Session;
use rustc_session::lint::builtin::{self, FORBIDDEN_LINT_GROUPS};
use rustc_session::lint::{FutureIncompatibilityReason, Level, Lint, LintExpectationId, LintId};
use rustc_span::hygiene::{ExpnKind, MacroKind};
use rustc_span::{DUMMY_SP, DesugaringKind, Span, Symbol, symbol};
use rustc_span::{DUMMY_SP, DesugaringKind, Span, Symbol, kw};
use tracing::instrument;
use crate::ty::TyCtxt;
@ -37,7 +37,7 @@ pub enum LintLevelSource {
impl LintLevelSource {
pub fn name(&self) -> Symbol {
match *self {
LintLevelSource::Default => symbol::kw::Default,
LintLevelSource::Default => kw::Default,
LintLevelSource::Node { name, .. } => name,
LintLevelSource::CommandLine(name, _) => name,
}

View file

@ -1,7 +1,7 @@
use rustc_hir::def::Res;
use rustc_macros::{HashStable, TyDecodable, TyEncodable};
use rustc_span::Ident;
use rustc_span::def_id::DefId;
use rustc_span::symbol::Ident;
use smallvec::SmallVec;
use crate::ty;

View file

@ -1,7 +1,7 @@
use rustc_abi::Align;
use rustc_attr_parsing::{InlineAttr, InstructionSetAttr, OptimizeAttr};
use rustc_macros::{HashStable, TyDecodable, TyEncodable};
use rustc_span::symbol::Symbol;
use rustc_span::Symbol;
use rustc_target::spec::SanitizerSet;
use crate::mir::mono::Linkage;

View file

@ -12,7 +12,7 @@ use std::num::IntErrorKind;
use rustc_ast::attr::AttributeExt;
use rustc_session::{Limit, Limits, Session};
use rustc_span::symbol::{Symbol, sym};
use rustc_span::{Symbol, sym};
use crate::error::LimitInvalid;
use crate::query::Providers;

View file

@ -6,8 +6,7 @@ pub mod lang_items;
pub mod lib_features {
use rustc_data_structures::unord::UnordMap;
use rustc_macros::{HashStable, TyDecodable, TyEncodable};
use rustc_span::Span;
use rustc_span::symbol::Symbol;
use rustc_span::{Span, Symbol};
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[derive(HashStable, TyEncodable, TyDecodable)]

View file

@ -18,8 +18,7 @@ use rustc_session::Session;
use rustc_session::lint::builtin::{DEPRECATED, DEPRECATED_IN_FUTURE, SOFT_UNSTABLE};
use rustc_session::lint::{BuiltinLintDiag, DeprecatedSinceKind, Level, Lint, LintBuffer};
use rustc_session::parse::feature_err_issue;
use rustc_span::Span;
use rustc_span::symbol::{Symbol, sym};
use rustc_span::{Span, Symbol, sym};
use tracing::debug;
pub use self::StabilityLevel::*;

View file

@ -5,7 +5,7 @@ use rustc_hir::def_id::DefId;
use rustc_macros::{HashStable, Lift, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable};
use rustc_session::RemapFileNameExt;
use rustc_session::config::RemapPathScopeComponents;
use rustc_span::{DUMMY_SP, Span};
use rustc_span::{DUMMY_SP, Span, Symbol};
use rustc_type_ir::visit::TypeVisitableExt;
use super::interpret::ReportedErrorInfo;
@ -569,7 +569,7 @@ impl<'tcx> TyCtxt<'tcx> {
let topmost = span.ctxt().outer_expn().expansion_cause().unwrap_or(span);
let caller = self.sess.source_map().lookup_char_pos(topmost.lo());
self.const_caller_location(
rustc_span::symbol::Symbol::intern(
Symbol::intern(
&caller
.file
.name

View file

@ -26,8 +26,7 @@ use rustc_index::{Idx, IndexSlice, IndexVec};
use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable};
use rustc_serialize::{Decodable, Encodable};
use rustc_span::source_map::Spanned;
use rustc_span::symbol::Symbol;
use rustc_span::{DUMMY_SP, Span};
use rustc_span::{DUMMY_SP, Span, Symbol};
use tracing::trace;
pub use self::query::*;

View file

@ -13,8 +13,7 @@ use rustc_index::Idx;
use rustc_macros::{HashStable, TyDecodable, TyEncodable};
use rustc_query_system::ich::StableHashingContext;
use rustc_session::config::OptLevel;
use rustc_span::Span;
use rustc_span::symbol::Symbol;
use rustc_span::{Span, Symbol};
use rustc_target::spec::SymbolVisibility;
use tracing::debug;

View file

@ -11,8 +11,7 @@ use rustc_hir::def_id::LocalDefId;
use rustc_index::bit_set::BitMatrix;
use rustc_index::{Idx, IndexVec};
use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable};
use rustc_span::Span;
use rustc_span::symbol::Symbol;
use rustc_span::{Span, Symbol};
use smallvec::SmallVec;
use super::{ConstValue, SourceInfo};

View file

@ -10,10 +10,9 @@ use rustc_hir::CoroutineKind;
use rustc_hir::def_id::DefId;
use rustc_index::IndexVec;
use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable};
use rustc_span::Span;
use rustc_span::def_id::LocalDefId;
use rustc_span::source_map::Spanned;
use rustc_span::symbol::Symbol;
use rustc_span::{Span, Symbol};
use rustc_target::asm::InlineAsmRegOrRegClass;
use smallvec::SmallVec;

View file

@ -332,7 +332,7 @@ trivial! {
rustc_span::ExpnId,
rustc_span::Span,
rustc_span::Symbol,
rustc_span::symbol::Ident,
rustc_span::Ident,
rustc_target::spec::PanicStrategy,
rustc_type_ir::Variance,
u32,

View file

@ -4,8 +4,7 @@ use rustc_hir::def_id::{CrateNum, DefId, LOCAL_CRATE, LocalDefId, LocalModDefId,
use rustc_hir::hir_id::{HirId, OwnerId};
use rustc_query_system::dep_graph::DepNodeIndex;
use rustc_query_system::query::{DefIdCache, DefaultCache, SingleCache, VecCache};
use rustc_span::symbol::{Ident, Symbol};
use rustc_span::{DUMMY_SP, Span};
use rustc_span::{DUMMY_SP, Ident, Span, Symbol};
use crate::infer::canonical::CanonicalQueryInput;
use crate::mir::mono::CollectionMode;

View file

@ -41,8 +41,7 @@ use rustc_session::cstore::{
use rustc_session::lint::LintExpectationId;
use rustc_span::def_id::LOCAL_CRATE;
use rustc_span::source_map::Spanned;
use rustc_span::symbol::Symbol;
use rustc_span::{DUMMY_SP, Span};
use rustc_span::{DUMMY_SP, Span, Symbol};
use rustc_target::spec::PanicStrategy;
use {rustc_abi as abi, rustc_ast as ast, rustc_attr_parsing as attr, rustc_hir as hir};
@ -680,7 +679,7 @@ rustc_queries! {
/// of supertraits that define the given associated type. This is used to avoid
/// cycles in resolving type-dependent associated item paths like `T::Item`.
query explicit_supertraits_containing_assoc_item(
key: (DefId, rustc_span::symbol::Ident)
key: (DefId, rustc_span::Ident)
) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> {
desc { |tcx| "computing the super traits of `{}` with associated type name `{}`",
tcx.def_path_str(key.0),
@ -709,7 +708,7 @@ rustc_queries! {
/// To avoid cycles within the predicates of a single item we compute
/// per-type-parameter predicates for resolving `T::AssocTy`.
query type_param_predicates(
key: (LocalDefId, LocalDefId, rustc_span::symbol::Ident)
key: (LocalDefId, LocalDefId, rustc_span::Ident)
) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> {
desc { |tcx| "computing the bounds for type parameter `{}`", tcx.hir().ty_param_name(key.1) }
}
@ -1284,7 +1283,7 @@ rustc_queries! {
desc { |tcx| "computing target features for inline asm of `{}`", tcx.def_path_str(def_id) }
}
query fn_arg_names(def_id: DefId) -> &'tcx [rustc_span::symbol::Ident] {
query fn_arg_names(def_id: DefId) -> &'tcx [rustc_span::Ident] {
desc { |tcx| "looking up function parameter names for `{}`", tcx.def_path_str(def_id) }
separate_provide_extern
}

View file

@ -799,7 +799,7 @@ macro_rules! impl_ref_decoder {
impl_ref_decoder! {<'tcx>
Span,
rustc_hir::Attribute,
rustc_span::symbol::Ident,
rustc_span::Ident,
ty::Variance,
rustc_span::def_id::DefId,
rustc_span::def_id::LocalDefId,

View file

@ -20,8 +20,7 @@ use rustc_macros::{
Decodable, Encodable, HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable,
};
use rustc_span::def_id::{CRATE_DEF_ID, LocalDefId};
use rustc_span::symbol::Symbol;
use rustc_span::{DUMMY_SP, Span};
use rustc_span::{DUMMY_SP, Span, Symbol};
// FIXME: Remove this import and import via `solve::`
pub use rustc_type_ir::solve::BuiltinImplSource;
use smallvec::{SmallVec, smallvec};

View file

@ -2,7 +2,7 @@ use rustc_data_structures::fx::FxIndexMap;
use rustc_errors::ErrorGuaranteed;
use rustc_hir::def_id::{DefId, DefIdMap};
use rustc_macros::{HashStable, TyDecodable, TyEncodable};
use rustc_span::symbol::sym;
use rustc_span::sym;
use crate::error::StrictCoherenceNeedsNegativeCoherence;
use crate::ty::fast_reject::SimplifiedType;

View file

@ -17,7 +17,7 @@ use rustc_index::{IndexSlice, IndexVec};
use rustc_macros::{HashStable, TyDecodable, TyEncodable};
use rustc_query_system::ich::StableHashingContext;
use rustc_session::DataTypeKind;
use rustc_span::symbol::sym;
use rustc_span::sym;
use rustc_type_ir::solve::AdtDestructorKind;
use tracing::{debug, info, trace};

View file

@ -3,7 +3,7 @@ use rustc_hir as hir;
use rustc_hir::def::{DefKind, Namespace};
use rustc_hir::def_id::DefId;
use rustc_macros::{Decodable, Encodable, HashStable};
use rustc_span::symbol::{Ident, Symbol};
use rustc_span::{Ident, Symbol};
use super::{TyCtxt, Visibility};
use crate::ty;

View file

@ -7,8 +7,7 @@ use rustc_hir::HirId;
use rustc_hir::def_id::LocalDefId;
use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable};
use rustc_span::def_id::LocalDefIdMap;
use rustc_span::symbol::Ident;
use rustc_span::{Span, Symbol};
use rustc_span::{Ident, Span, Symbol};
use super::TyCtxt;
use crate::hir::place::{

View file

@ -548,7 +548,7 @@ macro_rules! impl_arena_copy_decoder {
impl_arena_copy_decoder! {<'tcx>
Span,
rustc_span::symbol::Ident,
rustc_span::Ident,
ty::Variance,
rustc_span::def_id::DefId,
rustc_span::def_id::LocalDefId,

View file

@ -47,8 +47,7 @@ use rustc_session::cstore::{CrateStoreDyn, Untracked};
use rustc_session::lint::Lint;
use rustc_session::{Limit, MetadataKind, Session};
use rustc_span::def_id::{CRATE_DEF_ID, DefPathHash, StableCrateId};
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 rustc_type_ir::TyKind::*;
use rustc_type_ir::fold::TypeFoldable;
use rustc_type_ir::lang_items::TraitSolverLangItem;

View file

@ -2,8 +2,7 @@ use rustc_ast as ast;
use rustc_data_structures::fx::FxHashMap;
use rustc_hir::def_id::DefId;
use rustc_macros::{HashStable, TyDecodable, TyEncodable};
use rustc_span::Span;
use rustc_span::symbol::{Symbol, kw};
use rustc_span::{Span, Symbol, kw};
use tracing::instrument;
use super::{Clause, InstantiatedPredicates, ParamConst, ParamTy, Ty, TyCtxt};

View file

@ -16,8 +16,7 @@ use rustc_hir::def_id::DefId;
use rustc_index::IndexVec;
use rustc_macros::{HashStable, TyDecodable, TyEncodable, extension};
use rustc_session::config::OptLevel;
use rustc_span::symbol::{Symbol, sym};
use rustc_span::{DUMMY_SP, ErrorGuaranteed, Span};
use rustc_span::{DUMMY_SP, ErrorGuaranteed, Span, Symbol, sym};
use rustc_target::callconv::FnAbi;
use rustc_target::spec::{
HasTargetSpec, HasWasmCAbiOpt, HasX86AbiOpt, PanicStrategy, Target, WasmCAbi, X86Abi,

View file

@ -46,8 +46,7 @@ use rustc_serialize::{Decodable, Encodable};
use rustc_session::lint::LintBuffer;
pub use rustc_session::lint::RegisteredTools;
use rustc_span::hygiene::MacroKind;
use rustc_span::symbol::{Ident, Symbol, kw, sym};
use rustc_span::{ExpnId, ExpnKind, Span};
use rustc_span::{ExpnId, ExpnKind, Ident, Span, Symbol, kw, sym};
pub use rustc_type_ir::relate::VarianceDiagInfo;
pub use rustc_type_ir::*;
use tracing::{debug, instrument};

View file

@ -109,7 +109,7 @@ trivially_parameterized_over_tcx! {
rustc_span::Symbol,
rustc_span::def_id::DefPathHash,
rustc_span::hygiene::SyntaxContextData,
rustc_span::symbol::Ident,
rustc_span::Ident,
rustc_type_ir::Variance,
rustc_hir::Attribute,
}

View file

@ -16,8 +16,7 @@ use rustc_hir::definitions::{DefKey, DefPathDataName};
use rustc_macros::{Lift, extension};
use rustc_session::Limit;
use rustc_session::cstore::{ExternCrate, ExternCrateSource};
use rustc_span::symbol::{Ident, Symbol, kw};
use rustc_span::{FileNameDisplayPreference, sym};
use rustc_span::{FileNameDisplayPreference, Ident, Symbol, kw, sym};
use rustc_type_ir::{Upcast as _, elaborate};
use smallvec::SmallVec;

View file

@ -4,8 +4,7 @@ use rustc_data_structures::intern::Interned;
use rustc_errors::MultiSpan;
use rustc_hir::def_id::DefId;
use rustc_macros::{HashStable, TyDecodable, TyEncodable};
use rustc_span::symbol::{Symbol, kw, sym};
use rustc_span::{DUMMY_SP, ErrorGuaranteed};
use rustc_span::{DUMMY_SP, ErrorGuaranteed, Symbol, kw, sym};
use rustc_type_ir::RegionKind as IrRegionKind;
pub use rustc_type_ir::RegionVid;
use tracing::debug;

View file

@ -224,7 +224,6 @@ TrivialTypeTraversalImpls! {
::rustc_ast::InlineAsmOptions,
::rustc_ast::InlineAsmTemplatePiece,
::rustc_ast::NodeId,
::rustc_span::symbol::Symbol,
::rustc_hir::def::Res,
::rustc_hir::def_id::LocalDefId,
::rustc_hir::ByRef,
@ -252,8 +251,9 @@ TrivialTypeTraversalImpls! {
crate::ty::Placeholder<ty::BoundVar>,
crate::ty::LateParamRegion,
crate::ty::adjustment::PointerCoercion,
::rustc_span::Ident,
::rustc_span::Span,
::rustc_span::symbol::Ident,
::rustc_span::Symbol,
ty::BoundVar,
ty::ValTree<'tcx>,
}

View file

@ -15,8 +15,7 @@ use rustc_hir as hir;
use rustc_hir::LangItem;
use rustc_hir::def_id::DefId;
use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeFoldable, extension};
use rustc_span::symbol::{Symbol, sym};
use rustc_span::{DUMMY_SP, Span};
use rustc_span::{DUMMY_SP, Span, Symbol, sym};
use rustc_type_ir::TyKind::*;
use rustc_type_ir::visit::TypeVisitableExt;
use rustc_type_ir::{self as ir, BoundVar, CollectAndApply, DynKind};

View file

@ -4,8 +4,7 @@
use rustc_hir::def_id::DefId;
use rustc_hir::{LangItem, lang_items};
use rustc_span::symbol::Ident;
use rustc_span::{DesugaringKind, Span, sym};
use rustc_span::{DesugaringKind, Ident, Span, sym};
use tracing::debug;
use crate::ty::{AssocItemContainer, GenericArgsRef, Instance, Ty, TyCtxt, TypingEnv};