Skip to content

Commit baa74a8

Browse files
committed
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.
1 parent c4a69d4 commit baa74a8

6 files changed

Lines changed: 9 additions & 37 deletions

File tree

compiler/rustc_middle/src/dep_graph/dep_node.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,6 @@ impl DepKind {
8383
*self as usize
8484
}
8585

86-
pub(crate) fn name(self) -> &'static str {
87-
DEP_KIND_NAMES[self.as_usize()]
88-
}
89-
9086
/// This is the highest value a `DepKind` can have. It's used during encoding to
9187
/// pack information into the unused bits.
9288
pub(crate) const MAX: u16 = DEP_KIND_NUM_VARIANTS - 1;
@@ -287,9 +283,6 @@ pub struct DepKindVTable<'tcx> {
287283

288284
/// Invoke a query to put the on-disk cached value in memory.
289285
pub try_load_from_on_disk_cache: Option<fn(TyCtxt<'tcx>, DepNode)>,
290-
291-
/// The name of this dep kind.
292-
pub name: &'static &'static str,
293286
}
294287

295288
/// A "work product" corresponds to a `.o` (or other) file that we
@@ -372,12 +365,6 @@ macro_rules! define_dep_nodes {
372365
deps.len() as u16
373366
};
374367

375-
/// List containing the name of each dep kind as a static string,
376-
/// indexable by `DepKind`.
377-
pub(crate) const DEP_KIND_NAMES: &[&str] = &[
378-
$( self::label_strs::$variant, )*
379-
];
380-
381368
pub(super) fn dep_kind_from_label_string(label: &str) -> Result<DepKind, ()> {
382369
match label {
383370
$( stringify!($variant) => Ok(self::DepKind::$variant), )*

compiler/rustc_middle/src/dep_graph/serialized.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -288,13 +288,14 @@ impl SerializedDepGraph {
288288
if index[node.kind.as_usize()].insert(node.key_fingerprint, idx).is_some() {
289289
// Empty nodes and side effect nodes can have duplicates
290290
if node.kind != DepKind::Null && node.kind != DepKind::SideEffect {
291-
let name = node.kind.name();
291+
let kind = node.kind;
292292
panic!(
293-
"Error: A dep graph node ({name}) does not have an unique index. \
294-
Running a clean build on a nightly compiler with `-Z incremental-verify-ich` \
295-
can help narrow down the issue for reporting. A clean build may also work around the issue.\n
296-
DepNode: {node:?}"
297-
)
293+
"Error: A dep graph node ({kind:?}) does not have an unique index. \
294+
Running a clean build on a nightly compiler with \
295+
`-Z incremental-verify-ich` can help narrow down the issue for reporting. \
296+
A clean build may also work around the issue.\n
297+
DepNode: {node:?}"
298+
)
298299
}
299300
}
300301
}

compiler/rustc_query_impl/src/dep_kind_vtables.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ mod non_query {
2020
bug!("force_from_dep_node: encountered {dep_node:?}")
2121
}),
2222
try_load_from_on_disk_cache: None,
23-
name: &"Null",
2423
}
2524
}
2625

@@ -34,7 +33,6 @@ mod non_query {
3433
bug!("force_from_dep_node: encountered {dep_node:?}")
3534
}),
3635
try_load_from_on_disk_cache: None,
37-
name: &"Red",
3836
}
3937
}
4038

@@ -48,7 +46,6 @@ mod non_query {
4846
true
4947
}),
5048
try_load_from_on_disk_cache: None,
51-
name: &"SideEffect",
5249
}
5350
}
5451

@@ -59,7 +56,6 @@ mod non_query {
5956
key_fingerprint_style: KeyFingerprintStyle::Opaque,
6057
force_from_dep_node: Some(|_, _, _| bug!("cannot force an anon node")),
6158
try_load_from_on_disk_cache: None,
62-
name: &"AnonZeroDeps",
6359
}
6460
}
6561

@@ -70,7 +66,6 @@ mod non_query {
7066
key_fingerprint_style: KeyFingerprintStyle::Unit,
7167
force_from_dep_node: None,
7268
try_load_from_on_disk_cache: None,
73-
name: &"TraitSelect",
7469
}
7570
}
7671

@@ -81,7 +76,6 @@ mod non_query {
8176
key_fingerprint_style: KeyFingerprintStyle::Opaque,
8277
force_from_dep_node: None,
8378
try_load_from_on_disk_cache: None,
84-
name: &"CompileCodegenUnit",
8579
}
8680
}
8781

@@ -92,7 +86,6 @@ mod non_query {
9286
key_fingerprint_style: KeyFingerprintStyle::Opaque,
9387
force_from_dep_node: None,
9488
try_load_from_on_disk_cache: None,
95-
name: &"CompileMonoItem",
9689
}
9790
}
9891

@@ -103,7 +96,6 @@ mod non_query {
10396
key_fingerprint_style: KeyFingerprintStyle::Unit,
10497
force_from_dep_node: None,
10598
try_load_from_on_disk_cache: None,
106-
name: &"Metadata",
10799
}
108100
}
109101
}
@@ -131,7 +123,6 @@ where
131123
key_fingerprint_style,
132124
force_from_dep_node: None,
133125
try_load_from_on_disk_cache: None,
134-
name: Q::NAME,
135126
};
136127
}
137128

@@ -145,7 +136,6 @@ where
145136
try_load_from_on_disk_cache: Some(|tcx, dep_node| {
146137
try_load_from_on_disk_cache_inner(Q::query_dispatcher(tcx), tcx, dep_node)
147138
}),
148-
name: Q::NAME,
149139
}
150140
}
151141

compiler/rustc_query_impl/src/job.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -423,10 +423,8 @@ pub fn print_query_stack<'tcx>(
423423
if let Some(ref mut file) = file {
424424
let _ = writeln!(
425425
file,
426-
"#{} [{}] {}",
427-
count_total,
428-
tcx.dep_kind_vtable(query_info.frame.dep_kind).name,
429-
query_extra.description
426+
"#{} [{:?}] {}",
427+
count_total, query_info.frame.dep_kind, query_extra.description
430428
);
431429
}
432430

compiler/rustc_query_impl/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,6 @@ impl<'tcx, C: QueryCache, const FLAGS: QueryFlags> SemiDynamicQueryDispatcher<'t
231231
trait QueryDispatcherUnerased<'tcx, C: QueryCache, const FLAGS: QueryFlags> {
232232
type UnerasedValue;
233233

234-
const NAME: &'static &'static str;
235-
236234
fn query_dispatcher(tcx: TyCtxt<'tcx>) -> SemiDynamicQueryDispatcher<'tcx, C, FLAGS>;
237235

238236
fn restore_val(value: C::Value) -> Self::UnerasedValue;

compiler/rustc_query_impl/src/plumbing.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -630,8 +630,6 @@ macro_rules! define_queries {
630630
{
631631
type UnerasedValue = queries::$name::Value<'tcx>;
632632

633-
const NAME: &'static &'static str = &stringify!($name);
634-
635633
#[inline(always)]
636634
fn query_dispatcher(tcx: TyCtxt<'tcx>)
637635
-> SemiDynamicQueryDispatcher<'tcx, queries::$name::Storage<'tcx>, FLAGS>

0 commit comments

Comments
 (0)