Don't require a QueryContext to access the DepGraph.
This commit is contained in:
parent
7794fbb478
commit
211b05aef3
6 changed files with 13 additions and 14 deletions
|
@ -1,7 +1,6 @@
|
|||
//! Cache for candidate selection.
|
||||
|
||||
use crate::dep_graph::DepNodeIndex;
|
||||
use crate::query::QueryContext;
|
||||
use crate::dep_graph::{DepContext, DepNodeIndex};
|
||||
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_data_structures::sync::HashMapExt;
|
||||
|
@ -28,7 +27,7 @@ impl<Key, Value> Cache<Key, Value> {
|
|||
}
|
||||
|
||||
impl<Key: Eq + Hash, Value: Clone> Cache<Key, Value> {
|
||||
pub fn get<CTX: QueryContext>(&self, key: &Key, tcx: CTX) -> Option<Value> {
|
||||
pub fn get<CTX: DepContext>(&self, key: &Key, tcx: CTX) -> Option<Value> {
|
||||
Some(self.hashmap.borrow().get(key)?.get(tcx))
|
||||
}
|
||||
|
||||
|
@ -55,7 +54,7 @@ impl<T: Clone> WithDepNode<T> {
|
|||
WithDepNode { dep_node, cached_value }
|
||||
}
|
||||
|
||||
pub fn get<CTX: QueryContext>(&self, tcx: CTX) -> T {
|
||||
pub fn get<CTX: DepContext>(&self, tcx: CTX) -> T {
|
||||
tcx.dep_graph().read_index(self.dep_node);
|
||||
self.cached_value.clone()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue