From 4224b4b1f5695a70b268f36fa845ce9f224c1d6b Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sun, 19 Feb 2023 13:14:00 +0000 Subject: [PATCH] Re-allow computing fed queries. --- .../rustc_query_system/src/query/plumbing.rs | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_query_system/src/query/plumbing.rs b/compiler/rustc_query_system/src/query/plumbing.rs index 4a6d07a03cc..c122c7d722d 100644 --- a/compiler/rustc_query_system/src/query/plumbing.rs +++ b/compiler/rustc_query_system/src/query/plumbing.rs @@ -410,9 +410,26 @@ where // as its feeding query had. So if the fed query is red, so is its feeder, which will // get evaluated first, and re-feed the query. if let Some((cached_result, _)) = cache.lookup(&key) { - panic!( - "fed query later has its value computed. The already cached value: {}", - (query.format_value())(&cached_result) + let Some(hasher) = query.hash_result() else { + panic!( + "fed query later has its value computed. The already cached value: {}", + (query.format_value())(&cached_result) + ); + }; + + let (old_hash, new_hash) = qcx.dep_context().with_stable_hashing_context(|mut hcx| { + (hasher(&mut hcx, &cached_result), hasher(&mut hcx, &result)) + }); + let formatter = query.format_value(); + debug_assert_eq!( + old_hash, + new_hash, + "Computed query value for {:?}({:?}) is inconsistent with fed value,\n\ + computed={:#?}\nfed={:#?}", + query.dep_kind(), + key, + formatter(&result), + formatter(&cached_result), ); } }