} else {
Some(key.default_span(*tcx))
};
- // Use `tcx.hir().opt_def_kind()` to reduce the chance of
- // accidentally triggering an infinite query loop.
- let def_kind = key.key_as_def_id()
- .and_then(|def_id| def_id.as_local())
- .and_then(|def_id| tcx.hir().opt_def_kind(def_id));
+ let def_kind = if kind == dep_graph::DepKind::opt_def_kind {
+ // Try to avoid infinite recursion.
+ None
+ } else {
+ key.key_as_def_id()
+ .and_then(|def_id| def_id.as_local())
+ .and_then(|def_id| tcx.opt_def_kind(def_id))
+ };
let hash = || {
- let mut hcx = tcx.create_stable_hashing_context();
- let mut hasher = StableHasher::new();
- std::mem::discriminant(&kind).hash_stable(&mut hcx, &mut hasher);
- key.hash_stable(&mut hcx, &mut hasher);
- hasher.finish::<u64>()
+ tcx.with_stable_hashing_context(|mut hcx|{
+ let mut hasher = StableHasher::new();
+ std::mem::discriminant(&kind).hash_stable(&mut hcx, &mut hasher);
+ key.hash_stable(&mut hcx, &mut hasher);
+ hasher.finish::<u64>()
+ })
};
QueryStackFrame::new(name, description, span, def_kind, hash)
}
}
+ // We use this for the forever-red node.
+ pub fn Red() -> DepKindStruct {
+ DepKindStruct {
+ is_anon: false,
+ is_eval_always: false,
+ fingerprint_style: FingerprintStyle::Unit,
+ force_from_dep_node: Some(|_, dep_node| bug!("force_from_dep_node: encountered {:?}", dep_node)),
+ try_load_from_on_disk_cache: None,
+ }
+ }
+
pub fn TraitSelect() -> DepKindStruct {
DepKindStruct {
is_anon: true,