Auto merge of #80692 - Aaron1011:feature/query-result-debug, r=estebank
Enforce that query results implement Debug Currently, we require that query keys implement `Debug`, but we do not do the same for query values. This can make incremental compilation bugs difficult to debug - there isn't a good place to print out the result loaded from disk. This PR adds `Debug` bounds to several query-related functions, allowing us to debug-print the query value when an 'unstable fingerprint' error occurs. This required adding `#[derive(Debug)]` to a fairly large number of types - hopefully, this doesn't have much of an impact on compiler bootstrapping times.
This commit is contained in:
commit
a8f7075532
23 changed files with 46 additions and 34 deletions
|
@ -15,7 +15,7 @@ pub trait CacheSelector<K, V> {
|
|||
}
|
||||
|
||||
pub trait QueryStorage: Default {
|
||||
type Value;
|
||||
type Value: Debug;
|
||||
type Stored: Clone;
|
||||
|
||||
/// Store a value without putting it in the cache.
|
||||
|
@ -75,7 +75,7 @@ impl<K, V> Default for DefaultCache<K, V> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<K: Eq + Hash, V: Clone> QueryStorage for DefaultCache<K, V> {
|
||||
impl<K: Eq + Hash, V: Clone + Debug> QueryStorage for DefaultCache<K, V> {
|
||||
type Value = V;
|
||||
type Stored = V;
|
||||
|
||||
|
@ -89,7 +89,7 @@ impl<K: Eq + Hash, V: Clone> QueryStorage for DefaultCache<K, V> {
|
|||
impl<K, V> QueryCache for DefaultCache<K, V>
|
||||
where
|
||||
K: Eq + Hash + Clone + Debug,
|
||||
V: Clone,
|
||||
V: Clone + Debug,
|
||||
{
|
||||
type Key = K;
|
||||
type Sharded = FxHashMap<K, (V, DepNodeIndex)>;
|
||||
|
@ -156,7 +156,7 @@ impl<'tcx, K, V> Default for ArenaCache<'tcx, K, V> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx, K: Eq + Hash, V: 'tcx> QueryStorage for ArenaCache<'tcx, K, V> {
|
||||
impl<'tcx, K: Eq + Hash, V: Debug + 'tcx> QueryStorage for ArenaCache<'tcx, K, V> {
|
||||
type Value = V;
|
||||
type Stored = &'tcx V;
|
||||
|
||||
|
@ -171,6 +171,7 @@ impl<'tcx, K: Eq + Hash, V: 'tcx> QueryStorage for ArenaCache<'tcx, K, V> {
|
|||
impl<'tcx, K, V: 'tcx> QueryCache for ArenaCache<'tcx, K, V>
|
||||
where
|
||||
K: Eq + Hash + Clone + Debug,
|
||||
V: Debug,
|
||||
{
|
||||
type Key = K;
|
||||
type Sharded = FxHashMap<K, &'tcx (V, DepNodeIndex)>;
|
||||
|
|
|
@ -20,6 +20,7 @@ use rustc_errors::{Diagnostic, FatalError};
|
|||
use rustc_span::source_map::DUMMY_SP;
|
||||
use rustc_span::Span;
|
||||
use std::collections::hash_map::Entry;
|
||||
use std::fmt::Debug;
|
||||
use std::hash::{Hash, Hasher};
|
||||
use std::mem;
|
||||
use std::num::NonZeroU32;
|
||||
|
@ -478,7 +479,7 @@ where
|
|||
result
|
||||
}
|
||||
|
||||
fn load_from_disk_and_cache_in_memory<CTX, K, V>(
|
||||
fn load_from_disk_and_cache_in_memory<CTX, K, V: Debug>(
|
||||
tcx: CTX,
|
||||
key: K,
|
||||
prev_dep_node_index: SerializedDepNodeIndex,
|
||||
|
@ -539,7 +540,7 @@ where
|
|||
|
||||
#[inline(never)]
|
||||
#[cold]
|
||||
fn incremental_verify_ich<CTX, K, V>(
|
||||
fn incremental_verify_ich<CTX, K, V: Debug>(
|
||||
tcx: CTX,
|
||||
result: &V,
|
||||
dep_node: &DepNode<CTX::DepKind>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue