Rename rustc_middle::cstore::DepKind to DependencyKind.
This commit is contained in:
parent
2c28244cf0
commit
4d4b8f2d41
@ -13,7 +13,7 @@ use rustc_expand::base::SyntaxExtension;
|
||||
use rustc_hir::def_id::{CrateNum, LocalDefId, LOCAL_CRATE};
|
||||
use rustc_hir::definitions::Definitions;
|
||||
use rustc_index::vec::IndexVec;
|
||||
use rustc_middle::middle::cstore::{CrateSource, DepKind, ExternCrate};
|
||||
use rustc_middle::middle::cstore::{CrateDepKind, CrateSource, ExternCrate};
|
||||
use rustc_middle::middle::cstore::{ExternCrateSource, MetadataLoaderDyn};
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_session::config::{self, CrateType, ExternLocation};
|
||||
@ -294,7 +294,7 @@ impl<'a> CrateLoader<'a> {
|
||||
host_lib: Option<Library>,
|
||||
root: Option<&CratePaths>,
|
||||
lib: Library,
|
||||
dep_kind: DepKind,
|
||||
dep_kind: CrateDepKind,
|
||||
name: Symbol,
|
||||
) -> Result<CrateNum, CrateError> {
|
||||
let _prof_timer = self.sess.prof.generic_activity("metadata_register_crate");
|
||||
@ -425,7 +425,7 @@ impl<'a> CrateLoader<'a> {
|
||||
&'b mut self,
|
||||
name: Symbol,
|
||||
span: Span,
|
||||
dep_kind: DepKind,
|
||||
dep_kind: CrateDepKind,
|
||||
dep: Option<(&'b CratePaths, &'b CrateDep)>,
|
||||
) -> CrateNum {
|
||||
if dep.is_none() {
|
||||
@ -438,7 +438,7 @@ impl<'a> CrateLoader<'a> {
|
||||
fn maybe_resolve_crate<'b>(
|
||||
&'b mut self,
|
||||
name: Symbol,
|
||||
mut dep_kind: DepKind,
|
||||
mut dep_kind: CrateDepKind,
|
||||
dep: Option<(&'b CratePaths, &'b CrateDep)>,
|
||||
) -> Result<CrateNum, CrateError> {
|
||||
info!("resolving crate `{}`", name);
|
||||
@ -475,7 +475,7 @@ impl<'a> CrateLoader<'a> {
|
||||
match self.load(&mut locator)? {
|
||||
Some(res) => (res, None),
|
||||
None => {
|
||||
dep_kind = DepKind::MacrosOnly;
|
||||
dep_kind = CrateDepKind::MacrosOnly;
|
||||
match self.load_proc_macro(&mut locator, path_kind)? {
|
||||
Some(res) => res,
|
||||
None => return Err(locator.into_error()),
|
||||
@ -488,7 +488,7 @@ impl<'a> CrateLoader<'a> {
|
||||
(LoadResult::Previous(cnum), None) => {
|
||||
let data = self.cstore.get_crate_data(cnum);
|
||||
if data.is_proc_macro_crate() {
|
||||
dep_kind = DepKind::MacrosOnly;
|
||||
dep_kind = CrateDepKind::MacrosOnly;
|
||||
}
|
||||
data.update_dep_kind(|data_dep_kind| cmp::max(data_dep_kind, dep_kind));
|
||||
Ok(cnum)
|
||||
@ -548,7 +548,7 @@ impl<'a> CrateLoader<'a> {
|
||||
crate_root: &CrateRoot<'_>,
|
||||
metadata: &MetadataBlob,
|
||||
krate: CrateNum,
|
||||
dep_kind: DepKind,
|
||||
dep_kind: CrateDepKind,
|
||||
) -> Result<CrateNumMap, CrateError> {
|
||||
debug!("resolving deps of external crate");
|
||||
if crate_root.is_proc_macro_crate() {
|
||||
@ -567,7 +567,7 @@ impl<'a> CrateLoader<'a> {
|
||||
dep.name, dep.hash, dep.extra_filename
|
||||
);
|
||||
let dep_kind = match dep_kind {
|
||||
DepKind::MacrosOnly => DepKind::MacrosOnly,
|
||||
CrateDepKind::MacrosOnly => CrateDepKind::MacrosOnly,
|
||||
_ => dep.kind,
|
||||
};
|
||||
let cnum = self.maybe_resolve_crate(dep.name, dep_kind, Some((root, &dep)))?;
|
||||
@ -634,7 +634,7 @@ impl<'a> CrateLoader<'a> {
|
||||
self.inject_dependency_if(cnum, "a panic runtime", &|data| {
|
||||
data.needs_panic_runtime()
|
||||
});
|
||||
runtime_found = runtime_found || data.dep_kind() == DepKind::Explicit;
|
||||
runtime_found = runtime_found || data.dep_kind() == CrateDepKind::Explicit;
|
||||
}
|
||||
});
|
||||
|
||||
@ -663,7 +663,7 @@ impl<'a> CrateLoader<'a> {
|
||||
};
|
||||
info!("panic runtime not found -- loading {}", name);
|
||||
|
||||
let cnum = self.resolve_crate(name, DUMMY_SP, DepKind::Implicit, None);
|
||||
let cnum = self.resolve_crate(name, DUMMY_SP, CrateDepKind::Implicit, None);
|
||||
let data = self.cstore.get_crate_data(cnum);
|
||||
|
||||
// Sanity check the loaded crate to ensure it is indeed a panic runtime
|
||||
@ -693,7 +693,7 @@ impl<'a> CrateLoader<'a> {
|
||||
info!("loading profiler");
|
||||
|
||||
let name = sym::profiler_builtins;
|
||||
let cnum = self.resolve_crate(name, DUMMY_SP, DepKind::Implicit, None);
|
||||
let cnum = self.resolve_crate(name, DUMMY_SP, CrateDepKind::Implicit, None);
|
||||
let data = self.cstore.get_crate_data(cnum);
|
||||
|
||||
// Sanity check the loaded crate to ensure it is indeed a profiler runtime
|
||||
@ -891,9 +891,9 @@ impl<'a> CrateLoader<'a> {
|
||||
None => item.ident.name,
|
||||
};
|
||||
let dep_kind = if attr::contains_name(&item.attrs, sym::no_link) {
|
||||
DepKind::MacrosOnly
|
||||
CrateDepKind::MacrosOnly
|
||||
} else {
|
||||
DepKind::Explicit
|
||||
CrateDepKind::Explicit
|
||||
};
|
||||
|
||||
let cnum = self.resolve_crate(name, item.span, dep_kind, None);
|
||||
@ -915,7 +915,7 @@ impl<'a> CrateLoader<'a> {
|
||||
}
|
||||
|
||||
pub fn process_path_extern(&mut self, name: Symbol, span: Span) -> CrateNum {
|
||||
let cnum = self.resolve_crate(name, span, DepKind::Explicit, None);
|
||||
let cnum = self.resolve_crate(name, span, CrateDepKind::Explicit, None);
|
||||
|
||||
self.update_extern_crate(
|
||||
cnum,
|
||||
@ -932,6 +932,6 @@ impl<'a> CrateLoader<'a> {
|
||||
}
|
||||
|
||||
pub fn maybe_process_path_extern(&mut self, name: Symbol) -> Option<CrateNum> {
|
||||
self.maybe_resolve_crate(name, DepKind::Explicit, None).ok()
|
||||
self.maybe_resolve_crate(name, CrateDepKind::Explicit, None).ok()
|
||||
}
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ use crate::creader::CStore;
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_hir::def_id::CrateNum;
|
||||
use rustc_middle::middle::cstore::LinkagePreference::{self, RequireDynamic, RequireStatic};
|
||||
use rustc_middle::middle::cstore::{self, DepKind};
|
||||
use rustc_middle::middle::cstore::{self, CrateDepKind};
|
||||
use rustc_middle::middle::dependency_format::{Dependencies, DependencyList, Linkage};
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_session::config::CrateType;
|
||||
@ -188,7 +188,7 @@ fn calculate_type(tcx: TyCtxt<'_>, ty: CrateType) -> DependencyList {
|
||||
let src = tcx.used_crate_source(cnum);
|
||||
if src.dylib.is_none()
|
||||
&& !formats.contains_key(&cnum)
|
||||
&& tcx.dep_kind(cnum) == DepKind::Explicit
|
||||
&& tcx.dep_kind(cnum) == CrateDepKind::Explicit
|
||||
{
|
||||
assert!(src.rlib.is_some() || src.rmeta.is_some());
|
||||
log::info!("adding staticlib: {}", tcx.crate_name(cnum));
|
||||
@ -284,7 +284,7 @@ fn attempt_static(tcx: TyCtxt<'_>) -> Option<DependencyList> {
|
||||
let last_crate = tcx.crates().len();
|
||||
let mut ret = (1..last_crate + 1)
|
||||
.map(|cnum| {
|
||||
if tcx.dep_kind(CrateNum::new(cnum)) == DepKind::Explicit {
|
||||
if tcx.dep_kind(CrateNum::new(cnum)) == CrateDepKind::Explicit {
|
||||
Linkage::Static
|
||||
} else {
|
||||
Linkage::NotLinked
|
||||
|
@ -100,7 +100,7 @@ crate struct CrateMetadata {
|
||||
/// Same ID set as `cnum_map` plus maybe some injected crates like panic runtime.
|
||||
dependencies: Lock<Vec<CrateNum>>,
|
||||
/// How to link (or not link) this crate to the currently compiled crate.
|
||||
dep_kind: Lock<DepKind>,
|
||||
dep_kind: Lock<CrateDepKind>,
|
||||
/// Filesystem location of this crate.
|
||||
source: CrateSource,
|
||||
/// Whether or not this crate should be consider a private dependency
|
||||
@ -1670,7 +1670,7 @@ impl CrateMetadata {
|
||||
raw_proc_macros: Option<&'static [ProcMacro]>,
|
||||
cnum: CrateNum,
|
||||
cnum_map: CrateNumMap,
|
||||
dep_kind: DepKind,
|
||||
dep_kind: CrateDepKind,
|
||||
source: CrateSource,
|
||||
private_dep: bool,
|
||||
host_hash: Option<Svh>,
|
||||
@ -1728,11 +1728,11 @@ impl CrateMetadata {
|
||||
&self.source
|
||||
}
|
||||
|
||||
crate fn dep_kind(&self) -> DepKind {
|
||||
crate fn dep_kind(&self) -> CrateDepKind {
|
||||
*self.dep_kind.lock()
|
||||
}
|
||||
|
||||
crate fn update_dep_kind(&self, f: impl FnOnce(DepKind) -> DepKind) {
|
||||
crate fn update_dep_kind(&self, f: impl FnOnce(CrateDepKind) -> CrateDepKind) {
|
||||
self.dep_kind.with_lock(|dep_kind| *dep_kind = f(*dep_kind))
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ use rustc_hir::def_id::{DefId, DefIndex};
|
||||
use rustc_hir::lang_items;
|
||||
use rustc_index::{bit_set::FiniteBitSet, vec::IndexVec};
|
||||
use rustc_middle::hir::exports::Export;
|
||||
use rustc_middle::middle::cstore::{DepKind, ForeignModule, LinkagePreference, NativeLib};
|
||||
use rustc_middle::middle::cstore::{CrateDepKind, ForeignModule, LinkagePreference, NativeLib};
|
||||
use rustc_middle::middle::exported_symbols::{ExportedSymbol, SymbolExportLevel};
|
||||
use rustc_middle::mir;
|
||||
use rustc_middle::ty::{self, ReprOptions, Ty};
|
||||
@ -226,7 +226,7 @@ crate struct CrateDep {
|
||||
pub name: Symbol,
|
||||
pub hash: Svh,
|
||||
pub host_hash: Option<Svh>,
|
||||
pub kind: DepKind,
|
||||
pub kind: CrateDepKind,
|
||||
pub extra_filename: String,
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ impl CrateSource {
|
||||
|
||||
#[derive(RustcEncodable, RustcDecodable, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Debug)]
|
||||
#[derive(HashStable)]
|
||||
pub enum DepKind {
|
||||
pub enum CrateDepKind {
|
||||
/// A dependency that is only used for its macros.
|
||||
MacrosOnly,
|
||||
/// A dependency that is always injected into the dependency list and so
|
||||
@ -51,11 +51,11 @@ pub enum DepKind {
|
||||
Explicit,
|
||||
}
|
||||
|
||||
impl DepKind {
|
||||
impl CrateDepKind {
|
||||
pub fn macros_only(self) -> bool {
|
||||
match self {
|
||||
DepKind::MacrosOnly => true,
|
||||
DepKind::Implicit | DepKind::Explicit => false,
|
||||
CrateDepKind::MacrosOnly => true,
|
||||
CrateDepKind::Implicit | CrateDepKind::Explicit => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1180,7 +1180,7 @@ rustc_queries! {
|
||||
}
|
||||
|
||||
Other {
|
||||
query dep_kind(_: CrateNum) -> DepKind {
|
||||
query dep_kind(_: CrateNum) -> CrateDepKind {
|
||||
eval_always
|
||||
desc { "fetching what a dependency looks like" }
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
use crate::dep_graph::{self, DepNode, DepNodeParams};
|
||||
use crate::dep_graph::{self, DepKind, DepNode, DepNodeParams};
|
||||
use crate::hir::exports::Export;
|
||||
use crate::hir::map;
|
||||
use crate::infer::canonical::{self, Canonical};
|
||||
use crate::lint::LintLevelMap;
|
||||
use crate::middle::codegen_fn_attrs::CodegenFnAttrs;
|
||||
use crate::middle::cstore::{CrateSource, DepKind};
|
||||
use crate::middle::cstore::{CrateDepKind, CrateSource};
|
||||
use crate::middle::cstore::{ExternCrate, ForeignModule, LinkagePreference, NativeLib};
|
||||
use crate::middle::exported_symbols::{ExportedSymbol, SymbolExportLevel};
|
||||
use crate::middle::lib_features::LibFeatures;
|
||||
@ -161,7 +161,7 @@ pub fn force_from_dep_node<'tcx>(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> bool
|
||||
// hit the cache instead of having to go through `force_from_dep_node`.
|
||||
// This assertion makes sure, we actually keep applying the solution above.
|
||||
debug_assert!(
|
||||
dep_node.kind != crate::dep_graph::DepKind::codegen_unit,
|
||||
dep_node.kind != DepKind::codegen_unit,
|
||||
"calling force_from_dep_node() on DepKind::codegen_unit"
|
||||
);
|
||||
|
||||
@ -172,14 +172,14 @@ pub fn force_from_dep_node<'tcx>(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> bool
|
||||
rustc_dep_node_force!([dep_node, tcx]
|
||||
// These are inputs that are expected to be pre-allocated and that
|
||||
// should therefore always be red or green already.
|
||||
crate::dep_graph::DepKind::CrateMetadata |
|
||||
DepKind::CrateMetadata |
|
||||
|
||||
// These are anonymous nodes.
|
||||
crate::dep_graph::DepKind::TraitSelect |
|
||||
DepKind::TraitSelect |
|
||||
|
||||
// We don't have enough information to reconstruct the query key of
|
||||
// these.
|
||||
crate::dep_graph::DepKind::CompileCodegenUnit => {
|
||||
DepKind::CompileCodegenUnit => {
|
||||
bug!("force_from_dep_node: encountered {:?}", dep_node)
|
||||
}
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user