rust-lang/rust · #162277
Introduce `rustc_middle::middle::resolve`
compiler/rustc_ast/src/ast.rs0 + / 19 −
@@ -29,7 +29,6 @@ use rustc_data_structures::stable_hash::{StableHash, StableHashCtxt, StableHashe use rustc_data_structures::tagged_ptr::Tag; use rustc_macros::{Decodable, Encodable, StableHash, Walkable}; pub use rustc_span::AttrId;-use rustc_span::def_id::LocalDefId; use rustc_span::{ ByteSymbol, DUMMY_SP, ErrorGuaranteed, Ident, LocalExpnId, Span, Spanned, Symbol, kw, respan, sym,@@ -4445,24 +4444,6 @@ impl TryFrom<ItemKind> for ForeignItemKind { } pub type ForeignItem = Item<ForeignItemKind>;--/// Fragment of the AST according to "HIR owner" semantics.-///-/// This is used to map each `LocalDefId` to its content's AST.-#[derive(Debug)]-pub enum AstOwner {- /// This definition does not correspond to a HIR owner.- NonOwner,- /// This definition corresponds to a nested `use` tree.- /// The `LocalDefId` points to its HIR owner.- NestedUseTree(LocalDefId),- Crate(Box<Crate>),- Item(Box<Item>),- TraitItem(Box<AssocItem>),- ImplItem(Box<AssocItem>),- ForeignItem(Box<ForeignItem>),-}- // Some nodes are used a lot. Make sure they don't unintentionally get bigger. #[cfg(target_pointer_width = "64")] mod size_asserts {compiler/rustc_ast_lowering/src/item.rs2 + / 1 −
@@ -8,9 +8,10 @@ use rustc_hir::{ self as hir, CRATE_OWNER_ID, HirId, ImplItemImplKind, LifetimeSource, PredicateOrigin, Target, find_attr, };+use rustc_middle::middle::resolve::ResolverAstLowering; use rustc_middle::span_bug;+use rustc_middle::ty::TyCtxt; use rustc_middle::ty::data_structures::IndexMap;-use rustc_middle::ty::{ResolverAstLowering, TyCtxt}; use rustc_span::def_id::{DefId, LocalDefId}; use rustc_span::edit_distance::find_best_match_for_name; use rustc_span::{DUMMY_SP, DesugaringKind, Ident, Span, Symbol, kw, sym};compiler/rustc_ast_lowering/src/lib.rs5 + / 2 −
@@ -55,7 +55,7 @@ use rustc_data_structures::unord::ExtendUnord; use rustc_errors::codes::*; use rustc_errors::{DiagArgFromDisplay, DiagCtxtHandle, ErrorGuaranteed}; use rustc_hir::attrs::lang_items::LangItem;-use rustc_hir::def::{DefKind, LifetimeRes, Namespace, PartialRes, PerNS, Res};+use rustc_hir::def::{DefKind, Namespace, PerNS, Res}; use rustc_hir::def_id::{DefId, LOCAL_CRATE, LocalDefId, LocalDefIdMap}; use rustc_hir::definitions::PerParentDisambiguatorState; use rustc_hir::lints::DelayedLint;@@ -65,9 +65,12 @@ use rustc_hir::{ }; use rustc_index::{Idx, IndexVec}; use rustc_macros::extension;+use rustc_middle::middle::resolve::{+ AstOwner, LifetimeRes, PartialRes, PerOwnerResolverData, ResolverAstLowering,+}; use rustc_middle::queries::Providers; use rustc_middle::span_bug;-use rustc_middle::ty::{PerOwnerResolverData, ResolverAstLowering, TyCtxt};+use rustc_middle::ty::TyCtxt; use rustc_session::diagnostics::add_feature_diagnostics; use rustc_span::symbol::{Ident, Symbol, kw, sym}; use rustc_span::{DUMMY_SP, DesugaringKind, Span};compiler/rustc_ast_lowering/src/path.rs2 + / 1 −
@@ -2,9 +2,10 @@ use std::sync::Arc; use rustc_ast::{self as ast, *}; use rustc_errors::StashKey;-use rustc_hir::def::{DefKind, PartialRes, PerNS, Res};+use rustc_hir::def::{DefKind, PerNS, Res}; use rustc_hir::def_id::DefId; use rustc_hir::{self as hir, GenericArg};+use rustc_middle::middle::resolve::PartialRes; use rustc_middle::{span_bug, ty}; use rustc_session::diagnostics::add_feature_diagnostics; use rustc_span::{BytePos, DUMMY_SP, DesugaringKind, Ident, Span, Symbol, sym};compiler/rustc_hir/src/def.rs1 + / 99 −
@@ -4,12 +4,11 @@ use std::fmt::Debug; use rustc_ast as ast; use rustc_ast::NodeId;-use rustc_data_structures::fx::FxIndexMap; use rustc_error_messages::{DiagArgValue, IntoDiagArg}; use rustc_hir_id::HirId; use rustc_macros::{Decodable, Encodable, StableHash}; use rustc_span::Symbol;-use rustc_span::def_id::{DefId, LocalDefId};+use rustc_span::def_id::DefId; use rustc_span::hygiene::MacroKind; use crate as hir;@@ -587,63 +586,6 @@ impl<Id> IntoDiagArg for Res<Id> { } } -/// The result of resolving a path before lowering to HIR,-/// with "module" segments resolved and associated item-/// segments deferred to type checking.-/// `base_res` is the resolution of the resolved part of the-/// path, `unresolved_segments` is the number of unresolved-/// segments.-///-/// ```text-/// module::Type::AssocX::AssocY::MethodOrAssocType-/// ^~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-/// base_res unresolved_segments = 3-///-/// <T as Trait>::AssocX::AssocY::MethodOrAssocType-/// ^~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~-/// base_res unresolved_segments = 2-/// ```-#[derive(Copy, Clone, Debug)]-pub struct PartialRes {- base_res: Res<NodeId>,- unresolved_segments: usize,-}--impl PartialRes {- #[inline]- pub fn new(base_res: Res<NodeId>) -> Self {- PartialRes { base_res, unresolved_segments: 0 }- }-- #[inline]- pub fn with_unresolved_segments(base_res: Res<NodeId>, mut unresolved_segments: usize) -> Self {- if base_res == Res::Err {- unresolved_segments = 0- }- PartialRes { base_res, unresolved_segments }- }-- #[inline]- pub fn base_res(&self) -> Res<NodeId> {- self.base_res- }-- #[inline]- pub fn unresolved_segments(&self) -> usize {- self.unresolved_segments- }-- #[inline]- pub fn full_res(&self) -> Option<Res<NodeId>> {- (self.unresolved_segments == 0).then_some(self.base_res)- }-- #[inline]- pub fn expect_full_res(&self) -> Res<NodeId> {- self.full_res().expect("unexpected unresolved segments")- }-}- /// Different kinds of symbols can coexist even if they share the same textual name. /// Therefore, they each have a separate universe (known as a "namespace"). #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Encodable, Decodable)]@@ -933,43 +875,3 @@ impl<Id> Res<Id> { matches!(self, Res::Def(DefKind::Ctor(_, CtorKind::Const), _) | Res::SelfCtor(..)) } }--/// Resolution for a lifetime appearing in a type.-#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]-pub enum LifetimeRes {- /// Successfully linked the lifetime to a generic parameter.- Param {- /// Id of the generic parameter that introduced it.- param: LocalDefId,- /// Id of the introducing place. That can be:- /// - an item's id, for the item's generic parameters;- /// - a TraitRef's ref_id, identifying the `for<...>` binder;- /// - a FnPtr type's id.- ///- /// This information is used for impl-trait lifetime captures, to know when to or not to- /// capture any given lifetime.- binder: NodeId,- },- /// Created a generic parameter for an anonymous lifetime.- Fresh {- /// Id of the generic parameter that introduced it.- ///- /// Creating the associated `LocalDefId` is the responsibility of lowering.- param: NodeId,- /// Kind of elided lifetime- kind: hir::MissingLifetimeKind,- },- /// This variant is used for anonymous lifetimes that we did not resolve during- /// late resolution. Those lifetimes will be inferred by typechecking.- Infer,- /// `'static` lifetime.- Static,- /// Resolution failure.- Error(rustc_span::ErrorGuaranteed),- /// HACK: This is used to recover the NodeId of an elided lifetime.- ElidedAnchor { start: NodeId, end: NodeId },-}--// FxIndexMap is necessary because its data ends up in .rmeta files,-// so its iteration order must be consistent. See #159677 for context.-pub type DocLinkResMap = FxIndexMap<(Symbol, Namespace), Option<Res<NodeId>>>;compiler/rustc_interface/src/passes.rs2 + / 5 −
@@ -30,6 +30,7 @@ use rustc_lint::{BufferedEarlyLint, EarlyCheckNode, LintStore, unerased_lint_sto use rustc_metadata::EncodedMetadata; use rustc_metadata::creader::CStore; use rustc_middle::arena::Arena;+use rustc_middle::middle::resolve::{ResolverAstLowering, ResolverGlobalCtxt}; use rustc_middle::ty::{self, RegisteredTools, TyCtxt}; use rustc_middle::util::Providers; use rustc_parse::lexer::StripTokens;@@ -792,11 +793,7 @@ fn write_out_deps(tcx: TyCtxt<'_>, outputs: &OutputFilenames, out_filenames: &[P fn resolver_for_lowering_raw<'tcx>( tcx: TyCtxt<'tcx>, (): (),-) -> (- &'tcx Steal<ty::ResolverAstLowering<'tcx>>,- &'tcx Steal<ast::Crate>,- &'tcx ty::ResolverGlobalCtxt,-) {+) -> (&'tcx Steal<ResolverAstLowering<'tcx>>, &'tcx Steal<ast::Crate>, &'tcx ResolverGlobalCtxt) { let arenas = WorkerLocal::new(|_| Resolver::arenas()); let _ = tcx.registered_attr_tools(()); // Uses `crate_for_resolver`. let _ = tcx.registered_lint_tools(()); // Uses `crate_for_resolver`.compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs1 + / 1 −
@@ -10,8 +10,8 @@ use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LOCAL_CRATE}; use rustc_hir::definitions::{DefKey, DefPath, DefPathHash}; use rustc_middle::arena::ArenaAllocatable; use rustc_middle::bug;-use rustc_middle::metadata::{AmbigModChild, ModChild}; use rustc_middle::middle::exported_symbols::ExportedSymbol;+use rustc_middle::middle::resolve::{AmbigModChild, ModChild}; use rustc_middle::middle::stability::DeprecationEntry; use rustc_middle::queries::ExternProviders; use rustc_middle::query::LocalCrate;compiler/rustc_metadata/src/rmeta/mod.rs2 + / 2 −
@@ -15,7 +15,7 @@ use rustc_data_structures::svh::Svh; use rustc_hir as hir; use rustc_hir::attrs::StrippedCfgItem; use rustc_hir::attrs::lang_items::LangItem;-use rustc_hir::def::{CtorKind, DefKind, DocLinkResMap, MacroKinds};+use rustc_hir::def::{CtorKind, DefKind, MacroKinds}; use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, DefIndex, DefPathHash, StableCrateId}; use rustc_hir::definitions::DefKey; use rustc_hir::{PreciseCapturingArgKind, attrs};@@ -24,12 +24,12 @@ use rustc_index::bit_set::DenseBitSet; use rustc_macros::{ BlobDecodable, Decodable, Encodable, LazyDecodable, MetadataEncodable, TyDecodable, TyEncodable, };-use rustc_middle::metadata::{AmbigModChild, ModChild}; use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs; use rustc_middle::middle::debugger_visualizer::DebuggerVisualizerFile; use rustc_middle::middle::deduced_param_attrs::DeducedParamAttrs; use rustc_middle::middle::exported_symbols::{ExportedSymbol, SymbolExportInfo}; use rustc_middle::middle::lib_features::FeatureStability;+use rustc_middle::middle::resolve::{AmbigModChild, DocLinkResMap, ModChild}; use rustc_middle::middle::resolve_bound_vars::ObjectLifetimeDefault; use rustc_middle::mir; use rustc_middle::mir::ConstValue;compiler/rustc_metadata/src/rmeta/parameterized.rs3 + / 3 −
@@ -104,18 +104,18 @@ trivially_parameterized_over_tcx! { rustc_hir::attrs::StrippedCfgItem<rustc_hir::def_id::DefIndex>, rustc_hir::attrs::lang_items::LangItem, rustc_hir::def::DefKind,- rustc_hir::def::DocLinkResMap, rustc_hir::def_id::DefId, rustc_hir::def_id::DefIndex, rustc_hir::definitions::DefKey, rustc_index::bit_set::DenseBitSet<u32>,- rustc_middle::metadata::AmbigModChild,- rustc_middle::metadata::ModChild, rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs, rustc_middle::middle::debugger_visualizer::DebuggerVisualizerFile, rustc_middle::middle::deduced_param_attrs::DeducedParamAttrs, rustc_middle::middle::exported_symbols::SymbolExportInfo, rustc_middle::middle::lib_features::FeatureStability,+ rustc_middle::middle::resolve::AmbigModChild,+ rustc_middle::middle::resolve::DocLinkResMap,+ rustc_middle::middle::resolve::ModChild, rustc_middle::middle::resolve_bound_vars::ObjectLifetimeDefault, rustc_middle::mir::ConstQualifs, rustc_middle::mir::ConstValue,compiler/rustc_middle/src/arena.rs9 + / 6 −
@@ -36,18 +36,21 @@ rustc_arena::declare_arena! { rustc_hir::def_id::LocalDefId, rustc_middle::ty::DefinitionSiteHiddenType<'tcx>, >,- resolver: rustc_data_structures::steal::Steal<rustc_middle::ty::ResolverAstLowering<'tcx>>,+ resolver:+ rustc_data_structures::steal::Steal<+ rustc_middle::middle::resolve::ResolverAstLowering<'tcx>+ >, index_ast: rustc_index::IndexVec< rustc_span::def_id::LocalDefId, rustc_data_structures::steal::Steal<(- std::sync::Arc<rustc_middle::ty::ResolverAstLowering<'tcx>>,- rustc_ast::AstOwner+ std::sync::Arc<rustc_middle::middle::resolve::ResolverAstLowering<'tcx>>,+ rustc_middle::middle::resolve::AstOwner )> >, crate_alone: rustc_data_structures::steal::Steal<rustc_ast::Crate>, crate_for_resolver: rustc_data_structures::steal::Steal<(rustc_ast::Crate, rustc_ast::AttrVec)>,- resolutions: rustc_middle::ty::ResolverGlobalCtxt,+ resolutions: rustc_middle::middle::resolve::ResolverGlobalCtxt, const_allocs: rustc_middle::mir::interpret::Allocation, region_scope_tree: rustc_middle::middle::region::ScopeTree, // Required for the incremental on-disk cache@@ -128,9 +131,9 @@ rustc_arena::declare_arena! { rustc_middle::ty::EarlyBinder<'tcx, Ty<'tcx>> >, external_constraints: rustc_middle::traits::solve::ExternalConstraintsData<TyCtxt<'tcx>>,- doc_link_resolutions: rustc_hir::def::DocLinkResMap,+ doc_link_resolutions: rustc_middle::middle::resolve::DocLinkResMap, stripped_cfg_items: rustc_hir::attrs::StrippedCfgItem,- mod_child: rustc_middle::metadata::ModChild,+ mod_child: rustc_middle::middle::resolve::ModChild, features: rustc_feature::Features, specialization_graph: rustc_middle::traits::specialization_graph::Graph, crate_inherent_impls: rustc_middle::ty::CrateInherentImpls,compiler/rustc_middle/src/lib.rs0 + / 1 −
@@ -77,7 +77,6 @@ pub mod hooks; pub mod ich; pub mod infer; pub mod lint;-pub mod metadata; pub mod middle; pub mod mir; pub mod mono;compiler/rustc_middle/src/metadata.rsremoved0 + / 53 −
@@ -1,53 +0,0 @@-use rustc_hir::def::Res;-use rustc_macros::{StableHash, TyDecodable, TyEncodable};-use rustc_span::Ident;-use rustc_span::def_id::{DefId, ModId};-use smallvec::SmallVec;--use crate::ty;--/// A simplified version of `ImportKind` from resolve.-/// `DefId`s here correspond to `use` and `extern crate` items themselves, not their targets.-#[derive(Clone, Copy, Debug, TyEncodable, TyDecodable, StableHash)]-pub enum Reexport {- Single(DefId),- Glob(DefId),- ExternCrate(DefId),- MacroUse,- MacroExport,-}--impl Reexport {- pub fn id(self) -> Option<DefId> {- match self {- Reexport::Single(id) | Reexport::Glob(id) | Reexport::ExternCrate(id) => Some(id),- Reexport::MacroUse | Reexport::MacroExport => None,- }- }-}--/// This structure is supposed to keep enough data to re-create `Decl`s for other crates-/// during name resolution. Right now the bindings are not recreated entirely precisely so we may-/// need to add more data in the future to correctly support macros 2.0, for example.-/// Module child can be either a proper item or a reexport (including private imports).-/// In case of reexport all the fields describe the reexport item itself, not what it refers to.-#[derive(Debug, TyEncodable, TyDecodable, StableHash)]-pub struct ModChild {- /// Name of the item.- pub ident: Ident,- /// Resolution result corresponding to the item.- /// Local variables cannot be exported, so this `Res` doesn't need the ID parameter.- pub res: Res<!>,- /// Visibility of the item.- pub vis: ty::Visibility<ModId>,- /// Reexport chain linking this module child to its original reexported item.- /// Empty if the module child is a proper item.- pub reexport_chain: SmallVec<[Reexport; 2]>,-}--/// Same as `ModChild`, however, it includes ambiguity error.-#[derive(Debug, TyEncodable, TyDecodable, StableHash)]-pub struct AmbigModChild {- pub main: ModChild,- pub second: ModChild,-}compiler/rustc_middle/src/middle/mod.rs1 + / 0 −
@@ -34,5 +34,6 @@ pub mod lib_features { } pub mod privacy; pub mod region;+pub mod resolve; pub mod resolve_bound_vars; pub mod stability;compiler/rustc_middle/src/middle/resolve.rsadded309 + / 0 −
@@ -0,0 +1,309 @@+//! This module contains types that carry name resolution results from `rustc_resolve` to a+//! consumer in another crate (e.g. AST lowering, metadata, or a query).++use rustc_ast::node_id::NodeMap;+use rustc_ast::{self as ast, NodeId};+use rustc_attr_ir::StrippedCfgItem;+use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};+use rustc_data_structures::steal::Steal;+use rustc_data_structures::unord::{UnordMap, UnordSet};+use rustc_errors::{ErrorGuaranteed, LintBuffer};+use rustc_hir::def::{DefKind, Namespace, PerNS, Res};+use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, LocalDefIdMap, LocalModId, ModId};+use rustc_hir::definitions::PerParentDisambiguatorState;+use rustc_hir::{MissingLifetimeKind, TraitCandidate};+use rustc_macros::{StableHash, TyDecodable, TyEncodable};+use rustc_span::{ExpnId, Ident, Span, Symbol};+use smallvec::SmallVec;++use crate::middle::privacy::EffectiveVisibilities;+use crate::ty::Visibility;++/// The result of resolving a path before lowering to HIR,+/// with "module" segments resolved and associated item+/// segments deferred to type checking.+/// `base_res` is the resolution of the resolved part of the+/// path, `unresolved_segments` is the number of unresolved+/// segments.+///+/// ```text+/// module::Type::AssocX::AssocY::MethodOrAssocType+/// ^~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+/// base_res unresolved_segments = 3+///+/// <T as Trait>::AssocX::AssocY::MethodOrAssocType+/// ^~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~+/// base_res unresolved_segments = 2+/// ```+#[derive(Copy, Clone, Debug)]+pub struct PartialRes {+ base_res: Res<NodeId>,+ unresolved_segments: usize,+}++impl PartialRes {+ #[inline]+ pub fn new(base_res: Res<NodeId>) -> Self {+ PartialRes { base_res, unresolved_segments: 0 }+ }++ #[inline]+ pub fn with_unresolved_segments(base_res: Res<NodeId>, mut unresolved_segments: usize) -> Self {+ if base_res == Res::Err {+ unresolved_segments = 0+ }+ PartialRes { base_res, unresolved_segments }+ }++ #[inline]+ pub fn base_res(&self) -> Res<NodeId> {+ self.base_res+ }++ #[inline]+ pub fn unresolved_segments(&self) -> usize {+ self.unresolved_segments+ }++ #[inline]+ pub fn full_res(&self) -> Option<Res<NodeId>> {+ (self.unresolved_segments == 0).then_some(self.base_res)+ }++ #[inline]+ pub fn expect_full_res(&self) -> Res<NodeId> {+ self.full_res().expect("unexpected unresolved segments")+ }+}++/// Resolution for a lifetime appearing in a type.+#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]+pub enum LifetimeRes {+ /// Successfully linked the lifetime to a generic parameter.+ Param {+ /// Id of the generic parameter that introduced it.+ param: LocalDefId,+ /// Id of the introducing place. That can be:+ /// - an item's id, for the item's generic parameters;+ /// - a TraitRef's ref_id, identifying the `for<...>` binder;+ /// - a FnPtr type's id.+ ///+ /// This information is used for impl-trait lifetime captures, to know when to or not to+ /// capture any given lifetime.+ binder: NodeId,+ },+ /// Created a generic parameter for an anonymous lifetime.+ Fresh {+ /// Id of the generic parameter that introduced it.+ ///+ /// Creating the associated `LocalDefId` is the responsibility of lowering.+ param: NodeId,+ /// Kind of elided lifetime+ kind: MissingLifetimeKind,+ },+ /// This variant is used for anonymous lifetimes that we did not resolve during+ /// late resolution. Those lifetimes will be inferred by typechecking.+ Infer,+ /// `'static` lifetime.+ Static,+ /// Resolution failure.+ Error(ErrorGuaranteed),+ /// HACK: This is used to recover the NodeId of an elided lifetime.+ ElidedAnchor { start: NodeId, end: NodeId },+}++/// A simplified version of `ImportKind` from resolve.+/// `DefId`s here correspond to `use` and `extern crate` items themselves, not their targets.+#[derive(Clone, Copy, Debug, TyEncodable, TyDecodable, StableHash)]+pub enum Reexport {+ Single(DefId),+ Glob(DefId),+ ExternCrate(DefId),+ MacroUse,+ MacroExport,+}++impl Reexport {+ pub fn id(self) -> Option<DefId> {+ match self {+ Reexport::Single(id) | Reexport::Glob(id) | Reexport::ExternCrate(id) => Some(id),+ Reexport::MacroUse | Reexport::MacroExport => None,+ }+ }+}++/// This structure is supposed to keep enough data to re-create `Decl`s for other crates+/// during name resolution. Right now the bindings are not recreated entirely precisely so we may+/// need to add more data in the future to correctly support macros 2.0, for example.+/// Module child can be either a proper item or a reexport (including private imports).+/// In case of reexport all the fields describe the reexport item itself, not what it refers to.+#[derive(Debug, TyEncodable, TyDecodable, StableHash)]+pub struct ModChild {+ /// Name of the item.+ pub ident: Ident,+ /// Resolution result corresponding to the item.+ /// Local variables cannot be exported, so this `Res` doesn't need the ID parameter.+ pub res: Res<!>,+ /// Visibility of the item.+ pub vis: Visibility<ModId>,+ /// Reexport chain linking this module child to its original reexported item.+ /// Empty if the module child is a proper item.+ pub reexport_chain: SmallVec<[Reexport; 2]>,+}++/// Same as `ModChild`, however, it includes ambiguity error.+#[derive(Debug, TyEncodable, TyDecodable, StableHash)]+pub struct AmbigModChild {+ pub main: ModChild,+ pub second: ModChild,+}++#[derive(Debug, StableHash)]+pub struct ResolverGlobalCtxt {+ pub visibilities_for_hashing: Vec<(LocalDefId, Visibility)>,+ /// Item with a given `LocalDefId` was defined during macro expansion with ID `ExpnId`.+ pub expn_that_defined: UnordMap<LocalDefId, ExpnId>,+ pub effective_visibilities: EffectiveVisibilities,+ // FIXME: This table contains ADTs reachable from macro 2.0.+ // Currently, reachability of a definition from a macro is determined by nominal visibility+ // (see `compute_effective_visibilities`). This is incorrect and leads to the necessity+ // of traversing ADT fields in `rustc_privacy`. Remove this workaround once the+ // correct reachability logic is implemented for macros.+ pub macro_reachable_adts: FxIndexMap<LocalDefId, FxIndexSet<LocalDefId>>,+ pub extern_crate_map: UnordMap<LocalDefId, CrateNum>,+ pub maybe_unused_trait_imports: FxIndexSet<LocalDefId>,+ pub module_children: LocalDefIdMap<Vec<ModChild>>,+ pub ambig_module_children: LocalDefIdMap<Vec<AmbigModChild>>,+ pub glob_map: FxIndexMap<LocalDefId, FxIndexSet<Symbol>>,+ pub main_def: Option<MainDefinition>,+ pub trait_impls: FxIndexMap<DefId, Vec<LocalDefId>>,+ /// A list of proc macro LocalDefIds, written out in the order in which+ /// they are declared in the static array generated by proc_macro_harness.+ pub proc_macros: Vec<LocalDefId>,+ /// Mapping from ident span to path span for paths that don't exist as written, but that+ /// exist under `std`. For example, wrote `str::from_utf8` instead of `std::str::from_utf8`.+ pub confused_type_with_std_module: FxIndexMap<Span, Span>,+ pub doc_link_resolutions: FxIndexMap<LocalModId, DocLinkResMap>,+ pub doc_link_traits_in_scope: FxIndexMap<LocalModId, Vec<DefId>>,+ pub all_macro_rules: UnordSet<Symbol>,+ pub stripped_cfg_items: Vec<StrippedCfgItem>,+ // Information about delegations which is used when handling recursive delegations+ // and ensures easy access to delegation-only `LocalDefId`s.+ pub delegation_infos: FxIndexMap<LocalDefId, DelegationInfo>,+}++#[derive(Debug)]+pub struct PerOwnerResolverData<'tcx> {+ pub node_id_to_def_id: NodeMap<LocalDefId> = Default::default(),+ /// Whether lifetime elision was successful.+ pub lifetime_elision_allowed: bool = false,+ /// Resolutions for labels. Maps from NodeId of the break/continue expression to the NodeId of+ /// their corresponding blocks or loops.+ pub label_res_map: NodeMap<NodeId> = Default::default(),+ /// Resolutions for lifetimes.+ pub lifetimes_res_map: NodeMap<LifetimeRes> = Default::default(),++ pub trait_map: NodeMap<&'tcx [TraitCandidate<'tcx>]> = Default::default(),++ /// Resolution for import nodes, which have multiple resolutions in different namespaces.+ pub import_res: PerNS<Option<Res<NodeId>>> = Default::default(),+ /// Lifetime parameters that lowering will have to introduce.+ pub extra_lifetime_params_map: NodeMap<Vec<(Ident, NodeId, MissingLifetimeKind)>> =+ Default::default(),++ /// The id of the owner+ pub id: NodeId,+ /// The `DefId` of the owner, can't be found in `node_id_to_def_id`.+ pub def_id: LocalDefId,+}++impl<'tcx> PerOwnerResolverData<'tcx> {+ pub fn new(id: NodeId, def_id: LocalDefId) -> PerOwnerResolverData<'tcx> {+ PerOwnerResolverData { id, def_id, .. }+ }++ /// Obtains resolution for a label with the given `NodeId`.+ pub fn get_label_res(&self, id: NodeId) -> Option<NodeId> {+ self.label_res_map.get(&id).copied()+ }++ /// Obtains resolution for a lifetime with the given `NodeId`.+ pub fn get_lifetime_res(&self, id: NodeId) -> Option<LifetimeRes> {+ self.lifetimes_res_map.get(&id).copied()+ }++ /// Obtain the list of lifetimes parameters to add to an item.+ ///+ /// Extra lifetime parameters should only be added in places that can appear+ /// as a `binder` in `LifetimeRes`.+ ///+ /// The extra lifetimes that appear from the parenthesized `Fn`-trait desugaring+ /// should appear at the enclosing `PolyTraitRef`.+ pub fn extra_lifetime_params(&self, id: NodeId) -> &[(Ident, NodeId, MissingLifetimeKind)] {+ self.extra_lifetime_params_map.get(&id).map_or(&[], |v| &v[..])+ }+}++/// Resolutions that should only be used for lowering.+/// This struct is meant to be consumed by lowering.+#[derive(Debug)]+pub struct ResolverAstLowering<'tcx> {+ /// Resolutions for nodes that have a single resolution.+ pub partial_res_map: NodeMap<PartialRes>,++ pub next_node_id: NodeId,++ pub owners: NodeMap<PerOwnerResolverData<'tcx>>,++ /// Lints that were emitted by the resolver and early lints.+ pub lint_buffer: Steal<LintBuffer>,++ pub disambiguators: LocalDefIdMap<Steal<PerParentDisambiguatorState>>,+}++#[derive(Debug, StableHash)]+pub struct DelegationInfo {+ // `DefId` (either the resolution at delegation.id or item_id in case of a trait impl) for+ // signature resolution, for details see+ // https://github.com/rust-lang/rust/issues/118212#issuecomment-2160686914.+ /// Refers to the next element in a delegation resolution chain. Usually points to the final+ /// resolution, as most "chains" are just one step to a trait or an impl.+ pub resolution_id: Result<DefId, ErrorGuaranteed>,+}++#[derive(Clone, Copy, Debug, StableHash)]+pub struct MainDefinition {+ pub res: Res<NodeId>,+ pub is_import: bool,+ pub span: Span,+}++impl MainDefinition {+ pub fn opt_fn_def_id(self) -> Option<DefId> {+ if let Res::Def(DefKind::Fn, def_id) = self.res { Some(def_id) } else { None }+ }+}++// FxIndexMap is necessary because its data ends up in .rmeta files,+// so its iteration order must be consistent. See #159677 for context.+pub type DocLinkResMap = FxIndexMap<(Symbol, Namespace), Option<Res<NodeId>>>;++/// Fragment of the AST according to "HIR owner" semantics.+///+/// This is used to map each `LocalDefId` to its content's AST.+///+/// This type isn't produced by name resolution but it is paired with `ResolverAstLowering` so this+/// is as good a place as any for it.+#[derive(Debug)]+pub enum AstOwner {+ /// This definition does not correspond to a HIR owner.+ NonOwner,+ /// This definition corresponds to a nested `use` tree.+ /// The `LocalDefId` points to its HIR owner.+ NestedUseTree(LocalDefId),+ Crate(Box<ast::Crate>),+ Item(Box<ast::Item>),+ TraitItem(Box<ast::AssocItem>),+ ImplItem(Box<ast::AssocItem>),+ ForeignItem(Box<ast::ForeignItem>),+}compiler/rustc_middle/src/middle/resolve_bound_vars.rs2 + / 1 −
@@ -1,4 +1,5 @@-//! Name resolution for lifetimes and late-bound type and const variables: type declarations.+//! Name resolution for lifetimes and late-bound type and const variables (done by+//! `rustc_hir_analysis`): type declarations. use rustc_data_structures::sorted_map::SortedMap; use rustc_errors::ErrorGuaranteed;compiler/rustc_middle/src/queries.rs9 + / 7 −
@@ -65,7 +65,7 @@ use rustc_data_structures::svh::Svh; use rustc_data_structures::unord::{UnordMap, UnordSet}; use rustc_errors::{ErrorGuaranteed, catch_fatal_errors}; use rustc_hir as hir;-use rustc_hir::def::{DefKind, DocLinkResMap};+use rustc_hir::def::DefKind; use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LocalDefId, LocalDefIdSet, LocalModId}; use rustc_hir::{ItemLocalId, PreciseCapturingArgKind}; use rustc_index::IndexVec;@@ -79,14 +79,16 @@ use rustc_target::spec::PanicStrategy; use crate::infer::canonical::{self, Canonical}; use crate::lint::LintExpectation;-use crate::metadata::ModChild; use crate::middle::codegen_fn_attrs::{CodegenFnAttrs, SanitizerFnAttrs}; use crate::middle::dead_code::DeadCodeLivenessSummary; use crate::middle::debugger_visualizer::DebuggerVisualizerFile; use crate::middle::deduced_param_attrs::DeducedParamAttrs; use crate::middle::exported_symbols::{ExportedSymbol, SymbolExportInfo}; use crate::middle::lib_features::LibFeatures; use crate::middle::privacy::EffectiveVisibilities;+use crate::middle::resolve::{+ AstOwner, DocLinkResMap, ModChild, ResolverAstLowering, ResolverGlobalCtxt,+}; use crate::middle::resolve_bound_vars::{ObjectLifetimeDefault, ResolveBoundVars, ResolvedArg}; use crate::middle::stability::DeprecationEntry; use crate::mir::interpret::{@@ -186,16 +188,16 @@ rustc_queries! { desc { "get the value of an environment variable" } } - query resolutions(_: ()) -> &'tcx ty::ResolverGlobalCtxt {+ query resolutions(_: ()) -> &'tcx ResolverGlobalCtxt { desc { "getting the resolver outputs" } } query resolver_for_lowering_raw(_: ()) -> ( // Those two fields are consumed by `index_ast`. // We want them to be eventually dropped after lowering.- &'tcx Steal<ty::ResolverAstLowering<'tcx>>,+ &'tcx Steal<ResolverAstLowering<'tcx>>, &'tcx Steal<ast::Crate>,- &'tcx ty::ResolverGlobalCtxt,+ &'tcx ResolverGlobalCtxt, ) { eval_always no_hash@@ -206,8 +208,8 @@ rustc_queries! { // There is only a single `ResolverAstLowering` for all owners. // We want to drop it once the whole HIR has been lowered. // We rely on reference counting to know when all definitions have been stolen.- Arc<ty::ResolverAstLowering<'tcx>>,- ast::AstOwner,+ Arc<ResolverAstLowering<'tcx>>,+ AstOwner, )>> { arena_cache eval_alwayscompiler/rustc_middle/src/ty/context.rs2 + / 2 −
@@ -55,8 +55,8 @@ use crate::hir::{ProjectedMaybeOwner, ProjectedOwnerInfo}; use crate::ich::StableHashState; use crate::infer::canonical::{CanonicalParamEnvCache, CanonicalVarKind}; use crate::lint::emit_lint_base;-use crate::metadata::ModChild; use crate::middle::codegen_fn_attrs::{CodegenFnAttrs, TargetFeature};+use crate::middle::resolve::{ModChild, ResolverAstLowering}; use crate::middle::resolve_bound_vars; use crate::mir::interpret::{self, Allocation, ConstAllocation}; use crate::mir::{Body, Local, Place, PlaceElem, ProjectionKind, Promoted};@@ -2878,7 +2878,7 @@ impl<'tcx> TyCtxt<'tcx> { pub fn resolver_for_lowering( self,- ) -> (&'tcx Steal<ty::ResolverAstLowering<'tcx>>, &'tcx Steal<ast::Crate>) {+ ) -> (&'tcx Steal<ResolverAstLowering<'tcx>>, &'tcx Steal<ast::Crate>) { let (resolver, krate, _) = self.resolver_for_lowering_raw(()); (resolver, krate) }compiler/rustc_middle/src/ty/mod.rs7 + / 142 −
@@ -28,21 +28,17 @@ pub use intrinsic::IntrinsicDef; use rustc_abi::{ Align, FieldIdx, Integer, IntegerType, ReprFlags, ReprOptions, ScalableElt, VariantIdx, };-use rustc_ast::node_id::NodeMap;-use rustc_ast::{self as ast, NodeId};+use rustc_ast::{self as ast}; pub use rustc_ast_ir::{Movability, Mutability, try_visit}; use rustc_attr_ir::lang_items::LangItem;-use rustc_attr_ir::{self as attr, StrippedCfgItem, find_attr};-use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};+use rustc_attr_ir::{self as attr, find_attr};+use rustc_data_structures::fx::{FxHashSet, FxIndexMap}; use rustc_data_structures::intern::Interned; use rustc_data_structures::stable_hash::{StableHash, StableHashCtxt, StableHasher};-use rustc_data_structures::steal::Steal;-use rustc_data_structures::unord::{UnordMap, UnordSet};-use rustc_errors::{Diag, ErrorGuaranteed, LintBuffer};+use rustc_errors::{Diag, ErrorGuaranteed}; use rustc_hir as hir;-use rustc_hir::def::{CtorKind, CtorOf, DefKind, DocLinkResMap, LifetimeRes, Res};-use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LocalDefId, LocalDefIdMap};-use rustc_hir::definitions::PerParentDisambiguatorState;+use rustc_hir::def::{CtorKind, CtorOf, DefKind, Res};+use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LocalDefId}; use rustc_index::bit_set::BitMatrix; use rustc_index::{IndexVec, static_assert_size}; pub use rustc_lint_defs::RegisteredTools;@@ -54,7 +50,7 @@ use rustc_serialize::{Decodable, Encodable}; use rustc_session::config::OptLevel; use rustc_span::def_id::{LocalModId, ModId}; use rustc_span::hygiene::MacroKind;-use rustc_span::{DUMMY_SP, ExpnId, ExpnKind, Ident, Span, Symbol};+use rustc_span::{DUMMY_SP, ExpnKind, Ident, Span, Symbol}; use rustc_target::callconv::FnAbi; pub use rustc_type_ir::data_structures::{DelayedMap, DelayedSet}; pub use rustc_type_ir::fast_reject::DeepRejectCtxt;@@ -114,8 +110,6 @@ pub use self::typeck_results::{ UserTypeKind, }; use crate::diagnostics::{OpaqueHiddenTypeMismatch, TypeMismatchReason};-use crate::metadata::{AmbigModChild, ModChild};-use crate::middle::privacy::EffectiveVisibilities; use crate::mir::{Body, CoroutineLayout, CoroutineSavedLocal, MirPhase, SourceInfo}; use crate::query::{IntoQueryKey, Providers}; use crate::ty;@@ -171,135 +165,6 @@ mod visit; // Data types -#[derive(Debug, StableHash)]-pub struct ResolverGlobalCtxt {- pub visibilities_for_hashing: Vec<(LocalDefId, Visibility)>,- /// Item with a given `LocalDefId` was defined during macro expansion with ID `ExpnId`.- pub expn_that_defined: UnordMap<LocalDefId, ExpnId>,- pub effective_visibilities: EffectiveVisibilities,- // FIXME: This table contains ADTs reachable from macro 2.0.- // Currently, reachability of a definition from a macro is determined by nominal visibility- // (see `compute_effective_visibilities`). This is incorrect and leads to the necessity- // of traversing ADT fields in `rustc_privacy`. Remove this workaround once the- // correct reachability logic is implemented for macros.- pub macro_reachable_adts: FxIndexMap<LocalDefId, FxIndexSet<LocalDefId>>,- pub extern_crate_map: UnordMap<LocalDefId, CrateNum>,- pub maybe_unused_trait_imports: FxIndexSet<LocalDefId>,- pub module_children: LocalDefIdMap<Vec<ModChild>>,- pub ambig_module_children: LocalDefIdMap<Vec<AmbigModChild>>,- pub glob_map: FxIndexMap<LocalDefId, FxIndexSet<Symbol>>,- pub main_def: Option<MainDefinition>,- pub trait_impls: FxIndexMap<DefId, Vec<LocalDefId>>,- /// A list of proc macro LocalDefIds, written out in the order in which- /// they are declared in the static array generated by proc_macro_harness.- pub proc_macros: Vec<LocalDefId>,- /// Mapping from ident span to path span for paths that don't exist as written, but that- /// exist under `std`. For example, wrote `str::from_utf8` instead of `std::str::from_utf8`.- pub confused_type_with_std_module: FxIndexMap<Span, Span>,- pub doc_link_resolutions: FxIndexMap<LocalModId, DocLinkResMap>,- pub doc_link_traits_in_scope: FxIndexMap<LocalModId, Vec<DefId>>,- pub all_macro_rules: UnordSet<Symbol>,- pub stripped_cfg_items: Vec<StrippedCfgItem>,- // Information about delegations which is used when handling recursive delegations- // and ensures easy access to delegation-only `LocalDefId`s.- pub delegation_infos: FxIndexMap<LocalDefId, DelegationInfo>,-}--#[derive(Debug)]-pub struct PerOwnerResolverData<'tcx> {- pub node_id_to_def_id: NodeMap<LocalDefId> = Default::default(),- /// Whether lifetime elision was successful.- pub lifetime_elision_allowed: bool = false,- /// Resolutions for labels. Maps from NodeId of the break/continue expression to the NodeId of- /// their corresponding blocks or loops.- pub label_res_map: NodeMap<ast::NodeId> = Default::default(),- /// Resolutions for lifetimes.- pub lifetimes_res_map: NodeMap<LifetimeRes> = Default::default(),-- pub trait_map: NodeMap<&'tcx [hir::TraitCandidate<'tcx>]> = Default::default(),-- /// Resolution for import nodes, which have multiple resolutions in different namespaces.- pub import_res: hir::def::PerNS<Option<Res<ast::NodeId>>> = Default::default(),- /// Lifetime parameters that lowering will have to introduce.- pub extra_lifetime_params_map: NodeMap<Vec<(Ident, ast::NodeId, hir::MissingLifetimeKind)>> =- Default::default(),-- /// The id of the owner- pub id: ast::NodeId,- /// The `DefId` of the owner, can't be found in `node_id_to_def_id`.- pub def_id: LocalDefId,-}--impl<'tcx> PerOwnerResolverData<'tcx> {- pub fn new(id: ast::NodeId, def_id: LocalDefId) -> PerOwnerResolverData<'tcx> {- PerOwnerResolverData { id, def_id, .. }- }-- /// Obtains resolution for a label with the given `NodeId`.- pub fn get_label_res(&self, id: ast::NodeId) -> Option<ast::NodeId> {- self.label_res_map.get(&id).copied()- }-- /// Obtains resolution for a lifetime with the given `NodeId`.- pub fn get_lifetime_res(&self, id: ast::NodeId) -> Option<LifetimeRes> {- self.lifetimes_res_map.get(&id).copied()- }-- /// Obtain the list of lifetimes parameters to add to an item.- ///- /// Extra lifetime parameters should only be added in places that can appear- /// as a `binder` in `LifetimeRes`.- ///- /// The extra lifetimes that appear from the parenthesized `Fn`-trait desugaring- /// should appear at the enclosing `PolyTraitRef`.- pub fn extra_lifetime_params(- &self,- id: NodeId,- ) -> &[(Ident, NodeId, hir::MissingLifetimeKind)] {- self.extra_lifetime_params_map.get(&id).map_or(&[], |v| &v[..])- }-}--/// Resolutions that should only be used for lowering.-/// This struct is meant to be consumed by lowering.-#[derive(Debug)]-pub struct ResolverAstLowering<'tcx> {- /// Resolutions for nodes that have a single resolution.- pub partial_res_map: NodeMap<hir::def::PartialRes>,-- pub next_node_id: ast::NodeId,-- pub owners: NodeMap<PerOwnerResolverData<'tcx>>,-- /// Lints that were emitted by the resolver and early lints.- pub lint_buffer: Steal<LintBuffer>,-- pub disambiguators: LocalDefIdMap<Steal<PerParentDisambiguatorState>>,-}--#[derive(Debug, StableHash)]-pub struct DelegationInfo {- // `DefId` (either the resolution at delegation.id or item_id in case of a trait impl) for signature resolution,- // for details see https://github.com/rust-lang/rust/issues/118212#issuecomment-2160686914- /// Refers to the next element in a delegation resolution chain.- /// Usually points to the final resolution, as most "chains" are just- /// one step to a trait or an impl.- pub resolution_id: Result<DefId, ErrorGuaranteed>,-}--#[derive(Clone, Copy, Debug, StableHash)]-pub struct MainDefinition {- pub res: Res<ast::NodeId>,- pub is_import: bool,- pub span: Span,-}--impl MainDefinition {- pub fn opt_fn_def_id(self) -> Option<DefId> {- if let Res::Def(DefKind::Fn, def_id) = self.res { Some(def_id) } else { None }- }-}- #[derive(Copy, Clone, Debug, TyEncodable, TyDecodable, StableHash)] pub struct ImplTraitHeader<'tcx> { pub trait_ref: ty::EarlyBinder<'tcx, ty::TraitRef<'tcx>>,compiler/rustc_passes/src/diagnostics.rs2 + / 1 −
@@ -6,7 +6,8 @@ use rustc_errors::{ Diag, DiagCtxtHandle, DiagSymbolList, Diagnostic, EmissionGuarantee, Level, MultiSpan, msg, }; use rustc_macros::{Diagnostic, Subdiagnostic};-use rustc_middle::ty::{MainDefinition, Ty};+use rustc_middle::middle::resolve::MainDefinition;+use rustc_middle::ty::Ty; use rustc_span::{DUMMY_SP, Ident, Span, Symbol}; use crate::check_attr::ProcMacroKind;compiler/rustc_passes/src/lang_items.rs2 + / 1 −
@@ -13,8 +13,9 @@ use rustc_crate_store::ExternCrate; use rustc_hir::Target; use rustc_hir::attrs::lang_items::{GenericRequirement, LangItem, LanguageItems}; use rustc_hir::def_id::{DefId, LocalDefId};+use rustc_middle::middle::resolve::ResolverAstLowering; use rustc_middle::query::Providers;-use rustc_middle::ty::{ResolverAstLowering, TyCtxt};+use rustc_middle::ty::TyCtxt; use rustc_span::{Span, Symbol, sym}; use crate::diagnostics::{DuplicateLangItem, IncorrectCrateType, IncorrectTarget};compiler/rustc_resolve/src/build_reduced_graph.rs1 + / 1 −
@@ -23,7 +23,7 @@ use rustc_hir::def::{self, *}; use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_index::bit_set::DenseBitSet; use rustc_metadata::creader::LoadedMacro;-use rustc_middle::metadata::{ModChild, Reexport};+use rustc_middle::middle::resolve::{ModChild, PartialRes, Reexport}; use rustc_middle::ty::{TyCtxtFeed, Visibility}; use rustc_middle::{bug, span_bug}; use rustc_span::def_id::{CRATE_MOD_ID, ModId};compiler/rustc_resolve/src/def_collector.rs2 + / 1 −
@@ -10,8 +10,9 @@ use rustc_hir::Target; use rustc_hir::def::DefKind; use rustc_hir::def::Namespace::{TypeNS, ValueNS}; use rustc_hir::def_id::LocalDefId;+use rustc_middle::middle::resolve::PerOwnerResolverData; use rustc_middle::span_bug;-use rustc_middle::ty::{PerOwnerResolverData, TyCtxtFeed};+use rustc_middle::ty::TyCtxtFeed; use rustc_span::{Span, Symbol, sym}; use tracing::{debug, instrument}; compiler/rustc_resolve/src/ident.rs2 + / 1 −
@@ -4,8 +4,9 @@ use Determinacy::*; use Namespace::*; use rustc_ast::{self as ast, NodeId}; use rustc_errors::ErrorGuaranteed;-use rustc_hir::def::{DefKind, MacroKinds, Namespace, NonMacroAttrKind, PartialRes, PerNS};+use rustc_hir::def::{DefKind, MacroKinds, Namespace, NonMacroAttrKind, PerNS}; use rustc_lint_defs::builtin::PROC_MACRO_DERIVE_RESOLUTION_FALLBACK;+use rustc_middle::middle::resolve::PartialRes; use rustc_middle::{bug, span_bug}; use rustc_session::diagnostics::feature_err; use rustc_span::edition::Edition;compiler/rustc_resolve/src/imports.rs2 + / 2 −
@@ -8,14 +8,14 @@ use rustc_data_structures::fx::{FxHashSet, FxIndexSet}; use rustc_data_structures::intern::Interned; use rustc_errors::{Applicability, BufferedEarlyLint, Diagnostic}; use rustc_expand::base::SyntaxExtensionKind;-use rustc_hir::def::{self, DefKind, PartialRes};+use rustc_hir::def::{self, DefKind}; use rustc_hir::def_id::{DefId, LocalDefId, LocalDefIdMap}; use rustc_lint_defs::LintId; use rustc_lint_defs::builtin::{ AMBIGUOUS_GLOB_REEXPORTS, EXPORTED_PRIVATE_DEPENDENCIES, HIDDEN_GLOB_REEXPORTS, PUB_USE_OF_PRIVATE_EXTERN_CRATE, REDUNDANT_IMPORTS, UNUSED_IMPORTS, };-use rustc_middle::metadata::{AmbigModChild, ModChild, Reexport};+use rustc_middle::middle::resolve::{AmbigModChild, ModChild, PartialRes, Reexport}; use rustc_middle::span_bug; use rustc_middle::ty::Visibility; use rustc_session::diagnostics::feature_err;compiler/rustc_resolve/src/late.rs3 + / 2 −
@@ -25,12 +25,13 @@ use rustc_errors::{ StashKey, Suggestions, elided_lifetime_in_path_suggestion, pluralize, }; use rustc_hir::def::Namespace::{self, *};-use rustc_hir::def::{CtorKind, DefKind, LifetimeRes, NonMacroAttrKind, PartialRes, PerNS};+use rustc_hir::def::{CtorKind, DefKind, NonMacroAttrKind, PerNS}; use rustc_hir::def_id::{CRATE_DEF_ID, DefId, LOCAL_CRATE, LocalDefId}; use rustc_hir::{MissingLifetimeKind, PrimTy}; use rustc_lint_defs::builtin::{ELIDED_LIFETIMES_IN_PATHS, UNUSED_LABELS};+use rustc_middle::middle::resolve::{DelegationInfo, LifetimeRes, PartialRes}; use rustc_middle::middle::resolve_bound_vars::Set1;-use rustc_middle::ty::{AssocTag, DelegationInfo, Visibility};+use rustc_middle::ty::{AssocTag, Visibility}; use rustc_middle::{bug, span_bug}; use rustc_session::config::ResolveDocLinks; use rustc_session::diagnostics::feature_err;compiler/rustc_resolve/src/lib.rs7 + / 9 −
@@ -53,22 +53,20 @@ use rustc_expand::base::{DeriveResolution, SyntaxExtension, SyntaxExtensionKind} use rustc_feature::{BUILTIN_ATTRIBUTES, Features}; use rustc_hir::attrs::StrippedCfgItem; use rustc_hir::def::Namespace::{self, *};-use rustc_hir::def::{- self, CtorOf, DefKind, DocLinkResMap, MacroKinds, NonMacroAttrKind, PartialRes, PerNS,-};+use rustc_hir::def::{self, CtorOf, DefKind, MacroKinds, NonMacroAttrKind, PerNS}; use rustc_hir::def_id::{CRATE_DEF_ID, CrateNum, DefId, LOCAL_CRATE, LocalDefId, LocalDefIdMap}; use rustc_hir::definitions::{PerParentDisambiguatorState, PerParentDisambiguatorsMap}; use rustc_hir::{PrimTy, TraitCandidate, find_attr}; use rustc_index::bit_set::DenseBitSet; use rustc_lint_defs::builtin::PRIVATE_MACRO_USE; use rustc_metadata::creader::CStore;-use rustc_middle::metadata::{AmbigModChild, ModChild, Reexport}; use rustc_middle::middle::privacy::EffectiveVisibilities;-use rustc_middle::query::Providers;-use rustc_middle::ty::{- self, DelegationInfo, MainDefinition, PerOwnerResolverData, RegisteredTools,- ResolverAstLowering, ResolverGlobalCtxt, TyCtxt, TyCtxtFeed, Visibility,+use rustc_middle::middle::resolve::{+ AmbigModChild, DelegationInfo, DocLinkResMap, MainDefinition, ModChild, PartialRes,+ PerOwnerResolverData, Reexport, ResolverAstLowering, ResolverGlobalCtxt, };+use rustc_middle::query::Providers;+use rustc_middle::ty::{self, RegisteredTools, TyCtxt, TyCtxtFeed, Visibility}; use rustc_middle::{bug, span_bug}; use rustc_span::def_id::{LocalModId, ModId}; use rustc_span::hygiene::{ExpnId, LocalExpnId, MacroKind, SyntaxContext, Transparency};@@ -1993,7 +1991,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { stripped_cfg_items, delegation_infos: self.delegation_infos, };- let ast_lowering = ty::ResolverAstLowering {+ let ast_lowering = ResolverAstLowering { partial_res_map: self.partial_res_map, next_node_id: self.next_node_id, owners: self.owners,src/librustdoc/clean/mod.rs1 + / 1 −
@@ -45,7 +45,7 @@ use rustc_hir::def::{CtorKind, DefKind, MacroKinds, Res}; use rustc_hir::def_id::{DefId, DefIdMap, DefIdSet, LOCAL_CRATE, LocalDefId}; use rustc_hir::{PredicateOrigin, find_attr}; use rustc_hir_analysis::{lower_const_arg_for_rustdoc, lower_ty};-use rustc_middle::metadata::Reexport;+use rustc_middle::middle::resolve::Reexport; use rustc_middle::middle::resolve_bound_vars as rbv; use rustc_middle::ty::{ self, AdtKind, GenericArgsRef, RegionExt, Ty, TyCtxt, TypeVisitableExt, TypingMode,src/librustdoc/passes/lint/redundant_explicit_links.rs2 + / 1 −
@@ -3,8 +3,9 @@ use std::ops::Range; use rustc_ast::NodeId; use rustc_errors::{Diag, DiagCtxtHandle, Diagnostic, Level, SuggestionStyle}; use rustc_hir::HirId;-use rustc_hir::def::{DefKind, DocLinkResMap, Namespace, Res};+use rustc_hir::def::{DefKind, Namespace, Res}; use rustc_lint::Applicability;+use rustc_middle::middle::resolve::DocLinkResMap; use rustc_resolve::rustdoc::pulldown_cmark::{ BrokenLink, BrokenLinkCallback, CowStr, Event, LinkType, OffsetIter, Parser, Tag, };