Skip to content

Commit 1988423

Browse files
committed
Prepare define_feedable! for code extraction
1 parent 2ec9c2e commit 1988423

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

compiler/rustc_middle/src/query/plumbing.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,8 @@ macro_rules! define_feedable {
570570
let value = restore::<$V>(erased);
571571
let cache = &tcx.query_system.caches.$name;
572572

573+
let name: &'static str = stringify!($name);
574+
let dep_kind: dep_graph::DepKind = dep_graph::dep_kinds::$name;
573575
let hasher: Option<fn(&mut StableHashingContext<'_>, &_) -> _> = hash_result!([$($modifiers)*]);
574576
match try_get_cached(tcx, cache, &key) {
575577
Some(old) => {
@@ -583,28 +585,27 @@ macro_rules! define_feedable {
583585
// results is tainted by errors. In this case, delay a bug to
584586
// ensure compilation is doomed, and keep the `old` value.
585587
tcx.dcx().delayed_bug(format!(
586-
"Trying to feed an already recorded value for query {} key={key:?}:\n\
588+
"Trying to feed an already recorded value for query {name} key={key:?}:\n\
587589
old value: {old:?}\nnew value: {value:?}",
588-
stringify!($name),
589590
));
590591
}
591592
} else {
592593
// The query is `no_hash`, so we have no way to perform a sanity check.
593594
// If feeding the same value multiple times needs to be supported,
594595
// the query should not be marked `no_hash`.
595596
bug!(
596-
"Trying to feed an already recorded value for query {} key={key:?}:\nold value: {old:?}\nnew value: {value:?}",
597-
stringify!($name),
597+
"Trying to feed an already recorded value for query {name} key={key:?}:\n\
598+
old value: {old:?}\nnew value: {value:?}",
598599
)
599600
}
600601
}
601602
None => {
602-
let dep_node = dep_graph::DepNode::construct(tcx, dep_graph::dep_kinds::$name, &key);
603+
let dep_node = dep_graph::DepNode::construct(tcx, dep_kind, &key);
603604
let dep_node_index = tcx.dep_graph.with_feed_task(
604605
dep_node,
605606
tcx,
606607
&value,
607-
hash_result!([$($modifiers)*]),
608+
hasher,
608609
);
609610
cache.complete(key, erased, dep_node_index);
610611
}

0 commit comments

Comments
 (0)