Skip to content

Commit 4d4b8f2

Browse files
committed
Rename rustc_middle::cstore::DepKind to DependencyKind.
1 parent 2c28244 commit 4d4b8f2

File tree

7 files changed

+35
-35
lines changed

7 files changed

+35
-35
lines changed

src/librustc_metadata/creader.rs

+15-15
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use rustc_expand::base::SyntaxExtension;
1313
use rustc_hir::def_id::{CrateNum, LocalDefId, LOCAL_CRATE};
1414
use rustc_hir::definitions::Definitions;
1515
use rustc_index::vec::IndexVec;
16-
use rustc_middle::middle::cstore::{CrateSource, DepKind, ExternCrate};
16+
use rustc_middle::middle::cstore::{CrateDepKind, CrateSource, ExternCrate};
1717
use rustc_middle::middle::cstore::{ExternCrateSource, MetadataLoaderDyn};
1818
use rustc_middle::ty::TyCtxt;
1919
use rustc_session::config::{self, CrateType, ExternLocation};
@@ -294,7 +294,7 @@ impl<'a> CrateLoader<'a> {
294294
host_lib: Option<Library>,
295295
root: Option<&CratePaths>,
296296
lib: Library,
297-
dep_kind: DepKind,
297+
dep_kind: CrateDepKind,
298298
name: Symbol,
299299
) -> Result<CrateNum, CrateError> {
300300
let _prof_timer = self.sess.prof.generic_activity("metadata_register_crate");
@@ -425,7 +425,7 @@ impl<'a> CrateLoader<'a> {
425425
&'b mut self,
426426
name: Symbol,
427427
span: Span,
428-
dep_kind: DepKind,
428+
dep_kind: CrateDepKind,
429429
dep: Option<(&'b CratePaths, &'b CrateDep)>,
430430
) -> CrateNum {
431431
if dep.is_none() {
@@ -438,7 +438,7 @@ impl<'a> CrateLoader<'a> {
438438
fn maybe_resolve_crate<'b>(
439439
&'b mut self,
440440
name: Symbol,
441-
mut dep_kind: DepKind,
441+
mut dep_kind: CrateDepKind,
442442
dep: Option<(&'b CratePaths, &'b CrateDep)>,
443443
) -> Result<CrateNum, CrateError> {
444444
info!("resolving crate `{}`", name);
@@ -475,7 +475,7 @@ impl<'a> CrateLoader<'a> {
475475
match self.load(&mut locator)? {
476476
Some(res) => (res, None),
477477
None => {
478-
dep_kind = DepKind::MacrosOnly;
478+
dep_kind = CrateDepKind::MacrosOnly;
479479
match self.load_proc_macro(&mut locator, path_kind)? {
480480
Some(res) => res,
481481
None => return Err(locator.into_error()),
@@ -488,7 +488,7 @@ impl<'a> CrateLoader<'a> {
488488
(LoadResult::Previous(cnum), None) => {
489489
let data = self.cstore.get_crate_data(cnum);
490490
if data.is_proc_macro_crate() {
491-
dep_kind = DepKind::MacrosOnly;
491+
dep_kind = CrateDepKind::MacrosOnly;
492492
}
493493
data.update_dep_kind(|data_dep_kind| cmp::max(data_dep_kind, dep_kind));
494494
Ok(cnum)
@@ -548,7 +548,7 @@ impl<'a> CrateLoader<'a> {
548548
crate_root: &CrateRoot<'_>,
549549
metadata: &MetadataBlob,
550550
krate: CrateNum,
551-
dep_kind: DepKind,
551+
dep_kind: CrateDepKind,
552552
) -> Result<CrateNumMap, CrateError> {
553553
debug!("resolving deps of external crate");
554554
if crate_root.is_proc_macro_crate() {
@@ -567,7 +567,7 @@ impl<'a> CrateLoader<'a> {
567567
dep.name, dep.hash, dep.extra_filename
568568
);
569569
let dep_kind = match dep_kind {
570-
DepKind::MacrosOnly => DepKind::MacrosOnly,
570+
CrateDepKind::MacrosOnly => CrateDepKind::MacrosOnly,
571571
_ => dep.kind,
572572
};
573573
let cnum = self.maybe_resolve_crate(dep.name, dep_kind, Some((root, &dep)))?;
@@ -634,7 +634,7 @@ impl<'a> CrateLoader<'a> {
634634
self.inject_dependency_if(cnum, "a panic runtime", &|data| {
635635
data.needs_panic_runtime()
636636
});
637-
runtime_found = runtime_found || data.dep_kind() == DepKind::Explicit;
637+
runtime_found = runtime_found || data.dep_kind() == CrateDepKind::Explicit;
638638
}
639639
});
640640

@@ -663,7 +663,7 @@ impl<'a> CrateLoader<'a> {
663663
};
664664
info!("panic runtime not found -- loading {}", name);
665665

666-
let cnum = self.resolve_crate(name, DUMMY_SP, DepKind::Implicit, None);
666+
let cnum = self.resolve_crate(name, DUMMY_SP, CrateDepKind::Implicit, None);
667667
let data = self.cstore.get_crate_data(cnum);
668668

669669
// Sanity check the loaded crate to ensure it is indeed a panic runtime
@@ -693,7 +693,7 @@ impl<'a> CrateLoader<'a> {
693693
info!("loading profiler");
694694

695695
let name = sym::profiler_builtins;
696-
let cnum = self.resolve_crate(name, DUMMY_SP, DepKind::Implicit, None);
696+
let cnum = self.resolve_crate(name, DUMMY_SP, CrateDepKind::Implicit, None);
697697
let data = self.cstore.get_crate_data(cnum);
698698

699699
// Sanity check the loaded crate to ensure it is indeed a profiler runtime
@@ -891,9 +891,9 @@ impl<'a> CrateLoader<'a> {
891891
None => item.ident.name,
892892
};
893893
let dep_kind = if attr::contains_name(&item.attrs, sym::no_link) {
894-
DepKind::MacrosOnly
894+
CrateDepKind::MacrosOnly
895895
} else {
896-
DepKind::Explicit
896+
CrateDepKind::Explicit
897897
};
898898

899899
let cnum = self.resolve_crate(name, item.span, dep_kind, None);
@@ -915,7 +915,7 @@ impl<'a> CrateLoader<'a> {
915915
}
916916

917917
pub fn process_path_extern(&mut self, name: Symbol, span: Span) -> CrateNum {
918-
let cnum = self.resolve_crate(name, span, DepKind::Explicit, None);
918+
let cnum = self.resolve_crate(name, span, CrateDepKind::Explicit, None);
919919

920920
self.update_extern_crate(
921921
cnum,
@@ -932,6 +932,6 @@ impl<'a> CrateLoader<'a> {
932932
}
933933

934934
pub fn maybe_process_path_extern(&mut self, name: Symbol) -> Option<CrateNum> {
935-
self.maybe_resolve_crate(name, DepKind::Explicit, None).ok()
935+
self.maybe_resolve_crate(name, CrateDepKind::Explicit, None).ok()
936936
}
937937
}

src/librustc_metadata/dependency_format.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ use crate::creader::CStore;
5656
use rustc_data_structures::fx::FxHashMap;
5757
use rustc_hir::def_id::CrateNum;
5858
use rustc_middle::middle::cstore::LinkagePreference::{self, RequireDynamic, RequireStatic};
59-
use rustc_middle::middle::cstore::{self, DepKind};
59+
use rustc_middle::middle::cstore::{self, CrateDepKind};
6060
use rustc_middle::middle::dependency_format::{Dependencies, DependencyList, Linkage};
6161
use rustc_middle::ty::TyCtxt;
6262
use rustc_session::config::CrateType;
@@ -188,7 +188,7 @@ fn calculate_type(tcx: TyCtxt<'_>, ty: CrateType) -> DependencyList {
188188
let src = tcx.used_crate_source(cnum);
189189
if src.dylib.is_none()
190190
&& !formats.contains_key(&cnum)
191-
&& tcx.dep_kind(cnum) == DepKind::Explicit
191+
&& tcx.dep_kind(cnum) == CrateDepKind::Explicit
192192
{
193193
assert!(src.rlib.is_some() || src.rmeta.is_some());
194194
log::info!("adding staticlib: {}", tcx.crate_name(cnum));
@@ -284,7 +284,7 @@ fn attempt_static(tcx: TyCtxt<'_>) -> Option<DependencyList> {
284284
let last_crate = tcx.crates().len();
285285
let mut ret = (1..last_crate + 1)
286286
.map(|cnum| {
287-
if tcx.dep_kind(CrateNum::new(cnum)) == DepKind::Explicit {
287+
if tcx.dep_kind(CrateNum::new(cnum)) == CrateDepKind::Explicit {
288288
Linkage::Static
289289
} else {
290290
Linkage::NotLinked

src/librustc_metadata/rmeta/decoder.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ crate struct CrateMetadata {
100100
/// Same ID set as `cnum_map` plus maybe some injected crates like panic runtime.
101101
dependencies: Lock<Vec<CrateNum>>,
102102
/// How to link (or not link) this crate to the currently compiled crate.
103-
dep_kind: Lock<DepKind>,
103+
dep_kind: Lock<CrateDepKind>,
104104
/// Filesystem location of this crate.
105105
source: CrateSource,
106106
/// Whether or not this crate should be consider a private dependency
@@ -1670,7 +1670,7 @@ impl CrateMetadata {
16701670
raw_proc_macros: Option<&'static [ProcMacro]>,
16711671
cnum: CrateNum,
16721672
cnum_map: CrateNumMap,
1673-
dep_kind: DepKind,
1673+
dep_kind: CrateDepKind,
16741674
source: CrateSource,
16751675
private_dep: bool,
16761676
host_hash: Option<Svh>,
@@ -1728,11 +1728,11 @@ impl CrateMetadata {
17281728
&self.source
17291729
}
17301730

1731-
crate fn dep_kind(&self) -> DepKind {
1731+
crate fn dep_kind(&self) -> CrateDepKind {
17321732
*self.dep_kind.lock()
17331733
}
17341734

1735-
crate fn update_dep_kind(&self, f: impl FnOnce(DepKind) -> DepKind) {
1735+
crate fn update_dep_kind(&self, f: impl FnOnce(CrateDepKind) -> CrateDepKind) {
17361736
self.dep_kind.with_lock(|dep_kind| *dep_kind = f(*dep_kind))
17371737
}
17381738

src/librustc_metadata/rmeta/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_hir::def_id::{DefId, DefIndex};
1111
use rustc_hir::lang_items;
1212
use rustc_index::{bit_set::FiniteBitSet, vec::IndexVec};
1313
use rustc_middle::hir::exports::Export;
14-
use rustc_middle::middle::cstore::{DepKind, ForeignModule, LinkagePreference, NativeLib};
14+
use rustc_middle::middle::cstore::{CrateDepKind, ForeignModule, LinkagePreference, NativeLib};
1515
use rustc_middle::middle::exported_symbols::{ExportedSymbol, SymbolExportLevel};
1616
use rustc_middle::mir;
1717
use rustc_middle::ty::{self, ReprOptions, Ty};
@@ -226,7 +226,7 @@ crate struct CrateDep {
226226
pub name: Symbol,
227227
pub hash: Svh,
228228
pub host_hash: Option<Svh>,
229-
pub kind: DepKind,
229+
pub kind: CrateDepKind,
230230
pub extra_filename: String,
231231
}
232232

src/librustc_middle/middle/cstore.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl CrateSource {
4040

4141
#[derive(RustcEncodable, RustcDecodable, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Debug)]
4242
#[derive(HashStable)]
43-
pub enum DepKind {
43+
pub enum CrateDepKind {
4444
/// A dependency that is only used for its macros.
4545
MacrosOnly,
4646
/// A dependency that is always injected into the dependency list and so
@@ -51,11 +51,11 @@ pub enum DepKind {
5151
Explicit,
5252
}
5353

54-
impl DepKind {
54+
impl CrateDepKind {
5555
pub fn macros_only(self) -> bool {
5656
match self {
57-
DepKind::MacrosOnly => true,
58-
DepKind::Implicit | DepKind::Explicit => false,
57+
CrateDepKind::MacrosOnly => true,
58+
CrateDepKind::Implicit | CrateDepKind::Explicit => false,
5959
}
6060
}
6161
}

src/librustc_middle/query/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1180,7 +1180,7 @@ rustc_queries! {
11801180
}
11811181

11821182
Other {
1183-
query dep_kind(_: CrateNum) -> DepKind {
1183+
query dep_kind(_: CrateNum) -> CrateDepKind {
11841184
eval_always
11851185
desc { "fetching what a dependency looks like" }
11861186
}

src/librustc_middle/ty/query/mod.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
use crate::dep_graph::{self, DepNode, DepNodeParams};
1+
use crate::dep_graph::{self, DepKind, DepNode, DepNodeParams};
22
use crate::hir::exports::Export;
33
use crate::hir::map;
44
use crate::infer::canonical::{self, Canonical};
55
use crate::lint::LintLevelMap;
66
use crate::middle::codegen_fn_attrs::CodegenFnAttrs;
7-
use crate::middle::cstore::{CrateSource, DepKind};
7+
use crate::middle::cstore::{CrateDepKind, CrateSource};
88
use crate::middle::cstore::{ExternCrate, ForeignModule, LinkagePreference, NativeLib};
99
use crate::middle::exported_symbols::{ExportedSymbol, SymbolExportLevel};
1010
use crate::middle::lib_features::LibFeatures;
@@ -161,7 +161,7 @@ pub fn force_from_dep_node<'tcx>(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> bool
161161
// hit the cache instead of having to go through `force_from_dep_node`.
162162
// This assertion makes sure, we actually keep applying the solution above.
163163
debug_assert!(
164-
dep_node.kind != crate::dep_graph::DepKind::codegen_unit,
164+
dep_node.kind != DepKind::codegen_unit,
165165
"calling force_from_dep_node() on DepKind::codegen_unit"
166166
);
167167

@@ -172,14 +172,14 @@ pub fn force_from_dep_node<'tcx>(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> bool
172172
rustc_dep_node_force!([dep_node, tcx]
173173
// These are inputs that are expected to be pre-allocated and that
174174
// should therefore always be red or green already.
175-
crate::dep_graph::DepKind::CrateMetadata |
175+
DepKind::CrateMetadata |
176176

177177
// These are anonymous nodes.
178-
crate::dep_graph::DepKind::TraitSelect |
178+
DepKind::TraitSelect |
179179

180180
// We don't have enough information to reconstruct the query key of
181181
// these.
182-
crate::dep_graph::DepKind::CompileCodegenUnit => {
182+
DepKind::CompileCodegenUnit => {
183183
bug!("force_from_dep_node: encountered {:?}", dep_node)
184184
}
185185
);

0 commit comments

Comments
 (0)