Skip to content

Commit d9c9040

Browse files
authored
Rollup merge of #108046 - oli-obk:no_evaluating_fed_queries, r=cjgillot
Don't allow evaluating queries that were fed in a previous compiler run r? `@cjgillot` this code was already unreachable. Also we removed the no_hash + feeding restriction in #105220.
2 parents 3035ccb + b4182d2 commit d9c9040

File tree

1 file changed

+6
-19
lines changed

1 file changed

+6
-19
lines changed

compiler/rustc_query_system/src/query/plumbing.rs

+6-19
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ use rustc_data_structures::sync::Lock;
1919
use rustc_errors::{DiagnosticBuilder, ErrorGuaranteed, FatalError};
2020
use rustc_session::Session;
2121
use rustc_span::{Span, DUMMY_SP};
22-
use std::borrow::Borrow;
2322
use std::cell::Cell;
2423
use std::collections::hash_map::Entry;
2524
use std::fmt::Debug;
@@ -364,25 +363,13 @@ where
364363
let (result, dep_node_index) =
365364
execute_job::<Q, Qcx>(qcx, key.clone(), dep_node, job.id);
366365
if Q::FEEDABLE {
367-
// We may have put a value inside the cache from inside the execution.
368-
// Verify that it has the same hash as what we have now, to ensure consistency.
366+
// We should not compute queries that also got a value via feeding.
367+
// This can't happen, as query feeding adds the very dependencies to the fed query
368+
// as its feeding query had. So if the fed query is red, so is its feeder, which will
369+
// get evaluated first, and re-feed the query.
369370
if let Some((cached_result, _)) = cache.lookup(&key) {
370-
let hasher = Q::HASH_RESULT.expect("feedable forbids no_hash");
371-
372-
let old_hash = qcx.dep_context().with_stable_hashing_context(|mut hcx| {
373-
hasher(&mut hcx, cached_result.borrow())
374-
});
375-
let new_hash = qcx
376-
.dep_context()
377-
.with_stable_hashing_context(|mut hcx| hasher(&mut hcx, &result));
378-
debug_assert_eq!(
379-
old_hash,
380-
new_hash,
381-
"Computed query value for {:?}({:?}) is inconsistent with fed value,\ncomputed={:#?}\nfed={:#?}",
382-
Q::DEP_KIND,
383-
key,
384-
result,
385-
cached_result,
371+
panic!(
372+
"fed query later has its value computed. The already cached value: {cached_result:?}"
386373
);
387374
}
388375
}

0 commit comments

Comments
 (0)