@@ -75,7 +75,12 @@ pub use rustc_query_system::dep_graph::{DepContext, DepNodeParams};
75
75
/// Information is retrieved by indexing the `DEP_KINDS` array using the integer value
76
76
/// of the `DepKind`. Overall, this allows to implement `DepContext` using this manual
77
77
/// 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
+ }
79
84
80
85
impl std:: ops:: Deref for DepKind {
81
86
type Target = DepKindStruct ;
@@ -122,22 +127,25 @@ pub mod dep_kind {
122
127
use super :: * ;
123
128
124
129
// 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 } ;
126
131
127
132
// Represents metadata from an extern crate.
128
- pub const CrateMetadata : DepKindStruct = DepKindStruct { } ;
133
+ pub const CrateMetadata : DepKindStruct = DepKindStruct { is_anon : false } ;
129
134
130
- pub const TraitSelect : DepKindStruct = DepKindStruct { } ;
135
+ pub const TraitSelect : DepKindStruct = DepKindStruct { is_anon : true } ;
131
136
132
- pub const CompileCodegenUnit : DepKindStruct = DepKindStruct { } ;
137
+ pub const CompileCodegenUnit : DepKindStruct = DepKindStruct { is_anon : false } ;
133
138
134
139
macro_rules! define_query_dep_kinds {
135
140
( $(
136
141
[ $( $attrs: tt) * ]
137
142
$variant: ident $( ( $tuple_arg_ty: ty $( , ) ? ) ) *
138
143
, ) * ) => (
139
144
$( pub const $variant: DepKindStruct = {
145
+ const is_anon: bool = contains_anon_attr!( $( $attrs) * ) ;
146
+
140
147
DepKindStruct {
148
+ is_anon,
141
149
}
142
150
} ; ) *
143
151
) ;
@@ -165,13 +173,13 @@ macro_rules! define_dep_nodes {
165
173
impl DepKind {
166
174
#[ allow( unreachable_code) ]
167
175
pub fn can_reconstruct_query_key<$tcx>( & self ) -> bool {
176
+ if self . is_anon {
177
+ return false ;
178
+ }
179
+
168
180
match * self {
169
181
$(
170
182
DepKind :: $variant => {
171
- if contains_anon_attr!( $( $attrs) * ) {
172
- return false ;
173
- }
174
-
175
183
// tuple args
176
184
$( {
177
185
return <$tuple_arg_ty as DepNodeParams <TyCtxt <' _>>>
@@ -184,14 +192,6 @@ macro_rules! define_dep_nodes {
184
192
}
185
193
}
186
194
187
- pub fn is_anon( & self ) -> bool {
188
- match * self {
189
- $(
190
- DepKind :: $variant => { contains_anon_attr!( $( $attrs) * ) }
191
- ) *
192
- }
193
- }
194
-
195
195
pub fn is_eval_always( & self ) -> bool {
196
196
match * self {
197
197
$(
0 commit comments