Skip to content

Commit 24f0b95

Browse files
committed
Use a field for is_anon.
1 parent 016ea6b commit 24f0b95

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

compiler/rustc_middle/src/dep_graph/dep_node.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,12 @@ pub use rustc_query_system::dep_graph::{DepContext, DepNodeParams};
7575
/// Information is retrieved by indexing the `DEP_KINDS` array using the integer value
7676
/// of the `DepKind`. Overall, this allows to implement `DepContext` using this manual
7777
/// jump table instead of large matches.
78-
pub struct DepKindStruct {}
78+
pub struct DepKindStruct {
79+
/// Anonymous queries cannot be replayed from one compiler invocation to the next.
80+
/// When their result is needed, it is recomputed. They are useful for fine-grained
81+
/// dependency tracking, and caching within one compiler invocation.
82+
pub(super) is_anon: bool,
83+
}
7984

8085
impl std::ops::Deref for DepKind {
8186
type Target = DepKindStruct;
@@ -122,22 +127,25 @@ pub mod dep_kind {
122127
use super::*;
123128

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

127132
// Represents metadata from an extern crate.
128-
pub const CrateMetadata: DepKindStruct = DepKindStruct {};
133+
pub const CrateMetadata: DepKindStruct = DepKindStruct { is_anon: false };
129134

130-
pub const TraitSelect: DepKindStruct = DepKindStruct {};
135+
pub const TraitSelect: DepKindStruct = DepKindStruct { is_anon: true };
131136

132-
pub const CompileCodegenUnit: DepKindStruct = DepKindStruct {};
137+
pub const CompileCodegenUnit: DepKindStruct = DepKindStruct { is_anon: false };
133138

134139
macro_rules! define_query_dep_kinds {
135140
($(
136141
[$($attrs:tt)*]
137142
$variant:ident $(( $tuple_arg_ty:ty $(,)? ))*
138143
,)*) => (
139144
$(pub const $variant: DepKindStruct = {
145+
const is_anon: bool = contains_anon_attr!($($attrs)*);
146+
140147
DepKindStruct {
148+
is_anon,
141149
}
142150
};)*
143151
);
@@ -165,13 +173,13 @@ macro_rules! define_dep_nodes {
165173
impl DepKind {
166174
#[allow(unreachable_code)]
167175
pub fn can_reconstruct_query_key<$tcx>(&self) -> bool {
176+
if self.is_anon {
177+
return false;
178+
}
179+
168180
match *self {
169181
$(
170182
DepKind :: $variant => {
171-
if contains_anon_attr!($($attrs)*) {
172-
return false;
173-
}
174-
175183
// tuple args
176184
$({
177185
return <$tuple_arg_ty as DepNodeParams<TyCtxt<'_>>>
@@ -184,14 +192,6 @@ macro_rules! define_dep_nodes {
184192
}
185193
}
186194

187-
pub fn is_anon(&self) -> bool {
188-
match *self {
189-
$(
190-
DepKind :: $variant => { contains_anon_attr!($($attrs)*) }
191-
)*
192-
}
193-
}
194-
195195
pub fn is_eval_always(&self) -> bool {
196196
match *self {
197197
$(

compiler/rustc_middle/src/dep_graph/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ impl rustc_query_system::dep_graph::DepKind for DepKind {
3737
fn debug_node(node: &DepNode, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3838
write!(f, "{:?}", node.kind)?;
3939

40-
if !node.kind.has_params() && !node.kind.is_anon() {
40+
if !node.kind.has_params() && !node.kind.is_anon {
4141
return Ok(());
4242
}
4343

0 commit comments

Comments
 (0)