Skip to content

Commit 4224b4b

Browse files
committed
Re-allow computing fed queries.
1 parent 791a7f2 commit 4224b4b

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

compiler/rustc_query_system/src/query/plumbing.rs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -410,9 +410,26 @@ where
410410
// as its feeding query had. So if the fed query is red, so is its feeder, which will
411411
// get evaluated first, and re-feed the query.
412412
if let Some((cached_result, _)) = cache.lookup(&key) {
413-
panic!(
414-
"fed query later has its value computed. The already cached value: {}",
415-
(query.format_value())(&cached_result)
413+
let Some(hasher) = query.hash_result() else {
414+
panic!(
415+
"fed query later has its value computed. The already cached value: {}",
416+
(query.format_value())(&cached_result)
417+
);
418+
};
419+
420+
let (old_hash, new_hash) = qcx.dep_context().with_stable_hashing_context(|mut hcx| {
421+
(hasher(&mut hcx, &cached_result), hasher(&mut hcx, &result))
422+
});
423+
let formatter = query.format_value();
424+
debug_assert_eq!(
425+
old_hash,
426+
new_hash,
427+
"Computed query value for {:?}({:?}) is inconsistent with fed value,\n\
428+
computed={:#?}\nfed={:#?}",
429+
query.dep_kind(),
430+
key,
431+
formatter(&result),
432+
formatter(&cached_result),
416433
);
417434
}
418435
}

0 commit comments

Comments
 (0)