@@ -24,6 +24,15 @@ trait Key {
24
24
fn default_span ( & self , tcx : TyCtxt ) -> Span ;
25
25
}
26
26
27
+ impl Key for CrateNum {
28
+ fn map_crate ( & self ) -> CrateNum {
29
+ * self
30
+ }
31
+ fn default_span ( & self , _: TyCtxt ) -> Span {
32
+ DUMMY_SP
33
+ }
34
+ }
35
+
27
36
impl Key for DefId {
28
37
fn map_crate ( & self ) -> CrateNum {
29
38
self . krate
@@ -42,6 +51,15 @@ impl Key for (DefId, DefId) {
42
51
}
43
52
}
44
53
54
+ impl Key for ( CrateNum , DefId ) {
55
+ fn map_crate ( & self ) -> CrateNum {
56
+ self . 0
57
+ }
58
+ fn default_span ( & self , tcx : TyCtxt ) -> Span {
59
+ self . 1 . default_span ( tcx)
60
+ }
61
+ }
62
+
45
63
trait Value < ' tcx > : Sized {
46
64
fn from_cycle_error < ' a > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ) -> Self ;
47
65
}
@@ -141,6 +159,19 @@ impl<'tcx> QueryDescription for queries::type_param_predicates<'tcx> {
141
159
}
142
160
}
143
161
162
+ impl < ' tcx > QueryDescription for queries:: coherent_trait < ' tcx > {
163
+ fn describe ( tcx : TyCtxt , ( _, def_id) : ( CrateNum , DefId ) ) -> String {
164
+ format ! ( "coherence checking all impls of trait `{}`" ,
165
+ tcx. item_path_str( def_id) )
166
+ }
167
+ }
168
+
169
+ impl < ' tcx > QueryDescription for queries:: coherent_inherent_impls < ' tcx > {
170
+ fn describe ( _: TyCtxt , _: CrateNum ) -> String {
171
+ format ! ( "coherence checking all inherent impls" )
172
+ }
173
+ }
174
+
144
175
macro_rules! define_maps {
145
176
( <$tcx: tt>
146
177
$( $( #[ $attr: meta] ) *
@@ -238,6 +269,12 @@ macro_rules! define_maps {
238
269
}
239
270
240
271
pub fn force( tcx: TyCtxt <' a, $tcx, ' lcx>, span: Span , key: $K) {
272
+ // FIXME(eddyb) Move away from using `DepTrackingMap`
273
+ // so we don't have to explicitly ignore a false edge:
274
+ // we can't observe a value dependency, only side-effects,
275
+ // through `force`, and once everything has been updated,
276
+ // perhaps only diagnostics, if those, will remain.
277
+ let _ignore = tcx. dep_graph. in_ignore( ) ;
241
278
match Self :: try_get_with( tcx, span, key, |_| ( ) ) {
242
279
Ok ( ( ) ) => { }
243
280
Err ( e) => tcx. report_cycle( e)
@@ -338,7 +375,19 @@ define_maps! { <'tcx>
338
375
339
376
pub typeck_tables: TypeckTables ( DefId ) -> & ' tcx ty:: TypeckTables <' tcx>,
340
377
378
+ pub coherent_trait: coherent_trait_dep_node( ( CrateNum , DefId ) ) -> ( ) ,
379
+
380
+ pub coherent_inherent_impls: coherent_inherent_impls_dep_node( CrateNum ) -> ( ) ,
381
+
341
382
/// Results of evaluating monomorphic constants embedded in
342
383
/// other items, such as enum variant explicit discriminants.
343
384
pub monomorphic_const_eval: MonomorphicConstEval ( DefId ) -> Result <ConstVal , ( ) >
344
385
}
386
+
387
+ fn coherent_trait_dep_node ( ( _, def_id) : ( CrateNum , DefId ) ) -> DepNode < DefId > {
388
+ DepNode :: CoherenceCheckTrait ( def_id)
389
+ }
390
+
391
+ fn coherent_inherent_impls_dep_node ( _: CrateNum ) -> DepNode < DefId > {
392
+ DepNode :: Coherence
393
+ }
0 commit comments