diff --git a/compiler/rustc_middle/src/dep_graph/dep_node.rs b/compiler/rustc_middle/src/dep_graph/dep_node.rs index a5f632f25164..848c8b8ea9cb 100644 --- a/compiler/rustc_middle/src/dep_graph/dep_node.rs +++ b/compiler/rustc_middle/src/dep_graph/dep_node.rs @@ -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 { @@ -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 { ($( @@ -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, } };)* ); @@ -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 { diff --git a/compiler/rustc_middle/src/dep_graph/mod.rs b/compiler/rustc_middle/src/dep_graph/mod.rs index b1ee279d6667..b81b5b3ede10 100644 --- a/compiler/rustc_middle/src/dep_graph/mod.rs +++ b/compiler/rustc_middle/src/dep_graph/mod.rs @@ -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 {