Allow to create definitions inside the query system.

This commit is contained in:
Camille GILLOT 2021-07-12 22:19:25 +02:00
parent 3dcb616888
commit 43bb31b954
23 changed files with 260 additions and 150 deletions

View file

@ -131,12 +131,11 @@ where
#[inline(always)]
default fn to_fingerprint(&self, tcx: Ctxt) -> Fingerprint {
let mut hcx = tcx.create_stable_hashing_context();
let mut hasher = StableHasher::new();
self.hash_stable(&mut hcx, &mut hasher);
hasher.finish()
tcx.with_stable_hashing_context(|mut hcx| {
let mut hasher = StableHasher::new();
self.hash_stable(&mut hcx, &mut hasher);
hasher.finish()
})
}
#[inline(always)]

View file

@ -328,10 +328,8 @@ impl<K: DepKind> DepGraph<K> {
let dcx = cx.dep_context();
let hashing_timer = dcx.profiler().incr_result_hashing();
let current_fingerprint = hash_result.map(|f| {
let mut hcx = dcx.create_stable_hashing_context();
f(&mut hcx, &result)
});
let current_fingerprint =
hash_result.map(|f| dcx.with_stable_hashing_context(|mut hcx| f(&mut hcx, &result)));
let print_status = cfg!(debug_assertions) && dcx.sess().opts.debugging_opts.dep_tasks;

View file

@ -23,7 +23,7 @@ pub trait DepContext: Copy {
type DepKind: self::DepKind;
/// Create a hashing context for hashing new results.
fn create_stable_hashing_context(&self) -> StableHashingContext<'_>;
fn with_stable_hashing_context<R>(&self, f: impl FnOnce(StableHashingContext<'_>) -> R) -> R;
/// Access the DepGraph.
fn dep_graph(&self) -> &DepGraph<Self::DepKind>;

View file

@ -1,4 +1,5 @@
use crate::ich;
use rustc_ast as ast;
use rustc_data_structures::sorted_map::SortedMap;
use rustc_data_structures::stable_hasher::{HashStable, HashingControls, StableHasher};

View file

@ -542,8 +542,7 @@ fn incremental_verify_ich<CTX, K, V: Debug>(
debug!("BEGIN verify_ich({:?})", dep_node);
let new_hash = query.hash_result.map_or(Fingerprint::ZERO, |f| {
let mut hcx = tcx.create_stable_hashing_context();
f(&mut hcx, result)
tcx.with_stable_hashing_context(|mut hcx| f(&mut hcx, result))
});
let old_hash = tcx.dep_graph().prev_fingerprint_of(dep_node);
debug!("END verify_ich({:?})", dep_node);