Move reachable_set query in librustc_passes.
This commit is contained in:
parent
2e7dbb42c7
commit
4922310a3b
@ -105,7 +105,6 @@ pub mod middle {
|
||||
pub mod lang_items;
|
||||
pub mod lib_features;
|
||||
pub mod privacy;
|
||||
pub mod reachable;
|
||||
pub mod recursion_limit;
|
||||
pub mod region;
|
||||
pub mod resolve_lifetime;
|
||||
|
@ -510,7 +510,7 @@ rustc_queries! {
|
||||
}
|
||||
|
||||
Other {
|
||||
query reachable_set(_: CrateNum) -> ReachableSet {
|
||||
query reachable_set(_: CrateNum) -> Lrc<HirIdSet> {
|
||||
desc { "reachability" }
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,6 @@ use crate::middle::exported_symbols::{ExportedSymbol, SymbolExportLevel};
|
||||
use crate::middle::lang_items::{LangItem, LanguageItems};
|
||||
use crate::middle::lib_features::LibFeatures;
|
||||
use crate::middle::privacy::AccessLevels;
|
||||
use crate::middle::reachable::ReachableSet;
|
||||
use crate::middle::region;
|
||||
use crate::middle::resolve_lifetime::{ObjectLifetimeDefault, Region, ResolveLifetimes};
|
||||
use crate::middle::stability::{self, DeprecationEntry};
|
||||
@ -37,7 +36,7 @@ use crate::ty::subst::SubstsRef;
|
||||
use crate::ty::util::NeedsDrop;
|
||||
use crate::ty::{self, AdtSizedConstraint, CrateInherentImpls, ParamEnvAnd, Ty, TyCtxt};
|
||||
use crate::util::common::ErrorReported;
|
||||
use crate::util::nodemap::{DefIdMap, DefIdSet};
|
||||
use crate::util::nodemap::{DefIdMap, DefIdSet, HirIdSet};
|
||||
use rustc_data_structures::profiling::ProfileCategory::*;
|
||||
|
||||
use rustc_data_structures::fingerprint::Fingerprint;
|
||||
|
@ -65,7 +65,6 @@ fn reachable_non_generics_provider(
|
||||
|
||||
let mut reachable_non_generics: DefIdMap<_> = tcx
|
||||
.reachable_set(LOCAL_CRATE)
|
||||
.0
|
||||
.iter()
|
||||
.filter_map(|&hir_id| {
|
||||
// We want to ignore some FFI functions that are not exposed from
|
||||
@ -313,7 +312,7 @@ fn upstream_monomorphizations_for_provider(
|
||||
|
||||
fn is_unreachable_local_definition_provider(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
|
||||
if let Some(hir_id) = tcx.hir().as_local_hir_id(def_id) {
|
||||
!tcx.reachable_set(LOCAL_CRATE).0.contains(&hir_id)
|
||||
!tcx.reachable_set(LOCAL_CRATE).contains(&hir_id)
|
||||
} else {
|
||||
bug!("is_unreachable_local_definition called with non-local DefId: {:?}", def_id)
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ use rustc::hir::def_id::{CrateNum, LOCAL_CRATE};
|
||||
use rustc::hir::lowering::lower_crate;
|
||||
use rustc::lint;
|
||||
use rustc::middle::cstore::{CrateStore, MetadataLoader, MetadataLoaderDyn};
|
||||
use rustc::middle::{self, reachable, resolve_lifetime, stability};
|
||||
use rustc::middle::{self, resolve_lifetime, stability};
|
||||
use rustc::session::config::{self, CrateType, Input, OutputFilenames, OutputType};
|
||||
use rustc::session::config::{PpMode, PpSourceMode};
|
||||
use rustc::session::search_paths::PathKind;
|
||||
@ -678,14 +678,12 @@ pub fn default_provide(providers: &mut ty::query::Providers<'_>) {
|
||||
plugin::build::provide(providers);
|
||||
hir::provide(providers);
|
||||
mir::provide(providers);
|
||||
reachable::provide(providers);
|
||||
resolve_lifetime::provide(providers);
|
||||
rustc_privacy::provide(providers);
|
||||
typeck::provide(providers);
|
||||
ty::provide(providers);
|
||||
traits::provide(providers);
|
||||
stability::provide(providers);
|
||||
reachable::provide(providers);
|
||||
rustc_passes::provide(providers);
|
||||
rustc_traits::provide(providers);
|
||||
middle::region::provide(providers);
|
||||
|
@ -28,6 +28,7 @@ mod intrinsicck;
|
||||
pub mod layout_test;
|
||||
mod liveness;
|
||||
pub mod loops;
|
||||
mod reachable;
|
||||
|
||||
pub fn provide(providers: &mut Providers<'_>) {
|
||||
check_const::provide(providers);
|
||||
@ -35,4 +36,5 @@ pub fn provide(providers: &mut Providers<'_>) {
|
||||
loops::provide(providers);
|
||||
liveness::provide(providers);
|
||||
intrinsicck::provide(providers);
|
||||
reachable::provide(providers);
|
||||
}
|
||||
|
@ -5,23 +5,22 @@
|
||||
// makes all other generics or inline functions that it references
|
||||
// reachable as well.
|
||||
|
||||
use crate::hir::def::{DefKind, Res};
|
||||
use crate::hir::def_id::{CrateNum, DefId};
|
||||
use crate::hir::Node;
|
||||
use crate::hir::{CodegenFnAttrFlags, CodegenFnAttrs};
|
||||
use crate::middle::privacy;
|
||||
use crate::session::config;
|
||||
use crate::ty::query::Providers;
|
||||
use crate::ty::{self, TyCtxt};
|
||||
use crate::util::nodemap::{FxHashSet, HirIdSet};
|
||||
use rustc::hir::def::{DefKind, Res};
|
||||
use rustc::hir::def_id::{CrateNum, DefId};
|
||||
use rustc::hir::Node;
|
||||
use rustc::hir::{CodegenFnAttrFlags, CodegenFnAttrs};
|
||||
use rustc::middle::privacy;
|
||||
use rustc::session::config;
|
||||
use rustc::ty::query::Providers;
|
||||
use rustc::ty::{self, TyCtxt};
|
||||
use rustc::util::nodemap::{FxHashSet, HirIdSet};
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
|
||||
use crate::hir;
|
||||
use crate::hir::def_id::LOCAL_CRATE;
|
||||
use crate::hir::intravisit;
|
||||
use crate::hir::intravisit::{NestedVisitorMap, Visitor};
|
||||
use crate::hir::itemlikevisit::ItemLikeVisitor;
|
||||
use rustc_macros::HashStable;
|
||||
use rustc::hir;
|
||||
use rustc::hir::def_id::LOCAL_CRATE;
|
||||
use rustc::hir::intravisit;
|
||||
use rustc::hir::intravisit::{NestedVisitorMap, Visitor};
|
||||
use rustc::hir::itemlikevisit::ItemLikeVisitor;
|
||||
use rustc_target::spec::abi::Abi;
|
||||
|
||||
// Returns true if the given item must be inlined because it may be
|
||||
@ -378,12 +377,7 @@ impl<'a, 'tcx> ItemLikeVisitor<'tcx> for CollectPrivateImplItemsVisitor<'a, 'tcx
|
||||
}
|
||||
}
|
||||
|
||||
// We introduce a new-type here, so we can have a specialized HashStable
|
||||
// implementation for it.
|
||||
#[derive(Clone, HashStable)]
|
||||
pub struct ReachableSet(pub Lrc<HirIdSet>);
|
||||
|
||||
fn reachable_set(tcx: TyCtxt<'_>, crate_num: CrateNum) -> ReachableSet {
|
||||
fn reachable_set(tcx: TyCtxt<'_>, crate_num: CrateNum) -> Lrc<HirIdSet> {
|
||||
debug_assert!(crate_num == LOCAL_CRATE);
|
||||
|
||||
let access_levels = &tcx.privacy_access_levels(LOCAL_CRATE);
|
||||
@ -429,7 +423,7 @@ fn reachable_set(tcx: TyCtxt<'_>, crate_num: CrateNum) -> ReachableSet {
|
||||
debug!("Inline reachability shows: {:?}", reachable_context.reachable_symbols);
|
||||
|
||||
// Return the set of reachable symbols.
|
||||
ReachableSet(Lrc::new(reachable_context.reachable_symbols))
|
||||
Lrc::new(reachable_context.reachable_symbols)
|
||||
}
|
||||
|
||||
pub fn provide(providers: &mut Providers<'_>) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user