@@ -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
8085impl 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 $(
0 commit comments