Don't create two new closures for each query

- Parameterize DepKindStruct over `'tcx`

    This allows passing in an invariant function pointer in `query_callback`,
    rather than having to try and make it work for any lifetime.

- Add a new `execute_query` function to `QueryDescription` so we can call `tcx.$name` without needing to be in a macro context
This commit is contained in:
Joshua Nelson 2022-08-29 10:20:14 -05:00
parent 4fcc745266
commit 4e09a13bb8
5 changed files with 31 additions and 37 deletions

View file

@ -73,4 +73,7 @@ pub trait QueryDescription<CTX: QueryContext>: QueryConfig {
fn make_vtable(tcx: CTX, key: &Self::Key) -> QueryVTable<CTX, Self::Key, Self::Value>;
fn cache_on_disk(tcx: CTX::DepContext, key: &Self::Key) -> bool;
// Don't use this method to compute query results, instead use the methods on TyCtxt
fn execute_query(tcx: CTX::DepContext, k: Self::Key) -> Self::Stored;
}