Skip to content

Commit

Permalink
Use a field for is_anon.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjgillot committed Jan 8, 2021
1 parent 016ea6b commit 24f0b95
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
34 changes: 17 additions & 17 deletions compiler/rustc_middle/src/dep_graph/dep_node.rs
Expand Up @@ -75,7 +75,12 @@ pub use rustc_query_system::dep_graph::{DepContext, DepNodeParams};
/// Information is retrieved by indexing the `DEP_KINDS` array using the integer value
/// of the `DepKind`. Overall, this allows to implement `DepContext` using this manual
/// jump table instead of large matches.
pub struct DepKindStruct {}
pub struct DepKindStruct {
/// Anonymous queries cannot be replayed from one compiler invocation to the next.
/// When their result is needed, it is recomputed. They are useful for fine-grained
/// dependency tracking, and caching within one compiler invocation.
pub(super) is_anon: bool,
}

impl std::ops::Deref for DepKind {
type Target = DepKindStruct;
Expand Down Expand Up @@ -122,22 +127,25 @@ pub mod dep_kind {
use super::*;

// We use this for most things when incr. comp. is turned off.
pub const Null: DepKindStruct = DepKindStruct {};
pub const Null: DepKindStruct = DepKindStruct { is_anon: false };

// Represents metadata from an extern crate.
pub const CrateMetadata: DepKindStruct = DepKindStruct {};
pub const CrateMetadata: DepKindStruct = DepKindStruct { is_anon: false };

pub const TraitSelect: DepKindStruct = DepKindStruct {};
pub const TraitSelect: DepKindStruct = DepKindStruct { is_anon: true };

pub const CompileCodegenUnit: DepKindStruct = DepKindStruct {};
pub const CompileCodegenUnit: DepKindStruct = DepKindStruct { is_anon: false };

macro_rules! define_query_dep_kinds {
($(
[$($attrs:tt)*]
$variant:ident $(( $tuple_arg_ty:ty $(,)? ))*
,)*) => (
$(pub const $variant: DepKindStruct = {
const is_anon: bool = contains_anon_attr!($($attrs)*);

DepKindStruct {
is_anon,
}
};)*
);
Expand Down Expand Up @@ -165,13 +173,13 @@ macro_rules! define_dep_nodes {
impl DepKind {
#[allow(unreachable_code)]
pub fn can_reconstruct_query_key<$tcx>(&self) -> bool {
if self.is_anon {
return false;
}

match *self {
$(
DepKind :: $variant => {
if contains_anon_attr!($($attrs)*) {
return false;
}

// tuple args
$({
return <$tuple_arg_ty as DepNodeParams<TyCtxt<'_>>>
Expand All @@ -184,14 +192,6 @@ macro_rules! define_dep_nodes {
}
}

pub fn is_anon(&self) -> bool {
match *self {
$(
DepKind :: $variant => { contains_anon_attr!($($attrs)*) }
)*
}
}

pub fn is_eval_always(&self) -> bool {
match *self {
$(
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/dep_graph/mod.rs
Expand Up @@ -37,7 +37,7 @@ impl rustc_query_system::dep_graph::DepKind for DepKind {
fn debug_node(node: &DepNode, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}", node.kind)?;

if !node.kind.has_params() && !node.kind.is_anon() {
if !node.kind.has_params() && !node.kind.is_anon {
return Ok(());
}

Expand Down

0 comments on commit 24f0b95

Please sign in to comment.