Make can_reconstruct_query_key a function pointer.
This commit is contained in:
parent
5027f1c6ea
commit
438c430c76
2 changed files with 61 additions and 35 deletions
|
@ -88,6 +88,12 @@ pub struct DepKindStruct {
|
||||||
/// their inputs have not changed since the last compiler invocation. The result is still
|
/// their inputs have not changed since the last compiler invocation. The result is still
|
||||||
/// cached within one compiler invocation.
|
/// cached within one compiler invocation.
|
||||||
pub(super) is_eval_always: bool,
|
pub(super) is_eval_always: bool,
|
||||||
|
|
||||||
|
/// Whether the query key can be recovered from the hashed fingerprint.
|
||||||
|
/// See [DepNodeParams] trait for the behaviour of each key type.
|
||||||
|
// FIXME: Make this a simple boolean once DepNodeParams::can_reconstruct_query_key
|
||||||
|
// can be made a specialized associated const.
|
||||||
|
can_reconstruct_query_key: fn() -> bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::ops::Deref for DepKind {
|
impl std::ops::Deref for DepKind {
|
||||||
|
@ -97,6 +103,19 @@ impl std::ops::Deref for DepKind {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl DepKind {
|
||||||
|
#[inline(always)]
|
||||||
|
pub fn can_reconstruct_query_key(&self) -> bool {
|
||||||
|
// Only fetch the DepKindStruct once.
|
||||||
|
let data: &DepKindStruct = &**self;
|
||||||
|
if data.is_anon {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
(data.can_reconstruct_query_key)()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// erase!() just makes tokens go away. It's used to specify which macro argument
|
// erase!() just makes tokens go away. It's used to specify which macro argument
|
||||||
// is repeated (i.e., which sub-expression of the macro we are in) but don't need
|
// is repeated (i.e., which sub-expression of the macro we are in) but don't need
|
||||||
// to actually use any of the arguments.
|
// to actually use any of the arguments.
|
||||||
|
@ -133,20 +152,41 @@ macro_rules! contains_eval_always_attr {
|
||||||
#[allow(non_upper_case_globals)]
|
#[allow(non_upper_case_globals)]
|
||||||
pub mod dep_kind {
|
pub mod dep_kind {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use crate::ty::query::query_keys;
|
||||||
|
|
||||||
// We use this for most things when incr. comp. is turned off.
|
// We use this for most things when incr. comp. is turned off.
|
||||||
pub const Null: DepKindStruct =
|
pub const Null: DepKindStruct = DepKindStruct {
|
||||||
DepKindStruct { has_params: false, is_anon: false, is_eval_always: false };
|
has_params: false,
|
||||||
|
is_anon: false,
|
||||||
|
is_eval_always: false,
|
||||||
|
|
||||||
|
can_reconstruct_query_key: || true,
|
||||||
|
};
|
||||||
|
|
||||||
// Represents metadata from an extern crate.
|
// Represents metadata from an extern crate.
|
||||||
pub const CrateMetadata: DepKindStruct =
|
pub const CrateMetadata: DepKindStruct = DepKindStruct {
|
||||||
DepKindStruct { has_params: true, is_anon: false, is_eval_always: true };
|
has_params: true,
|
||||||
|
is_anon: false,
|
||||||
|
is_eval_always: true,
|
||||||
|
|
||||||
pub const TraitSelect: DepKindStruct =
|
can_reconstruct_query_key: || true,
|
||||||
DepKindStruct { has_params: false, is_anon: true, is_eval_always: false };
|
};
|
||||||
|
|
||||||
pub const CompileCodegenUnit: DepKindStruct =
|
pub const TraitSelect: DepKindStruct = DepKindStruct {
|
||||||
DepKindStruct { has_params: true, is_anon: false, is_eval_always: false };
|
has_params: false,
|
||||||
|
is_anon: true,
|
||||||
|
is_eval_always: false,
|
||||||
|
|
||||||
|
can_reconstruct_query_key: || false,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub const CompileCodegenUnit: DepKindStruct = DepKindStruct {
|
||||||
|
has_params: true,
|
||||||
|
is_anon: false,
|
||||||
|
is_eval_always: false,
|
||||||
|
|
||||||
|
can_reconstruct_query_key: || false,
|
||||||
|
};
|
||||||
|
|
||||||
macro_rules! define_query_dep_kinds {
|
macro_rules! define_query_dep_kinds {
|
||||||
($(
|
($(
|
||||||
|
@ -158,10 +198,18 @@ pub mod dep_kind {
|
||||||
const is_anon: bool = contains_anon_attr!($($attrs)*);
|
const is_anon: bool = contains_anon_attr!($($attrs)*);
|
||||||
const is_eval_always: bool = contains_eval_always_attr!($($attrs)*);
|
const is_eval_always: bool = contains_eval_always_attr!($($attrs)*);
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
|
fn can_reconstruct_query_key() -> bool {
|
||||||
|
!is_anon &&
|
||||||
|
<query_keys::$variant<'_> as DepNodeParams<TyCtxt<'_>>>
|
||||||
|
::can_reconstruct_query_key()
|
||||||
|
}
|
||||||
|
|
||||||
DepKindStruct {
|
DepKindStruct {
|
||||||
has_params,
|
has_params,
|
||||||
is_anon,
|
is_anon,
|
||||||
is_eval_always,
|
is_eval_always,
|
||||||
|
can_reconstruct_query_key,
|
||||||
}
|
}
|
||||||
};)*
|
};)*
|
||||||
);
|
);
|
||||||
|
@ -186,29 +234,6 @@ macro_rules! define_dep_nodes {
|
||||||
$($variant),*
|
$($variant),*
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DepKind {
|
|
||||||
#[allow(unreachable_code)]
|
|
||||||
pub fn can_reconstruct_query_key<$tcx>(&self) -> bool {
|
|
||||||
if self.is_anon {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
match *self {
|
|
||||||
$(
|
|
||||||
DepKind :: $variant => {
|
|
||||||
// tuple args
|
|
||||||
$({
|
|
||||||
return <$tuple_arg_ty as DepNodeParams<TyCtxt<'_>>>
|
|
||||||
::can_reconstruct_query_key();
|
|
||||||
})*
|
|
||||||
|
|
||||||
true
|
|
||||||
}
|
|
||||||
)*
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct DepConstructor;
|
pub struct DepConstructor;
|
||||||
|
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
|
|
|
@ -26,6 +26,11 @@ pub type SerializedDepGraph = rustc_query_system::dep_graph::SerializedDepGraph<
|
||||||
impl rustc_query_system::dep_graph::DepKind for DepKind {
|
impl rustc_query_system::dep_graph::DepKind for DepKind {
|
||||||
const NULL: Self = DepKind::Null;
|
const NULL: Self = DepKind::Null;
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
|
fn can_reconstruct_query_key(&self) -> bool {
|
||||||
|
DepKind::can_reconstruct_query_key(self)
|
||||||
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn is_eval_always(&self) -> bool {
|
fn is_eval_always(&self) -> bool {
|
||||||
self.is_eval_always
|
self.is_eval_always
|
||||||
|
@ -83,10 +88,6 @@ impl rustc_query_system::dep_graph::DepKind for DepKind {
|
||||||
op(icx.task_deps)
|
op(icx.task_deps)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn can_reconstruct_query_key(&self) -> bool {
|
|
||||||
DepKind::can_reconstruct_query_key(self)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> DepContext for TyCtxt<'tcx> {
|
impl<'tcx> DepContext for TyCtxt<'tcx> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue