Skip to content

Commit

Permalink
Use a field for is_eval_always.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjgillot committed Jan 8, 2021
1 parent 24f0b95 commit d8c87ac
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
24 changes: 12 additions & 12 deletions compiler/rustc_middle/src/dep_graph/dep_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ pub struct DepKindStruct {
/// 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,

/// Eval-always queries do not track their dependencies, and are always recomputed, even if
/// their inputs have not changed since the last compiler invocation. The result is still
/// cached within one compiler invocation.
pub(super) is_eval_always: bool,
}

impl std::ops::Deref for DepKind {
Expand Down Expand Up @@ -127,14 +132,15 @@ pub mod dep_kind {
use super::*;

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

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

pub const TraitSelect: DepKindStruct = DepKindStruct { is_anon: true };
pub const TraitSelect: DepKindStruct = DepKindStruct { is_anon: true, is_eval_always: false };

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

macro_rules! define_query_dep_kinds {
($(
Expand All @@ -143,9 +149,11 @@ pub mod dep_kind {
,)*) => (
$(pub const $variant: DepKindStruct = {
const is_anon: bool = contains_anon_attr!($($attrs)*);
const is_eval_always: bool = contains_eval_always_attr!($($attrs)*);

DepKindStruct {
is_anon,
is_eval_always,
}
};)*
);
Expand Down Expand Up @@ -192,14 +200,6 @@ macro_rules! define_dep_nodes {
}
}

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

#[allow(unreachable_code)]
pub fn has_params(&self) -> bool {
match *self {
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_middle/src/dep_graph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ pub type SerializedDepGraph = rustc_query_system::dep_graph::SerializedDepGraph<
impl rustc_query_system::dep_graph::DepKind for DepKind {
const NULL: Self = DepKind::Null;

#[inline(always)]
fn is_eval_always(&self) -> bool {
DepKind::is_eval_always(self)
self.is_eval_always
}

fn has_params(&self) -> bool {
Expand Down

0 comments on commit d8c87ac

Please sign in to comment.