Remove DepKind name plumbing.

There is a bunch of plumbing to record the string `"foo"` for each
variant `DepKind::foo`. But that's what the `Debug `impl` now produces.
So this commit removes the plumbing.
This commit is contained in:
Nicholas Nethercote
2026-02-17 12:55:14 +11:00
parent c4a69d4712
commit baa74a85ee
6 changed files with 9 additions and 37 deletions
@@ -83,10 +83,6 @@ pub const fn as_usize(&self) -> usize {
*self as usize
}
pub(crate) fn name(self) -> &'static str {
DEP_KIND_NAMES[self.as_usize()]
}
/// This is the highest value a `DepKind` can have. It's used during encoding to
/// pack information into the unused bits.
pub(crate) const MAX: u16 = DEP_KIND_NUM_VARIANTS - 1;
@@ -287,9 +283,6 @@ pub struct DepKindVTable<'tcx> {
/// Invoke a query to put the on-disk cached value in memory.
pub try_load_from_on_disk_cache: Option<fn(TyCtxt<'tcx>, DepNode)>,
/// The name of this dep kind.
pub name: &'static &'static str,
}
/// A "work product" corresponds to a `.o` (or other) file that we
@@ -372,12 +365,6 @@ pub enum DepKind {
deps.len() as u16
};
/// List containing the name of each dep kind as a static string,
/// indexable by `DepKind`.
pub(crate) const DEP_KIND_NAMES: &[&str] = &[
$( self::label_strs::$variant, )*
];
pub(super) fn dep_kind_from_label_string(label: &str) -> Result<DepKind, ()> {
match label {
$( stringify!($variant) => Ok(self::DepKind::$variant), )*
@@ -288,13 +288,14 @@ pub fn decode(d: &mut MemDecoder<'_>) -> Arc<SerializedDepGraph> {
if index[node.kind.as_usize()].insert(node.key_fingerprint, idx).is_some() {
// Empty nodes and side effect nodes can have duplicates
if node.kind != DepKind::Null && node.kind != DepKind::SideEffect {
let name = node.kind.name();
let kind = node.kind;
panic!(
"Error: A dep graph node ({name}) does not have an unique index. \
Running a clean build on a nightly compiler with `-Z incremental-verify-ich` \
can help narrow down the issue for reporting. A clean build may also work around the issue.\n
DepNode: {node:?}"
)
"Error: A dep graph node ({kind:?}) does not have an unique index. \
Running a clean build on a nightly compiler with \
`-Z incremental-verify-ich` can help narrow down the issue for reporting. \
A clean build may also work around the issue.\n
DepNode: {node:?}"
)
}
}
}
@@ -20,7 +20,6 @@ pub(crate) fn Null<'tcx>() -> DepKindVTable<'tcx> {
bug!("force_from_dep_node: encountered {dep_node:?}")
}),
try_load_from_on_disk_cache: None,
name: &"Null",
}
}
@@ -34,7 +33,6 @@ pub(crate) fn Red<'tcx>() -> DepKindVTable<'tcx> {
bug!("force_from_dep_node: encountered {dep_node:?}")
}),
try_load_from_on_disk_cache: None,
name: &"Red",
}
}
@@ -48,7 +46,6 @@ pub(crate) fn SideEffect<'tcx>() -> DepKindVTable<'tcx> {
true
}),
try_load_from_on_disk_cache: None,
name: &"SideEffect",
}
}
@@ -59,7 +56,6 @@ pub(crate) fn AnonZeroDeps<'tcx>() -> DepKindVTable<'tcx> {
key_fingerprint_style: KeyFingerprintStyle::Opaque,
force_from_dep_node: Some(|_, _, _| bug!("cannot force an anon node")),
try_load_from_on_disk_cache: None,
name: &"AnonZeroDeps",
}
}
@@ -70,7 +66,6 @@ pub(crate) fn TraitSelect<'tcx>() -> DepKindVTable<'tcx> {
key_fingerprint_style: KeyFingerprintStyle::Unit,
force_from_dep_node: None,
try_load_from_on_disk_cache: None,
name: &"TraitSelect",
}
}
@@ -81,7 +76,6 @@ pub(crate) fn CompileCodegenUnit<'tcx>() -> DepKindVTable<'tcx> {
key_fingerprint_style: KeyFingerprintStyle::Opaque,
force_from_dep_node: None,
try_load_from_on_disk_cache: None,
name: &"CompileCodegenUnit",
}
}
@@ -92,7 +86,6 @@ pub(crate) fn CompileMonoItem<'tcx>() -> DepKindVTable<'tcx> {
key_fingerprint_style: KeyFingerprintStyle::Opaque,
force_from_dep_node: None,
try_load_from_on_disk_cache: None,
name: &"CompileMonoItem",
}
}
@@ -103,7 +96,6 @@ pub(crate) fn Metadata<'tcx>() -> DepKindVTable<'tcx> {
key_fingerprint_style: KeyFingerprintStyle::Unit,
force_from_dep_node: None,
try_load_from_on_disk_cache: None,
name: &"Metadata",
}
}
}
@@ -131,7 +123,6 @@ pub(crate) fn make_dep_kind_vtable_for_query<'tcx, Q, Cache, const FLAGS: QueryF
key_fingerprint_style,
force_from_dep_node: None,
try_load_from_on_disk_cache: None,
name: Q::NAME,
};
}
@@ -145,7 +136,6 @@ pub(crate) fn make_dep_kind_vtable_for_query<'tcx, Q, Cache, const FLAGS: QueryF
try_load_from_on_disk_cache: Some(|tcx, dep_node| {
try_load_from_on_disk_cache_inner(Q::query_dispatcher(tcx), tcx, dep_node)
}),
name: Q::NAME,
}
}
+2 -4
View File
@@ -423,10 +423,8 @@ pub fn print_query_stack<'tcx>(
if let Some(ref mut file) = file {
let _ = writeln!(
file,
"#{} [{}] {}",
count_total,
tcx.dep_kind_vtable(query_info.frame.dep_kind).name,
query_extra.description
"#{} [{:?}] {}",
count_total, query_info.frame.dep_kind, query_extra.description
);
}
-2
View File
@@ -231,8 +231,6 @@ fn construct_dep_node(self, tcx: TyCtxt<'tcx>, key: &C::Key) -> DepNode {
trait QueryDispatcherUnerased<'tcx, C: QueryCache, const FLAGS: QueryFlags> {
type UnerasedValue;
const NAME: &'static &'static str;
fn query_dispatcher(tcx: TyCtxt<'tcx>) -> SemiDynamicQueryDispatcher<'tcx, C, FLAGS>;
fn restore_val(value: C::Value) -> Self::UnerasedValue;
@@ -630,8 +630,6 @@ impl<'tcx> QueryDispatcherUnerased<'tcx, queries::$name::Storage<'tcx>, FLAGS>
{
type UnerasedValue = queries::$name::Value<'tcx>;
const NAME: &'static &'static str = &stringify!($name);
#[inline(always)]
fn query_dispatcher(tcx: TyCtxt<'tcx>)
-> SemiDynamicQueryDispatcher<'tcx, queries::$name::Storage<'tcx>, FLAGS>