Skip to content

Commit 595a2f5

Browse files
authored
Rollup merge of rust-lang#75054 - cjgillot:rename-depkind, r=petrochenkov
Rename rustc_middle::cstore::DepKind to CrateDepKind It is ambiguous with DepGraph's own DepKind.
2 parents d4cc6d8 + 4d4b8f2 commit 595a2f5

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};
@@ -306,7 +306,7 @@ impl<'a> CrateLoader<'a> {
306306
host_lib: Option<Library>,
307307
root: Option<&CratePaths>,
308308
lib: Library,
309-
dep_kind: DepKind,
309+
dep_kind: CrateDepKind,
310310
name: Symbol,
311311
) -> Result<CrateNum, CrateError> {
312312
let _prof_timer = self.sess.prof.generic_activity("metadata_register_crate");
@@ -437,7 +437,7 @@ impl<'a> CrateLoader<'a> {
437437
&'b mut self,
438438
name: Symbol,
439439
span: Span,
440-
dep_kind: DepKind,
440+
dep_kind: CrateDepKind,
441441
dep: Option<(&'b CratePaths, &'b CrateDep)>,
442442
) -> CrateNum {
443443
if dep.is_none() {
@@ -450,7 +450,7 @@ impl<'a> CrateLoader<'a> {
450450
fn maybe_resolve_crate<'b>(
451451
&'b mut self,
452452
name: Symbol,
453-
mut dep_kind: DepKind,
453+
mut dep_kind: CrateDepKind,
454454
dep: Option<(&'b CratePaths, &'b CrateDep)>,
455455
) -> Result<CrateNum, CrateError> {
456456
info!("resolving crate `{}`", name);
@@ -487,7 +487,7 @@ impl<'a> CrateLoader<'a> {
487487
match self.load(&mut locator)? {
488488
Some(res) => (res, None),
489489
None => {
490-
dep_kind = DepKind::MacrosOnly;
490+
dep_kind = CrateDepKind::MacrosOnly;
491491
match self.load_proc_macro(&mut locator, path_kind)? {
492492
Some(res) => res,
493493
None => return Err(locator.into_error()),
@@ -500,7 +500,7 @@ impl<'a> CrateLoader<'a> {
500500
(LoadResult::Previous(cnum), None) => {
501501
let data = self.cstore.get_crate_data(cnum);
502502
if data.is_proc_macro_crate() {
503-
dep_kind = DepKind::MacrosOnly;
503+
dep_kind = CrateDepKind::MacrosOnly;
504504
}
505505
data.update_dep_kind(|data_dep_kind| cmp::max(data_dep_kind, dep_kind));
506506
Ok(cnum)
@@ -560,7 +560,7 @@ impl<'a> CrateLoader<'a> {
560560
crate_root: &CrateRoot<'_>,
561561
metadata: &MetadataBlob,
562562
krate: CrateNum,
563-
dep_kind: DepKind,
563+
dep_kind: CrateDepKind,
564564
) -> Result<CrateNumMap, CrateError> {
565565
debug!("resolving deps of external crate");
566566
if crate_root.is_proc_macro_crate() {
@@ -579,7 +579,7 @@ impl<'a> CrateLoader<'a> {
579579
dep.name, dep.hash, dep.extra_filename
580580
);
581581
let dep_kind = match dep_kind {
582-
DepKind::MacrosOnly => DepKind::MacrosOnly,
582+
CrateDepKind::MacrosOnly => CrateDepKind::MacrosOnly,
583583
_ => dep.kind,
584584
};
585585
let cnum = self.maybe_resolve_crate(dep.name, dep_kind, Some((root, &dep)))?;
@@ -646,7 +646,7 @@ impl<'a> CrateLoader<'a> {
646646
self.inject_dependency_if(cnum, "a panic runtime", &|data| {
647647
data.needs_panic_runtime()
648648
});
649-
runtime_found = runtime_found || data.dep_kind() == DepKind::Explicit;
649+
runtime_found = runtime_found || data.dep_kind() == CrateDepKind::Explicit;
650650
}
651651
});
652652

@@ -675,7 +675,7 @@ impl<'a> CrateLoader<'a> {
675675
};
676676
info!("panic runtime not found -- loading {}", name);
677677

678-
let cnum = self.resolve_crate(name, DUMMY_SP, DepKind::Implicit, None);
678+
let cnum = self.resolve_crate(name, DUMMY_SP, CrateDepKind::Implicit, None);
679679
let data = self.cstore.get_crate_data(cnum);
680680

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

707707
let name = sym::profiler_builtins;
708-
let cnum = self.resolve_crate(name, DUMMY_SP, DepKind::Implicit, None);
708+
let cnum = self.resolve_crate(name, DUMMY_SP, CrateDepKind::Implicit, None);
709709
let data = self.cstore.get_crate_data(cnum);
710710

711711
// Sanity check the loaded crate to ensure it is indeed a profiler runtime
@@ -901,9 +901,9 @@ impl<'a> CrateLoader<'a> {
901901
None => item.ident.name,
902902
};
903903
let dep_kind = if attr::contains_name(&item.attrs, sym::no_link) {
904-
DepKind::MacrosOnly
904+
CrateDepKind::MacrosOnly
905905
} else {
906-
DepKind::Explicit
906+
CrateDepKind::Explicit
907907
};
908908

909909
let cnum = self.resolve_crate(name, item.span, dep_kind, None);
@@ -925,7 +925,7 @@ impl<'a> CrateLoader<'a> {
925925
}
926926

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

930930
self.update_extern_crate(
931931
cnum,
@@ -942,6 +942,6 @@ impl<'a> CrateLoader<'a> {
942942
}
943943

944944
pub fn maybe_process_path_extern(&mut self, name: Symbol) -> Option<CrateNum> {
945-
self.maybe_resolve_crate(name, DepKind::Explicit, None).ok()
945+
self.maybe_resolve_crate(name, CrateDepKind::Explicit, None).ok()
946946
}
947947
}

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
@@ -1669,7 +1669,7 @@ impl CrateMetadata {
16691669
raw_proc_macros: Option<&'static [ProcMacro]>,
16701670
cnum: CrateNum,
16711671
cnum_map: CrateNumMap,
1672-
dep_kind: DepKind,
1672+
dep_kind: CrateDepKind,
16731673
source: CrateSource,
16741674
private_dep: bool,
16751675
host_hash: Option<Svh>,
@@ -1727,11 +1727,11 @@ impl CrateMetadata {
17271727
&self.source
17281728
}
17291729

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

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

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
@@ -1186,7 +1186,7 @@ rustc_queries! {
11861186
}
11871187

11881188
Other {
1189-
query dep_kind(_: CrateNum) -> DepKind {
1189+
query dep_kind(_: CrateNum) -> CrateDepKind {
11901190
eval_always
11911191
desc { "fetching what a dependency looks like" }
11921192
}

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)