Remove QueryEngine trait
This commit is contained in:
parent
897a146006
commit
66d85438ca
20 changed files with 272 additions and 327 deletions
|
@ -11,6 +11,7 @@ chalk-ir = "0.87.0"
|
|||
derive_more = "0.99.17"
|
||||
either = "1.5.0"
|
||||
gsgdt = "0.1.2"
|
||||
measureme = "10.0.0"
|
||||
polonius-engine = "0.13.0"
|
||||
rustc_apfloat = { path = "../rustc_apfloat" }
|
||||
rustc_arena = { path = "../rustc_arena" }
|
||||
|
|
|
@ -227,7 +227,9 @@ pub fn specialized_encode_alloc_id<'tcx, E: TyEncoder<I = TyCtxt<'tcx>>>(
|
|||
// References to statics doesn't need to know about their allocations,
|
||||
// just about its `DefId`.
|
||||
AllocDiscriminant::Static.encode(encoder);
|
||||
did.encode(encoder);
|
||||
// Cannot use `did.encode(encoder)` because of a bug around
|
||||
// specializations and method calls.
|
||||
Encodable::<E>::encode(&did, encoder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ use rustc_span::def_id::LOCAL_CRATE;
|
|||
|
||||
pub mod erase;
|
||||
mod keys;
|
||||
pub mod on_disk_cache;
|
||||
pub use keys::{AsLocalKey, Key, LocalCrate};
|
||||
|
||||
// Each of these queries corresponds to a function pointer field in the
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
use crate::QueryCtxt;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxIndexSet};
|
||||
use rustc_data_structures::memmap::Mmap;
|
||||
use rustc_data_structures::stable_hasher::Hash64;
|
||||
|
@ -13,8 +12,7 @@ use rustc_middle::mir::interpret::{AllocDecodingSession, AllocDecodingState};
|
|||
use rustc_middle::mir::{self, interpret};
|
||||
use rustc_middle::ty::codec::{RefDecodable, TyDecoder, TyEncoder};
|
||||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
||||
use rustc_query_system::dep_graph::DepContext;
|
||||
use rustc_query_system::query::{QueryCache, QuerySideEffects};
|
||||
use rustc_query_system::query::QuerySideEffects;
|
||||
use rustc_serialize::{
|
||||
opaque::{FileEncodeResult, FileEncoder, IntEncodedWithFixedSize, MemDecoder},
|
||||
Decodable, Decoder, Encodable, Encoder,
|
||||
|
@ -123,7 +121,7 @@ struct SourceFileIndex(u32);
|
|||
pub struct AbsoluteBytePos(u64);
|
||||
|
||||
impl AbsoluteBytePos {
|
||||
fn new(pos: usize) -> AbsoluteBytePos {
|
||||
pub fn new(pos: usize) -> AbsoluteBytePos {
|
||||
AbsoluteBytePos(pos.try_into().expect("Incremental cache file size overflowed u64."))
|
||||
}
|
||||
|
||||
|
@ -158,9 +156,9 @@ impl EncodedSourceFileId {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'sess> rustc_middle::ty::OnDiskCache<'sess> for OnDiskCache<'sess> {
|
||||
impl<'sess> OnDiskCache<'sess> {
|
||||
/// Creates a new `OnDiskCache` instance from the serialized data in `data`.
|
||||
fn new(sess: &'sess Session, data: Mmap, start_pos: usize) -> Self {
|
||||
pub fn new(sess: &'sess Session, data: Mmap, start_pos: usize) -> Self {
|
||||
debug_assert!(sess.opts.incremental.is_some());
|
||||
|
||||
// Wrap in a scope so we can borrow `data`.
|
||||
|
@ -193,7 +191,7 @@ impl<'sess> rustc_middle::ty::OnDiskCache<'sess> for OnDiskCache<'sess> {
|
|||
}
|
||||
}
|
||||
|
||||
fn new_empty(source_map: &'sess SourceMap) -> Self {
|
||||
pub fn new_empty(source_map: &'sess SourceMap) -> Self {
|
||||
Self {
|
||||
serialized_data: RwLock::new(None),
|
||||
file_index_to_stable_id: Default::default(),
|
||||
|
@ -215,7 +213,7 @@ impl<'sess> rustc_middle::ty::OnDiskCache<'sess> for OnDiskCache<'sess> {
|
|||
/// Cache promotions require invoking queries, which needs to read the serialized data.
|
||||
/// In order to serialize the new on-disk cache, the former on-disk cache file needs to be
|
||||
/// deleted, hence we won't be able to refer to its memmapped data.
|
||||
fn drop_serialized_data(&self, tcx: TyCtxt<'_>) {
|
||||
pub fn drop_serialized_data(&self, tcx: TyCtxt<'_>) {
|
||||
// Load everything into memory so we can write it out to the on-disk
|
||||
// cache. The vast majority of cacheable query results should already
|
||||
// be in memory, so this should be a cheap operation.
|
||||
|
@ -227,7 +225,7 @@ impl<'sess> rustc_middle::ty::OnDiskCache<'sess> for OnDiskCache<'sess> {
|
|||
*self.serialized_data.write() = None;
|
||||
}
|
||||
|
||||
fn serialize(&self, tcx: TyCtxt<'_>, encoder: FileEncoder) -> FileEncodeResult {
|
||||
pub fn serialize(&self, tcx: TyCtxt<'_>, encoder: FileEncoder) -> FileEncodeResult {
|
||||
// Serializing the `DepGraph` should not modify it.
|
||||
tcx.dep_graph.with_ignore(|| {
|
||||
// Allocate `SourceFileIndex`es.
|
||||
|
@ -269,7 +267,7 @@ impl<'sess> rustc_middle::ty::OnDiskCache<'sess> for OnDiskCache<'sess> {
|
|||
tcx.sess.time("encode_query_results", || {
|
||||
let enc = &mut encoder;
|
||||
let qri = &mut query_result_index;
|
||||
QueryCtxt::from_tcx(tcx).encode_query_results(enc, qri);
|
||||
(tcx.query_system.fns.encode_query_results)(tcx, enc, qri);
|
||||
});
|
||||
|
||||
// Encode side effects.
|
||||
|
@ -358,12 +356,6 @@ impl<'sess> rustc_middle::ty::OnDiskCache<'sess> for OnDiskCache<'sess> {
|
|||
encoder.finish()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl<'sess> OnDiskCache<'sess> {
|
||||
pub fn as_dyn(&self) -> &dyn rustc_middle::ty::OnDiskCache<'sess> {
|
||||
self as _
|
||||
}
|
||||
|
||||
/// Loads a `QuerySideEffects` created during the previous compilation session.
|
||||
pub fn load_side_effects(
|
||||
|
@ -855,7 +847,7 @@ impl<'a, 'tcx> CacheEncoder<'a, 'tcx> {
|
|||
/// encode the specified tag, then the given value, then the number of
|
||||
/// bytes taken up by tag and value. On decoding, we can then verify that
|
||||
/// we get the expected tag and read the expected number of bytes.
|
||||
fn encode_tagged<T: Encodable<Self>, V: Encodable<Self>>(&mut self, tag: T, value: &V) {
|
||||
pub fn encode_tagged<T: Encodable<Self>, V: Encodable<Self>>(&mut self, tag: T, value: &V) {
|
||||
let start_pos = self.position();
|
||||
|
||||
tag.encode(self);
|
||||
|
@ -1032,33 +1024,3 @@ impl<'a, 'tcx> Encodable<CacheEncoder<'a, 'tcx>> for [u8] {
|
|||
self.encode(&mut e.encoder);
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn encode_query_results<'a, 'tcx, Q>(
|
||||
query: Q,
|
||||
qcx: QueryCtxt<'tcx>,
|
||||
encoder: &mut CacheEncoder<'a, 'tcx>,
|
||||
query_result_index: &mut EncodedDepNodeIndex,
|
||||
) where
|
||||
Q: super::QueryConfigRestored<'tcx>,
|
||||
Q::RestoredValue: Encodable<CacheEncoder<'a, 'tcx>>,
|
||||
{
|
||||
let _timer = qcx
|
||||
.tcx
|
||||
.profiler()
|
||||
.verbose_generic_activity_with_arg("encode_query_results_for", query.name());
|
||||
|
||||
assert!(query.query_state(qcx).all_inactive());
|
||||
let cache = query.query_cache(qcx);
|
||||
cache.iter(&mut |key, value, dep_node| {
|
||||
if query.cache_on_disk(qcx.tcx, &key) {
|
||||
let dep_node = SerializedDepNodeIndex::new(dep_node.index());
|
||||
|
||||
// Record position of the cache entry.
|
||||
query_result_index.push((dep_node, AbsoluteBytePos::new(encoder.encoder.position())));
|
||||
|
||||
// Encode the type check tables with the `SerializedDepNodeIndex`
|
||||
// as tag.
|
||||
encoder.encode_tagged(dep_node, &Q::restore(*value));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -500,7 +500,6 @@ impl_arena_copy_decoder! {<'tcx>
|
|||
macro_rules! implement_ty_decoder {
|
||||
($DecoderName:ident <$($typaram:tt),*>) => {
|
||||
mod __ty_decoder_impl {
|
||||
use std::borrow::Cow;
|
||||
use rustc_serialize::Decoder;
|
||||
|
||||
use super::$DecoderName;
|
||||
|
|
|
@ -14,11 +14,14 @@ use crate::middle::resolve_bound_vars;
|
|||
use crate::middle::stability;
|
||||
use crate::mir::interpret::{self, Allocation, ConstAllocation};
|
||||
use crate::mir::{Body, Local, Place, PlaceElem, ProjectionKind, Promoted};
|
||||
use crate::query::on_disk_cache::OnDiskCache;
|
||||
use crate::query::LocalCrate;
|
||||
use crate::thir::Thir;
|
||||
use crate::traits;
|
||||
use crate::traits::solve;
|
||||
use crate::traits::solve::{ExternalConstraints, ExternalConstraintsData};
|
||||
use crate::ty::query::QuerySystem;
|
||||
use crate::ty::query::QuerySystemFns;
|
||||
use crate::ty::query::{self, TyCtxtAt};
|
||||
use crate::ty::{
|
||||
self, AdtDef, AdtDefData, AdtKind, Binder, Const, ConstData, FloatTy, FloatVar, FloatVid,
|
||||
|
@ -31,7 +34,6 @@ use rustc_ast::{self as ast, attr};
|
|||
use rustc_data_structures::fingerprint::Fingerprint;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_data_structures::intern::Interned;
|
||||
use rustc_data_structures::memmap::Mmap;
|
||||
use rustc_data_structures::profiling::SelfProfilerRef;
|
||||
use rustc_data_structures::sharded::{IntoPointer, ShardedHashMap};
|
||||
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
||||
|
@ -61,7 +63,6 @@ use rustc_session::lint::Lint;
|
|||
use rustc_session::Limit;
|
||||
use rustc_session::Session;
|
||||
use rustc_span::def_id::{DefPathHash, StableCrateId};
|
||||
use rustc_span::source_map::SourceMap;
|
||||
use rustc_span::symbol::{kw, sym, Ident, Symbol};
|
||||
use rustc_span::{Span, DUMMY_SP};
|
||||
use rustc_target::abi::{FieldIdx, Layout, LayoutS, TargetDataLayout, VariantIdx};
|
||||
|
@ -84,21 +85,6 @@ use super::query::IntoQueryParam;
|
|||
|
||||
const TINY_CONST_EVAL_LIMIT: Limit = Limit(20);
|
||||
|
||||
pub trait OnDiskCache<'tcx>: rustc_data_structures::sync::Sync {
|
||||
/// Creates a new `OnDiskCache` instance from the serialized data in `data`.
|
||||
fn new(sess: &'tcx Session, data: Mmap, start_pos: usize) -> Self
|
||||
where
|
||||
Self: Sized;
|
||||
|
||||
fn new_empty(source_map: &'tcx SourceMap) -> Self
|
||||
where
|
||||
Self: Sized;
|
||||
|
||||
fn drop_serialized_data(&self, tcx: TyCtxt<'tcx>);
|
||||
|
||||
fn serialize(&self, tcx: TyCtxt<'tcx>, encoder: FileEncoder) -> FileEncodeResult;
|
||||
}
|
||||
|
||||
#[allow(rustc::usage_of_ty_tykind)]
|
||||
impl<'tcx> Interner for TyCtxt<'tcx> {
|
||||
type AdtDef = ty::AdtDef<'tcx>;
|
||||
|
@ -527,13 +513,6 @@ pub struct GlobalCtxt<'tcx> {
|
|||
|
||||
untracked: Untracked,
|
||||
|
||||
/// This provides access to the incremental compilation on-disk cache for query results.
|
||||
/// Do not access this directly. It is only meant to be used by
|
||||
/// `DepGraph::try_mark_green()` and the query infrastructure.
|
||||
/// This is `None` if we are not incremental compilation mode
|
||||
pub on_disk_cache: Option<&'tcx dyn OnDiskCache<'tcx>>,
|
||||
|
||||
pub queries: &'tcx dyn query::QueryEngine<'tcx>,
|
||||
pub query_system: query::QuerySystem<'tcx>,
|
||||
pub(crate) query_kinds: &'tcx [DepKindStruct<'tcx>],
|
||||
|
||||
|
@ -674,9 +653,9 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
hir_arena: &'tcx WorkerLocal<hir::Arena<'tcx>>,
|
||||
untracked: Untracked,
|
||||
dep_graph: DepGraph,
|
||||
on_disk_cache: Option<&'tcx dyn OnDiskCache<'tcx>>,
|
||||
queries: &'tcx dyn query::QueryEngine<'tcx>,
|
||||
on_disk_cache: Option<OnDiskCache<'tcx>>,
|
||||
query_kinds: &'tcx [DepKindStruct<'tcx>],
|
||||
query_system_fns: QuerySystemFns<'tcx>,
|
||||
) -> GlobalCtxt<'tcx> {
|
||||
let data_layout = s.target.parse_data_layout().unwrap_or_else(|err| {
|
||||
s.emit_fatal(err);
|
||||
|
@ -698,9 +677,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
lifetimes: common_lifetimes,
|
||||
consts: common_consts,
|
||||
untracked,
|
||||
on_disk_cache,
|
||||
queries,
|
||||
query_system: Default::default(),
|
||||
query_system: QuerySystem::new(query_system_fns, on_disk_cache),
|
||||
query_kinds,
|
||||
ty_rcache: Default::default(),
|
||||
pred_rcache: Default::default(),
|
||||
|
@ -1039,7 +1016,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
}
|
||||
|
||||
pub fn serialize_query_result_cache(self, encoder: FileEncoder) -> FileEncodeResult {
|
||||
self.on_disk_cache.as_ref().map_or(Ok(0), |c| c.serialize(self, encoder))
|
||||
self.query_system.on_disk_cache.as_ref().map_or(Ok(0), |c| c.serialize(self, encoder))
|
||||
}
|
||||
|
||||
/// If `true`, we should use lazy normalization for constants, otherwise
|
||||
|
|
|
@ -84,8 +84,7 @@ pub use self::consts::{
|
|||
Const, ConstData, ConstInt, ConstKind, Expr, InferConst, ScalarInt, UnevaluatedConst, ValTree,
|
||||
};
|
||||
pub use self::context::{
|
||||
tls, CtxtInterners, DeducedParamAttrs, FreeRegionInfo, GlobalCtxt, Lift, OnDiskCache, TyCtxt,
|
||||
TyCtxtFeed,
|
||||
tls, CtxtInterners, DeducedParamAttrs, FreeRegionInfo, GlobalCtxt, Lift, TyCtxt, TyCtxtFeed,
|
||||
};
|
||||
pub use self::instance::{Instance, InstanceDef, ShortInstance, UnusedGenericParams};
|
||||
pub use self::list::List;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#![allow(unused_parens)]
|
||||
|
||||
use crate::dep_graph;
|
||||
use crate::dep_graph::DepKind;
|
||||
use crate::infer::canonical::{self, Canonical};
|
||||
use crate::lint::LintExpectation;
|
||||
use crate::metadata::ModChild;
|
||||
|
@ -17,7 +18,11 @@ use crate::mir::interpret::{
|
|||
};
|
||||
use crate::mir::interpret::{LitToConstError, LitToConstInput};
|
||||
use crate::mir::mono::CodegenUnit;
|
||||
|
||||
use crate::query::erase::{erase, restore, Erase};
|
||||
use crate::query::on_disk_cache::CacheEncoder;
|
||||
use crate::query::on_disk_cache::EncodedDepNodeIndex;
|
||||
use crate::query::on_disk_cache::OnDiskCache;
|
||||
use crate::query::{AsLocalKey, Key};
|
||||
use crate::thir;
|
||||
use crate::traits::query::{
|
||||
|
@ -38,13 +43,16 @@ use crate::ty::subst::{GenericArg, SubstsRef};
|
|||
use crate::ty::util::AlwaysRequiresDrop;
|
||||
use crate::ty::GeneratorDiagnosticData;
|
||||
use crate::ty::{self, CrateInherentImpls, ParamEnvAnd, Ty, TyCtxt, UnusedGenericParams};
|
||||
use measureme::StringId;
|
||||
use rustc_arena::TypedArena;
|
||||
use rustc_ast as ast;
|
||||
use rustc_ast::expand::allocator::AllocatorKind;
|
||||
use rustc_attr as attr;
|
||||
use rustc_data_structures::fingerprint::Fingerprint;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxIndexMap, FxIndexSet};
|
||||
use rustc_data_structures::steal::Steal;
|
||||
use rustc_data_structures::svh::Svh;
|
||||
use rustc_data_structures::sync::AtomicU64;
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use rustc_data_structures::sync::WorkerLocal;
|
||||
use rustc_data_structures::unord::UnordSet;
|
||||
|
@ -58,6 +66,7 @@ use rustc_hir::hir_id::OwnerId;
|
|||
use rustc_hir::lang_items::{LangItem, LanguageItems};
|
||||
use rustc_hir::{Crate, ItemLocalId, TraitCandidate};
|
||||
use rustc_index::IndexVec;
|
||||
use rustc_query_system::ich::StableHashingContext;
|
||||
pub(crate) use rustc_query_system::query::QueryJobId;
|
||||
use rustc_query_system::query::*;
|
||||
use rustc_session::config::{EntryFnType, OptLevel, OutputFilenames, SymbolManglingVersion};
|
||||
|
@ -76,17 +85,70 @@ use std::ops::Deref;
|
|||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
|
||||
use rustc_data_structures::fingerprint::Fingerprint;
|
||||
use rustc_query_system::ich::StableHashingContext;
|
||||
pub struct QueryKeyStringCache {
|
||||
pub def_id_cache: FxHashMap<DefId, StringId>,
|
||||
}
|
||||
|
||||
impl QueryKeyStringCache {
|
||||
pub fn new() -> QueryKeyStringCache {
|
||||
QueryKeyStringCache { def_id_cache: Default::default() }
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct QueryStruct<'tcx> {
|
||||
pub try_collect_active_jobs: fn(TyCtxt<'tcx>, &mut QueryMap<DepKind>) -> Option<()>,
|
||||
pub alloc_self_profile_query_strings: fn(TyCtxt<'tcx>, &mut QueryKeyStringCache),
|
||||
pub encode_query_results:
|
||||
Option<fn(TyCtxt<'tcx>, &mut CacheEncoder<'_, 'tcx>, &mut EncodedDepNodeIndex)>,
|
||||
}
|
||||
|
||||
pub struct QuerySystemFns<'tcx> {
|
||||
pub engine: QueryEngine,
|
||||
pub local_providers: Providers,
|
||||
pub extern_providers: ExternProviders,
|
||||
pub query_structs: Vec<QueryStruct<'tcx>>,
|
||||
pub encode_query_results: fn(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
encoder: &mut CacheEncoder<'_, 'tcx>,
|
||||
query_result_index: &mut EncodedDepNodeIndex,
|
||||
),
|
||||
pub try_mark_green: fn(tcx: TyCtxt<'tcx>, dep_node: &dep_graph::DepNode) -> bool,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct QuerySystem<'tcx> {
|
||||
pub states: QueryStates<'tcx>,
|
||||
pub arenas: QueryArenas<'tcx>,
|
||||
pub caches: QueryCaches<'tcx>,
|
||||
|
||||
/// This provides access to the incremental compilation on-disk cache for query results.
|
||||
/// Do not access this directly. It is only meant to be used by
|
||||
/// `DepGraph::try_mark_green()` and the query infrastructure.
|
||||
/// This is `None` if we are not incremental compilation mode
|
||||
pub on_disk_cache: Option<OnDiskCache<'tcx>>,
|
||||
|
||||
pub fns: QuerySystemFns<'tcx>,
|
||||
|
||||
pub jobs: AtomicU64,
|
||||
|
||||
// Since we erase query value types we tell the typesystem about them with `PhantomData`.
|
||||
_phantom_values: QueryPhantomValues<'tcx>,
|
||||
}
|
||||
|
||||
impl<'tcx> QuerySystem<'tcx> {
|
||||
pub fn new(fns: QuerySystemFns<'tcx>, on_disk_cache: Option<OnDiskCache<'tcx>>) -> Self {
|
||||
QuerySystem {
|
||||
states: Default::default(),
|
||||
arenas: Default::default(),
|
||||
caches: Default::default(),
|
||||
on_disk_cache,
|
||||
fns,
|
||||
jobs: AtomicU64::new(1),
|
||||
_phantom_values: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct TyCtxtAt<'tcx> {
|
||||
pub tcx: TyCtxt<'tcx>,
|
||||
|
@ -136,7 +198,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
}
|
||||
|
||||
pub fn try_mark_green(self, dep_node: &dep_graph::DepNode) -> bool {
|
||||
self.queries.try_mark_green(self, dep_node)
|
||||
(self.query_system.fns.try_mark_green)(self, dep_node)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -349,7 +411,7 @@ macro_rules! define_callbacks {
|
|||
|
||||
match try_get_cached(self.tcx, &self.tcx.query_system.caches.$name, &key) {
|
||||
Some(_) => return,
|
||||
None => self.tcx.queries.$name(
|
||||
None => (self.tcx.query_system.fns.engine.$name)(
|
||||
self.tcx,
|
||||
DUMMY_SP,
|
||||
key,
|
||||
|
@ -367,7 +429,7 @@ macro_rules! define_callbacks {
|
|||
|
||||
match try_get_cached(self.tcx, &self.tcx.query_system.caches.$name, &key) {
|
||||
Some(_) => return,
|
||||
None => self.tcx.queries.$name(
|
||||
None => (self.tcx.query_system.fns.engine.$name)(
|
||||
self.tcx,
|
||||
DUMMY_SP,
|
||||
key,
|
||||
|
@ -396,11 +458,22 @@ macro_rules! define_callbacks {
|
|||
|
||||
restore::<$V>(match try_get_cached(self.tcx, &self.tcx.query_system.caches.$name, &key) {
|
||||
Some(value) => value,
|
||||
None => self.tcx.queries.$name(self.tcx, self.span, key, QueryMode::Get).unwrap(),
|
||||
None => (self.tcx.query_system.fns.engine.$name)(
|
||||
self.tcx,
|
||||
self.span,
|
||||
key, QueryMode::Get
|
||||
).unwrap(),
|
||||
})
|
||||
})*
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct QueryStates<'tcx> {
|
||||
$(
|
||||
pub $name: QueryState<$($K)*, DepKind>,
|
||||
)*
|
||||
}
|
||||
|
||||
pub struct Providers {
|
||||
$(pub $name: for<'tcx> fn(
|
||||
TyCtxt<'tcx>,
|
||||
|
@ -446,19 +519,13 @@ macro_rules! define_callbacks {
|
|||
fn clone(&self) -> Self { *self }
|
||||
}
|
||||
|
||||
pub trait QueryEngine<'tcx>: rustc_data_structures::sync::Sync {
|
||||
fn as_any(&'tcx self) -> &'tcx dyn std::any::Any;
|
||||
|
||||
fn try_mark_green(&'tcx self, tcx: TyCtxt<'tcx>, dep_node: &dep_graph::DepNode) -> bool;
|
||||
|
||||
$($(#[$attr])*
|
||||
fn $name(
|
||||
&'tcx self,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
span: Span,
|
||||
key: query_keys::$name<'tcx>,
|
||||
mode: QueryMode,
|
||||
) -> Option<Erase<$V>>;)*
|
||||
pub struct QueryEngine {
|
||||
$(pub $name: for<'tcx> fn(
|
||||
TyCtxt<'tcx>,
|
||||
Span,
|
||||
query_keys::$name<'tcx>,
|
||||
QueryMode,
|
||||
) -> Option<Erase<$V>>,)*
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue