Skip to content

Commit 319d1b2

Browse files
committed
XXX: QueryDispatcherUnerased
1 parent 503f908 commit 319d1b2

2 files changed

Lines changed: 22 additions & 23 deletions

File tree

compiler/rustc_query_impl/src/lib.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -208,17 +208,15 @@ impl<'tcx, C: QueryCache, const FLAGS: QueryFlags> QueryDispatcher<'tcx>
208208
///
209209
/// There is one macro-generated implementation of this trait for each query,
210210
/// on the type `rustc_query_impl::query_impl::$name::QueryType`.
211-
trait QueryDispatcherUnerased<'tcx> {
211+
trait QueryDispatcherUnerased<'tcx, C: QueryCache, const FLAGS: QueryFlags> {
212212
type UnerasedValue;
213-
type Dispatcher: QueryDispatcher<'tcx, Qcx = QueryCtxt<'tcx>>;
213+
//type Dispatcher: QueryDispatcher<'tcx, Qcx = QueryCtxt<'tcx>>;
214214

215215
const NAME: &'static &'static str;
216216

217-
fn query_dispatcher(tcx: TyCtxt<'tcx>) -> Self::Dispatcher;
217+
fn query_dispatcher(tcx: TyCtxt<'tcx>) -> SemiDynamicQueryDispatcher<'tcx, C, FLAGS>;
218218

219-
fn restore_val(
220-
value: <Self::Dispatcher as QueryDispatcher<'tcx>>::Value,
221-
) -> Self::UnerasedValue;
219+
fn restore_val(value: C::Value) -> Self::UnerasedValue;
222220
}
223221

224222
pub fn query_system<'tcx>(

compiler/rustc_query_impl/src/plumbing.rs

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ use rustc_serialize::{Decodable, Encodable};
4343
use rustc_span::def_id::LOCAL_CRATE;
4444
use rustc_span::{DUMMY_SP, Span};
4545

46-
use crate::QueryDispatcherUnerased;
46+
use crate::{QueryDispatcherUnerased, QueryFlags, SemiDynamicQueryDispatcher};
4747
use crate::error::{QueryOverflow, QueryOverflowNote};
4848

4949
/// Implements [`QueryContext`] for use by [`rustc_query_system`], since that
@@ -385,13 +385,13 @@ where
385385
QueryStackFrame::new(info, kind, hash, def_id, def_id_for_ty_in_cycle)
386386
}
387387

388-
pub(crate) fn encode_query_results<'a, 'tcx, Q>(
389-
query: Q::Dispatcher,
388+
pub(crate) fn encode_query_results<'a, 'tcx, Q, C: QueryCache, const FLAGS: QueryFlags>(
389+
query: SemiDynamicQueryDispatcher<'tcx, C, FLAGS>,
390390
qcx: QueryCtxt<'tcx>,
391391
encoder: &mut CacheEncoder<'a, 'tcx>,
392392
query_result_index: &mut EncodedDepNodeIndex,
393393
) where
394-
Q: QueryDispatcherUnerased<'tcx>,
394+
Q: QueryDispatcherUnerased<'tcx, C, FLAGS>,
395395
Q::UnerasedValue: Encodable<CacheEncoder<'a, 'tcx>>,
396396
{
397397
let _timer = qcx.tcx.prof.generic_activity_with_arg("encode_query_results_for", query.name());
@@ -518,17 +518,17 @@ where
518518
}
519519
}
520520

521-
pub(crate) fn make_dep_kind_vtable_for_query<'tcx, Q>(
521+
pub(crate) fn make_dep_kind_vtable_for_query<'tcx, Q, C: QueryCache + 'tcx, const FLAGS: QueryFlags>(
522522
is_anon: bool,
523523
is_eval_always: bool,
524524
) -> DepKindVTable<'tcx>
525525
where
526-
Q: QueryDispatcherUnerased<'tcx>,
526+
Q: QueryDispatcherUnerased<'tcx, C, FLAGS>,
527527
{
528528
let fingerprint_style = if is_anon {
529529
FingerprintStyle::Opaque
530530
} else {
531-
<Q::Dispatcher as QueryDispatcher>::Key::fingerprint_style()
531+
<C::Key as DepNodeKey<TyCtxt<'tcx>>>::fingerprint_style()
532532
};
533533

534534
if is_anon || !fingerprint_style.reconstructible() {
@@ -725,25 +725,26 @@ macro_rules! define_queries {
725725
is_feedable: feedable!([$($modifiers)*]),
726726
};
727727

728-
impl<'tcx> QueryDispatcherUnerased<'tcx> for QueryType<'tcx> {
728+
impl<'tcx> QueryDispatcherUnerased<'tcx, queries::$name::Storage<'tcx>, FLAGS>
729+
for QueryType<'tcx>
730+
{
729731
type UnerasedValue = queries::$name::Value<'tcx>;
730-
type Dispatcher = SemiDynamicQueryDispatcher<
731-
'tcx,
732-
queries::$name::Storage<'tcx>,
733-
FLAGS,
734-
>;
735732

736733
const NAME: &'static &'static str = &stringify!($name);
737734

738735
#[inline(always)]
739-
fn query_dispatcher(tcx: TyCtxt<'tcx>) -> Self::Dispatcher {
736+
fn query_dispatcher(tcx: TyCtxt<'tcx>) -> SemiDynamicQueryDispatcher<'tcx,
737+
queries::$name::Storage<'tcx>,
738+
FLAGS> {
740739
SemiDynamicQueryDispatcher {
741740
vtable: &tcx.query_system.query_vtables.$name,
742741
}
743742
}
744743

745744
#[inline(always)]
746-
fn restore_val(value: <Self::Dispatcher as QueryDispatcher<'tcx>>::Value) -> Self::UnerasedValue {
745+
fn restore_val(value: <queries::$name::Storage<'tcx> as QueryCache>::Value)
746+
-> Self::UnerasedValue
747+
{
747748
erase::restore_val::<queries::$name::Value<'tcx>>(value)
748749
}
749750
}
@@ -799,7 +800,7 @@ macro_rules! define_queries {
799800
encoder: &mut CacheEncoder<'_, 'tcx>,
800801
query_result_index: &mut EncodedDepNodeIndex
801802
) {
802-
$crate::plumbing::encode_query_results::<query_impl::$name::QueryType<'tcx>>(
803+
$crate::plumbing::encode_query_results::<query_impl::$name::QueryType<'tcx>, _, _>(
803804
query_impl::$name::QueryType::query_dispatcher(tcx),
804805
QueryCtxt::new(tcx),
805806
encoder,
@@ -971,7 +972,7 @@ macro_rules! define_queries {
971972

972973
$(pub(crate) fn $name<'tcx>() -> DepKindVTable<'tcx> {
973974
use $crate::query_impl::$name::QueryType;
974-
$crate::plumbing::make_dep_kind_vtable_for_query::<QueryType<'tcx>>(
975+
$crate::plumbing::make_dep_kind_vtable_for_query::<QueryType<'tcx>, _, _>(
975976
is_anon!([$($modifiers)*]),
976977
is_eval_always!([$($modifiers)*]),
977978
)

0 commit comments

Comments
 (0)