QueryCache in rustc_query_system::query::caches - Rust (original) (raw)

pub trait QueryCache: Sized {
    type Key: Hash + Eq + Copy + Debug;
    type Value: Copy;

    // Required methods
    fn lookup(&self, key: &Self::Key) -> Option<(Self::Value, DepNodeIndex)>;
    fn complete(&self, key: Self::Key, value: Self::Value, index: DepNodeIndex);
    fn iter(&self, f: &mut dyn FnMut(&Self::Key, &Self::Value, DepNodeIndex));
}

Expand description

Trait for types that serve as an in-memory cache for query results, for a given key (argument) type and value (return) type.

Types implementing this trait are associated with actual key/value types by the Cache associated type of the rustc_middle::query::Key trait.

Source

Source

Source

Returns the cached value (and other information) associated with the given key, if it is present in the cache.

Source

Adds a key/value entry to this cache.

Called by some part of the query system, after having obtained the value by executing the query or loading a cached value from disk.

Source

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.