Copy extern prelude from resolver to global context
This commit is contained in:
parent
83bb430663
commit
522948827b
@ -936,8 +936,8 @@ pub struct GlobalCtxt<'tcx> {
|
||||
freevars: FxHashMap<DefId, Lrc<Vec<hir::Freevar>>>,
|
||||
|
||||
maybe_unused_trait_imports: FxHashSet<DefId>,
|
||||
|
||||
maybe_unused_extern_crates: Vec<(DefId, Span)>,
|
||||
pub extern_prelude: FxHashSet<ast::Name>,
|
||||
|
||||
// Internal cache for metadata decoding. No need to track deps on this.
|
||||
pub rcache: Lock<FxHashMap<ty::CReaderCacheKey, Ty<'tcx>>>,
|
||||
@ -1223,6 +1223,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||
.into_iter()
|
||||
.map(|(id, sp)| (hir.local_def_id(id), sp))
|
||||
.collect(),
|
||||
extern_prelude: resolutions.extern_prelude,
|
||||
hir,
|
||||
def_path_hash_to_def_id,
|
||||
queries: query::Queries::new(
|
||||
|
@ -289,7 +289,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||
// printing the `CrateRoot` so we don't prepend a `crate::` to paths.
|
||||
let mut is_prelude_crate = false;
|
||||
if let DefPathData::CrateRoot = self.def_key(parent_did).disambiguated_data.data {
|
||||
if self.sess.extern_prelude.contains(&data.as_interned_str().as_symbol()) {
|
||||
if self.extern_prelude.contains(&data.as_interned_str().as_symbol()) {
|
||||
is_prelude_crate = true;
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ use ty::subst::{Subst, Substs};
|
||||
use ty::util::{IntTypeExt, Discr};
|
||||
use ty::walk::TypeWalker;
|
||||
use util::captures::Captures;
|
||||
use util::nodemap::{NodeSet, DefIdMap, FxHashMap};
|
||||
use util::nodemap::{NodeSet, DefIdMap, FxHashMap, FxHashSet};
|
||||
use arena::SyncDroplessArena;
|
||||
use session::DataTypeKind;
|
||||
|
||||
@ -140,6 +140,7 @@ pub struct Resolutions {
|
||||
pub maybe_unused_trait_imports: NodeSet,
|
||||
pub maybe_unused_extern_crates: Vec<(NodeId, Span)>,
|
||||
pub export_map: ExportMap,
|
||||
pub extern_prelude: FxHashSet<Name>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
||||
|
@ -790,6 +790,7 @@ where
|
||||
trait_map: resolver.trait_map,
|
||||
maybe_unused_trait_imports: resolver.maybe_unused_trait_imports,
|
||||
maybe_unused_extern_crates: resolver.maybe_unused_extern_crates,
|
||||
extern_prelude: resolver.extern_prelude,
|
||||
},
|
||||
|
||||
analysis: ty::CrateAnalysis {
|
||||
|
@ -1360,7 +1360,7 @@ pub struct Resolver<'a, 'b: 'a> {
|
||||
graph_root: Module<'a>,
|
||||
|
||||
prelude: Option<Module<'a>>,
|
||||
extern_prelude: FxHashSet<Name>,
|
||||
pub extern_prelude: FxHashSet<Name>,
|
||||
|
||||
/// n.b. This is used only for better diagnostics, not name resolution itself.
|
||||
has_self: FxHashSet<DefId>,
|
||||
|
@ -164,7 +164,7 @@ fn unused_crates_lint<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>) {
|
||||
// If the extern crate isn't in the extern prelude,
|
||||
// there is no way it can be written as an `use`.
|
||||
let orig_name = extern_crate.orig_name.unwrap_or(item.name);
|
||||
if !tcx.sess.extern_prelude.contains(&orig_name) {
|
||||
if !tcx.extern_prelude.contains(&orig_name) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -474,6 +474,7 @@ pub fn run_core(search_paths: SearchPaths,
|
||||
trait_map: resolver.trait_map.clone(),
|
||||
maybe_unused_trait_imports: resolver.maybe_unused_trait_imports.clone(),
|
||||
maybe_unused_extern_crates: resolver.maybe_unused_extern_crates.clone(),
|
||||
extern_prelude: resolver.extern_prelude.clone(),
|
||||
};
|
||||
let analysis = ty::CrateAnalysis {
|
||||
access_levels: Lrc::new(AccessLevels::default()),
|
||||
|
Loading…
x
Reference in New Issue
Block a user