Rename query dep_kind.

The next commit will bring back `enum DepKind` and there would be a
variant `DepKind::dep_kind`. This makes it impossible to have a variable
named `dep_kind`, because the `bindings_with_variant_name` lint is
overzealous. For this code:
```
let dep_kind = DepKind::dep_kind;
```
the lint will give this error:
```
pattern binding `dep_kind` is named the same as one of the variants of the type `DepKind`
```
This is arguably a bug in the lint. To work around it, this commit
renames the `dep_kind` query as `crate_dep_kind`. It is a better name
anyway given that `DepKind` and `CrateDepKind` are different things.
This commit is contained in:
Nicholas Nethercote
2026-02-17 11:37:01 +11:00
parent 1d410c5831
commit 90b994b883
5 changed files with 9 additions and 9 deletions
+1 -1
View File
@@ -911,7 +911,7 @@ pub fn new(tcx: TyCtxt<'_>, target_cpu: String) -> CrateInfo {
.rev()
.copied()
.filter(|&cnum| {
let link = !tcx.dep_kind(cnum).macros_only();
let link = !tcx.crate_dep_kind(cnum).macros_only();
if link && tcx.is_compiler_builtins(cnum) {
compiler_builtins = Some(cnum);
return false;
@@ -146,7 +146,7 @@ fn calculate_type(tcx: TyCtxt<'_>, ty: CrateType) -> DependencyList {
&& !sess.target.crt_static_allows_dylibs)
{
for &cnum in tcx.crates(()).iter() {
if tcx.dep_kind(cnum).macros_only() {
if tcx.crate_dep_kind(cnum).macros_only() {
continue;
}
let src = tcx.used_crate_source(cnum);
@@ -163,7 +163,7 @@ fn calculate_type(tcx: TyCtxt<'_>, ty: CrateType) -> DependencyList {
let all_dylibs = || {
tcx.crates(()).iter().filter(|&&cnum| {
!tcx.dep_kind(cnum).macros_only()
!tcx.crate_dep_kind(cnum).macros_only()
&& (tcx.used_crate_source(cnum).dylib.is_some()
|| tcx.used_crate_source(cnum).sdylib_interface.is_some())
})
@@ -241,7 +241,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) == CrateDepKind::Unconditional
&& tcx.crate_dep_kind(cnum) == CrateDepKind::Unconditional
{
assert!(src.rlib.is_some() || src.rmeta.is_some());
info!("adding staticlib: {}", tcx.crate_name(cnum));
@@ -333,7 +333,7 @@ fn attempt_static(tcx: TyCtxt<'_>, unavailable: &mut Vec<CrateNum>) -> Option<De
.iter()
.copied()
.filter_map(|cnum| {
if tcx.dep_kind(cnum).macros_only() {
if tcx.crate_dep_kind(cnum).macros_only() {
return None;
}
let is_rlib = tcx.used_crate_source(cnum).rlib.is_some();
@@ -353,7 +353,7 @@ fn attempt_static(tcx: TyCtxt<'_>, unavailable: &mut Vec<CrateNum>) -> Option<De
assert_eq!(ret.push(Linkage::Static), LOCAL_CRATE);
for &cnum in tcx.crates(()) {
assert_eq!(
ret.push(match tcx.dep_kind(cnum) {
ret.push(match tcx.crate_dep_kind(cnum) {
CrateDepKind::Unconditional => Linkage::Static,
CrateDepKind::MacrosOnly | CrateDepKind::Conditional => Linkage::NotLinked,
}),
@@ -382,7 +382,7 @@ fn into_args(self) -> (DefId, SimplifiedType) {
implementations_of_trait => { cdata.get_implementations_of_trait(tcx, other) }
crate_incoherent_impls => { cdata.get_incoherent_impls(tcx, other) }
dep_kind => { cdata.dep_kind }
crate_dep_kind => { cdata.dep_kind }
module_children => {
tcx.arena.alloc_from_iter(cdata.get_module_children(tcx, def_id.index))
}
+1 -1
View File
@@ -2072,7 +2072,7 @@ fn encode_crate_deps(&mut self) -> LazyArray<CrateDep> {
name: self.tcx.crate_name(cnum),
hash: self.tcx.crate_hash(cnum),
host_hash: self.tcx.crate_host_hash(cnum),
kind: self.tcx.dep_kind(cnum),
kind: self.tcx.crate_dep_kind(cnum),
extra_filename: self.tcx.extra_filename(cnum).clone(),
is_private: self.tcx.is_private_dep(cnum),
};
+1 -1
View File
@@ -2179,7 +2179,7 @@
desc { "computing the uninhabited predicate of `{}`", key }
}
query dep_kind(_: CrateNum) -> CrateDepKind {
query crate_dep_kind(_: CrateNum) -> CrateDepKind {
eval_always
desc { "fetching what a dependency looks like" }
separate_provide_extern