Skip to content

Commit d8c87ac

Browse files
committed
Use a field for is_eval_always.
1 parent 24f0b95 commit d8c87ac

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

compiler/rustc_middle/src/dep_graph/dep_node.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ pub struct DepKindStruct {
8080
/// When their result is needed, it is recomputed. They are useful for fine-grained
8181
/// dependency tracking, and caching within one compiler invocation.
8282
pub(super) is_anon: bool,
83+
84+
/// Eval-always queries do not track their dependencies, and are always recomputed, even if
85+
/// their inputs have not changed since the last compiler invocation. The result is still
86+
/// cached within one compiler invocation.
87+
pub(super) is_eval_always: bool,
8388
}
8489

8590
impl std::ops::Deref for DepKind {
@@ -127,14 +132,15 @@ pub mod dep_kind {
127132
use super::*;
128133

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

132137
// Represents metadata from an extern crate.
133-
pub const CrateMetadata: DepKindStruct = DepKindStruct { is_anon: false };
138+
pub const CrateMetadata: DepKindStruct = DepKindStruct { is_anon: false, is_eval_always: true };
134139

135-
pub const TraitSelect: DepKindStruct = DepKindStruct { is_anon: true };
140+
pub const TraitSelect: DepKindStruct = DepKindStruct { is_anon: true, is_eval_always: false };
136141

137-
pub const CompileCodegenUnit: DepKindStruct = DepKindStruct { is_anon: false };
142+
pub const CompileCodegenUnit: DepKindStruct =
143+
DepKindStruct { is_anon: false, is_eval_always: false };
138144

139145
macro_rules! define_query_dep_kinds {
140146
($(
@@ -143,9 +149,11 @@ pub mod dep_kind {
143149
,)*) => (
144150
$(pub const $variant: DepKindStruct = {
145151
const is_anon: bool = contains_anon_attr!($($attrs)*);
152+
const is_eval_always: bool = contains_eval_always_attr!($($attrs)*);
146153

147154
DepKindStruct {
148155
is_anon,
156+
is_eval_always,
149157
}
150158
};)*
151159
);
@@ -192,14 +200,6 @@ macro_rules! define_dep_nodes {
192200
}
193201
}
194202

195-
pub fn is_eval_always(&self) -> bool {
196-
match *self {
197-
$(
198-
DepKind :: $variant => { contains_eval_always_attr!($($attrs)*) }
199-
)*
200-
}
201-
}
202-
203203
#[allow(unreachable_code)]
204204
pub fn has_params(&self) -> bool {
205205
match *self {

compiler/rustc_middle/src/dep_graph/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ pub type SerializedDepGraph = rustc_query_system::dep_graph::SerializedDepGraph<
2626
impl rustc_query_system::dep_graph::DepKind for DepKind {
2727
const NULL: Self = DepKind::Null;
2828

29+
#[inline(always)]
2930
fn is_eval_always(&self) -> bool {
30-
DepKind::is_eval_always(self)
31+
self.is_eval_always
3132
}
3233

3334
fn has_params(&self) -> bool {

0 commit comments

Comments
 (0)