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

@ -7,9 +7,8 @@ use rustc_infer::infer::TyCtxtInferExt;
use rustc_middle::span_bug;
use rustc_middle::ty::{self, Ty, TyCtxt, TypingMode};
use rustc_session::config::EntryFnType;
use rustc_span::Span;
use rustc_span::def_id::{CRATE_DEF_ID, DefId, LocalDefId};
use rustc_span::symbol::sym;
use rustc_span::{Span, sym};
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
use rustc_trait_selection::traits::{self, ObligationCause, ObligationCauseCode};

View file

@ -8,8 +8,7 @@ use rustc_middle::bug;
use rustc_middle::traits::{ObligationCause, ObligationCauseCode};
use rustc_middle::ty::{self, Ty, TyCtxt};
use rustc_span::def_id::LocalDefId;
use rustc_span::symbol::sym;
use rustc_span::{Span, Symbol};
use rustc_span::{Span, Symbol, sym};
use crate::check::check_function_signature;
use crate::errors::{

View file

@ -89,8 +89,7 @@ use rustc_middle::ty::{self, GenericArgs, GenericArgsRef, Ty, TyCtxt, TypingMode
use rustc_middle::{bug, span_bug};
use rustc_session::parse::feature_err;
use rustc_span::def_id::CRATE_DEF_ID;
use rustc_span::symbol::{Ident, kw, sym};
use rustc_span::{BytePos, DUMMY_SP, Span, Symbol};
use rustc_span::{BytePos, DUMMY_SP, Ident, Span, Symbol, kw, sym};
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
use rustc_trait_selection::error_reporting::infer::ObligationCauseExt as _;
use rustc_trait_selection::error_reporting::traits::suggestions::ReturnsVisitor;

View file

@ -23,8 +23,7 @@ use rustc_middle::ty::{
};
use rustc_middle::{bug, span_bug};
use rustc_session::parse::feature_err;
use rustc_span::symbol::{Ident, sym};
use rustc_span::{DUMMY_SP, Span};
use rustc_span::{DUMMY_SP, Ident, Span, sym};
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
use rustc_trait_selection::regions::InferCtxtRegionExt;
use rustc_trait_selection::traits::misc::{

View file

@ -13,8 +13,7 @@ use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_middle::bug;
use rustc_middle::ty::fast_reject::{SimplifiedType, TreatParams, simplify_type};
use rustc_middle::ty::{self, CrateInherentImpls, Ty, TyCtxt};
use rustc_span::ErrorGuaranteed;
use rustc_span::symbol::sym;
use rustc_span::{ErrorGuaranteed, sym};
use crate::errors;

View file

@ -38,8 +38,7 @@ use rustc_middle::ty::fold::fold_regions;
use rustc_middle::ty::util::{Discr, IntTypeExt};
use rustc_middle::ty::{self, AdtKind, Const, IsSuggestable, Ty, TyCtxt, TypingMode};
use rustc_middle::{bug, span_bug};
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_trait_selection::error_reporting::traits::suggestions::NextTypeParamName;
use rustc_trait_selection::infer::InferCtxtExt;
use rustc_trait_selection::traits::ObligationCtxt;

View file

@ -8,8 +8,7 @@ use rustc_hir::def::DefKind;
use rustc_hir::def_id::LocalDefId;
use rustc_middle::ty::{self, TyCtxt};
use rustc_session::lint;
use rustc_span::Span;
use rustc_span::symbol::{Symbol, kw};
use rustc_span::{Span, Symbol, kw};
use tracing::{debug, instrument};
use crate::delegation::inherit_generics_for_delegation_item;

View file

@ -9,8 +9,7 @@ use rustc_middle::ty::{
self, GenericPredicates, ImplTraitInTraitData, Ty, TyCtxt, TypeVisitable, TypeVisitor, Upcast,
};
use rustc_middle::{bug, span_bug};
use rustc_span::symbol::Ident;
use rustc_span::{DUMMY_SP, Span};
use rustc_span::{DUMMY_SP, Ident, Span};
use tracing::{debug, instrument, trace};
use super::item_bounds::explicit_item_bounds_with_filter;

View file

@ -26,9 +26,8 @@ use rustc_middle::middle::resolve_bound_vars::*;
use rustc_middle::query::Providers;
use rustc_middle::ty::{self, TyCtxt, TypeSuperVisitable, TypeVisitor};
use rustc_middle::{bug, span_bug};
use rustc_span::Span;
use rustc_span::def_id::{DefId, LocalDefId, LocalDefIdMap};
use rustc_span::symbol::{Ident, sym};
use rustc_span::{Ident, Span, sym};
use tracing::{debug, debug_span, instrument};
use crate::errors;

View file

@ -10,8 +10,7 @@ use rustc_middle::ty::print::with_forced_trimmed_paths;
use rustc_middle::ty::util::IntTypeExt;
use rustc_middle::ty::{self, Article, IsSuggestable, Ty, TyCtxt, TypeVisitableExt};
use rustc_middle::{bug, span_bug};
use rustc_span::symbol::Ident;
use rustc_span::{DUMMY_SP, Span};
use rustc_span::{DUMMY_SP, Ident, Span};
use super::{ItemCtxt, bad_placeholder};
use crate::errors::TypeofReservedKeywordUsed;
@ -473,7 +472,7 @@ fn infer_placeholder_type<'tcx>(
fn check_feature_inherent_assoc_ty(tcx: TyCtxt<'_>, span: Span) {
if !tcx.features().inherent_associated_types() {
use rustc_session::parse::feature_err;
use rustc_span::symbol::sym;
use rustc_span::sym;
feature_err(
&tcx.sess,
sym::inherent_associated_types,

View file

@ -6,8 +6,7 @@ use rustc_errors::{
};
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
use rustc_middle::ty::Ty;
use rustc_span::symbol::Ident;
use rustc_span::{Span, Symbol};
use rustc_span::{Ident, Span, Symbol};
use crate::fluent_generated as fluent;
mod pattern_types;

View file

@ -9,8 +9,7 @@ use rustc_hir::def::{DefKind, Res};
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_middle::bug;
use rustc_middle::ty::{self as ty, IsSuggestable, Ty, TyCtxt};
use rustc_span::symbol::Ident;
use rustc_span::{ErrorGuaranteed, Span, Symbol, sym};
use rustc_span::{ErrorGuaranteed, Ident, Span, Symbol, kw, sym};
use rustc_trait_selection::traits;
use rustc_type_ir::visit::{TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor};
use smallvec::SmallVec;
@ -745,7 +744,7 @@ fn check_assoc_const_binding_type<'tcx>(
let generics = tcx.generics_of(enclosing_item_owner_id);
for index in collector.params {
let param = generics.param_at(index as _, tcx);
let is_self_param = param.name == rustc_span::symbol::kw::SelfUpper;
let is_self_param = param.name == kw::SelfUpper;
guar.get_or_insert(cx.dcx().emit_err(crate::errors::ParamInTyOfAssocConstBinding {
span: assoc_const.span,
assoc_const,

View file

@ -16,8 +16,7 @@ use rustc_middle::ty::{
};
use rustc_session::parse::feature_err;
use rustc_span::edit_distance::find_best_match_for_name;
use rustc_span::symbol::{Ident, kw, sym};
use rustc_span::{BytePos, DUMMY_SP, Span, Symbol};
use rustc_span::{BytePos, DUMMY_SP, Ident, Span, Symbol, kw, sym};
use rustc_trait_selection::error_reporting::traits::report_dyn_incompatibility;
use rustc_trait_selection::traits::{
FulfillmentError, TraitAliasExpansionInfo, dyn_compatibility_violations_for_assoc_item,

View file

@ -9,7 +9,7 @@ use rustc_middle::ty::{
self, GenericArgsRef, GenericParamDef, GenericParamDefKind, IsSuggestable, Ty,
};
use rustc_session::lint::builtin::LATE_BOUND_LIFETIME_ARGUMENTS;
use rustc_span::symbol::{kw, sym};
use rustc_span::{kw, sym};
use smallvec::SmallVec;
use tracing::{debug, instrument};

View file

@ -45,8 +45,7 @@ use rustc_middle::ty::{
use rustc_middle::{bug, span_bug};
use rustc_session::lint::builtin::AMBIGUOUS_ASSOCIATED_ITEMS;
use rustc_span::edit_distance::find_best_match_for_name;
use rustc_span::symbol::{Ident, Symbol, kw};
use rustc_span::{DUMMY_SP, Span};
use rustc_span::{DUMMY_SP, Ident, Span, Symbol, kw};
use rustc_trait_selection::infer::InferCtxtExt;
use rustc_trait_selection::traits::wf::object_region_bounds;
use rustc_trait_selection::traits::{self, ObligationCtxt};

View file

@ -2,7 +2,7 @@ use std::fmt::Write;
use rustc_hir::def_id::{CRATE_DEF_ID, LocalDefId};
use rustc_middle::ty::{GenericArgs, TyCtxt};
use rustc_span::symbol::sym;
use rustc_span::sym;
fn format_variances(tcx: TyCtxt<'_>, def_id: LocalDefId) -> String {
let variances = tcx.variances_of(def_id);