11use std:: panic;
22
33use rustc_data_structures:: profiling:: SelfProfilerRef ;
4- use rustc_data_structures:: sync:: DynSync ;
54use rustc_query_system:: ich:: StableHashingContext ;
65use rustc_session:: Session ;
76use tracing:: instrument;
@@ -28,8 +27,6 @@ mod query;
2827mod serialized;
2928
3029pub trait DepContext : Copy {
31- type Deps : Deps ;
32-
3330 /// Create a hashing context for hashing new results.
3431 fn with_stable_hashing_context < R > ( self , f : impl FnOnce ( StableHashingContext < ' _ > ) -> R ) -> R ;
3532
@@ -96,45 +93,13 @@ pub trait DepContext: Copy {
9693 fn with_reduced_queries < T > ( self , _: impl FnOnce ( ) -> T ) -> T ;
9794}
9895
99- pub trait Deps : DynSync {
100- /// Execute the operation with provided dependencies.
101- fn with_deps < OP , R > ( deps : TaskDepsRef < ' _ > , op : OP ) -> R
102- where
103- OP : FnOnce ( ) -> R ;
104-
105- /// Access dependencies from current implicit context.
106- fn read_deps < OP > ( op : OP )
107- where
108- OP : for < ' a > FnOnce ( TaskDepsRef < ' a > ) ;
109-
110- fn name ( dep_kind : DepKind ) -> & ' static str ;
111-
112- /// We use this for most things when incr. comp. is turned off.
113- const DEP_KIND_NULL : DepKind ;
114-
115- /// We use this to create a forever-red node.
116- const DEP_KIND_RED : DepKind ;
117-
118- /// We use this to create a side effect node.
119- const DEP_KIND_SIDE_EFFECT : DepKind ;
120-
121- /// We use this to create the anon node with zero dependencies.
122- const DEP_KIND_ANON_ZERO_DEPS : DepKind ;
123-
124- /// This is the highest value a `DepKind` can have. It's used during encoding to
125- /// pack information into the unused bits.
126- const DEP_KIND_MAX : u16 ;
127- }
128-
12996pub trait HasDepContext : Copy {
130- type Deps : self :: Deps ;
131- type DepContext : self :: DepContext < Deps = Self :: Deps > ;
97+ type DepContext : self :: DepContext ;
13298
13399 fn dep_context ( & self ) -> & Self :: DepContext ;
134100}
135101
136102impl < T : DepContext > HasDepContext for T {
137- type Deps = T :: Deps ;
138103 type DepContext = Self ;
139104
140105 fn dep_context ( & self ) -> & Self :: DepContext {
@@ -143,7 +108,6 @@ impl<T: DepContext> HasDepContext for T {
143108}
144109
145110impl < T : HasDepContext , Q : Copy > HasDepContext for ( T , Q ) {
146- type Deps = T :: Deps ;
147111 type DepContext = T :: DepContext ;
148112
149113 fn dep_context ( & self ) -> & Self :: DepContext {
@@ -183,7 +147,8 @@ pub type DepKindVTable<'tcx> = dep_node::DepKindVTable<TyCtxt<'tcx>>;
183147
184148pub struct DepsType ;
185149
186- impl Deps for DepsType {
150+ impl DepsType {
151+ /// Execute the operation with provided dependencies.
187152 fn with_deps < OP , R > ( task_deps : TaskDepsRef < ' _ > , op : OP ) -> R
188153 where
189154 OP : FnOnce ( ) -> R ,
@@ -195,6 +160,7 @@ impl Deps for DepsType {
195160 } )
196161 }
197162
163+ /// Access dependencies from current implicit context.
198164 fn read_deps < OP > ( op : OP )
199165 where
200166 OP : for < ' a > FnOnce ( TaskDepsRef < ' a > ) ,
@@ -209,16 +175,24 @@ impl Deps for DepsType {
209175 dep_node:: DEP_KIND_NAMES [ dep_kind. as_usize ( ) ]
210176 }
211177
178+ /// We use this for most things when incr. comp. is turned off.
212179 const DEP_KIND_NULL : DepKind = dep_kinds:: Null ;
180+
181+ /// We use this to create a forever-red node.
213182 const DEP_KIND_RED : DepKind = dep_kinds:: Red ;
183+
184+ /// We use this to create a side effect node.
214185 const DEP_KIND_SIDE_EFFECT : DepKind = dep_kinds:: SideEffect ;
186+
187+ /// We use this to create the anon node with zero dependencies.
215188 const DEP_KIND_ANON_ZERO_DEPS : DepKind = dep_kinds:: AnonZeroDeps ;
189+
190+ /// This is the highest value a `DepKind` can have. It's used during encoding to
191+ /// pack information into the unused bits.
216192 const DEP_KIND_MAX : u16 = dep_node:: DEP_KIND_VARIANTS - 1 ;
217193}
218194
219195impl < ' tcx > DepContext for TyCtxt < ' tcx > {
220- type Deps = DepsType ;
221-
222196 #[ inline]
223197 fn with_stable_hashing_context < R > ( self , f : impl FnOnce ( StableHashingContext < ' _ > ) -> R ) -> R {
224198 TyCtxt :: with_stable_hashing_context ( self , f)
0 commit comments