15
15
16
16
use std:: iter:: FromIterator ;
17
17
use std:: vec:: Vec ;
18
- use rustc:: dep_graph:: { DepNode , label_strs} ;
18
+ use rustc:: dep_graph:: { CompletedDepGraph , ReconstructedDepGraph , DepNode , label_strs} ;
19
19
use rustc:: hir;
20
20
use rustc:: hir:: { ItemKind as HirItem , ImplItemKind , TraitItemKind } ;
21
21
use rustc:: hir:: Node as HirNode ;
@@ -206,16 +206,21 @@ impl Assertion {
206
206
}
207
207
}
208
208
209
- pub fn check_dirty_clean_annotations < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ) {
209
+ pub fn check_dirty_clean_annotations < ' a , ' tcx > (
210
+ tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
211
+ dep_graph : & CompletedDepGraph ,
212
+ ) {
210
213
// can't add `#[rustc_dirty]` etc without opting in to this feature
211
214
if !tcx. features ( ) . rustc_attrs {
212
215
return ;
213
216
}
214
217
215
218
tcx. dep_graph . with_ignore ( || {
219
+ let graph = ReconstructedDepGraph :: new ( dep_graph) ;
216
220
let krate = tcx. hir ( ) . krate ( ) ;
217
221
let mut dirty_clean_visitor = DirtyCleanVisitor {
218
222
tcx,
223
+ graph,
219
224
checked_attrs : Default :: default ( ) ,
220
225
} ;
221
226
krate. visit_all_item_likes ( & mut dirty_clean_visitor) ;
@@ -236,6 +241,7 @@ pub fn check_dirty_clean_annotations<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
236
241
237
242
struct DirtyCleanVisitor < ' a , ' tcx : ' a > {
238
243
tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
244
+ graph : ReconstructedDepGraph ,
239
245
checked_attrs : FxHashSet < ast:: AttrId > ,
240
246
}
241
247
@@ -460,7 +466,7 @@ impl<'a, 'tcx> DirtyCleanVisitor<'a, 'tcx> {
460
466
} )
461
467
}
462
468
463
- fn _dep_node_str ( & self , dep_node : & DepNode ) -> String {
469
+ fn dep_node_str ( & self , dep_node : & DepNode ) -> String {
464
470
if let Some ( def_id) = dep_node. extract_def_id ( self . tcx ) {
465
471
format ! ( "{:?}({})" ,
466
472
dep_node. kind,
@@ -470,34 +476,32 @@ impl<'a, 'tcx> DirtyCleanVisitor<'a, 'tcx> {
470
476
}
471
477
}
472
478
473
- fn assert_dirty ( & self , _item_span : Span , dep_node : DepNode ) {
479
+ fn assert_dirty ( & self , item_span : Span , dep_node : DepNode ) {
474
480
debug ! ( "assert_dirty({:?})" , dep_node) ;
475
- panic ! ( )
476
- /*let dep_node_index = self.tcx.dep_graph.dep_node_index_of(&dep_node);
477
- let current_fingerprint = self.tcx.dep_graph.fingerprint_of(dep_node_index);
481
+ let dep_node_index = self . graph . dep_node_index_of ( & dep_node) ;
482
+ let current_fingerprint = self . graph . fingerprint_of ( dep_node_index) ;
478
483
let prev_fingerprint = self . tcx . dep_graph . prev_fingerprint_of ( & dep_node) ;
479
484
480
485
if Some ( current_fingerprint) == prev_fingerprint {
481
486
let dep_node_str = self . dep_node_str ( & dep_node) ;
482
487
self . tcx . sess . span_err (
483
488
item_span,
484
489
& format ! ( "`{}` should be dirty but is not" , dep_node_str) ) ;
485
- }*/
490
+ }
486
491
}
487
492
488
- fn assert_clean ( & self , _item_span : Span , dep_node : DepNode ) {
493
+ fn assert_clean ( & self , item_span : Span , dep_node : DepNode ) {
489
494
debug ! ( "assert_clean({:?})" , dep_node) ;
490
- panic ! ( )
491
- /*let dep_node_index = self.tcx.dep_graph.dep_node_index_of(&dep_node);
492
- let current_fingerprint = self.tcx.dep_graph.fingerprint_of(dep_node_index);
495
+ let dep_node_index = self . graph . dep_node_index_of ( & dep_node) ;
496
+ let current_fingerprint = self . graph . fingerprint_of ( dep_node_index) ;
493
497
let prev_fingerprint = self . tcx . dep_graph . prev_fingerprint_of ( & dep_node) ;
494
498
495
499
if Some ( current_fingerprint) != prev_fingerprint {
496
500
let dep_node_str = self . dep_node_str ( & dep_node) ;
497
501
self . tcx . sess . span_err (
498
502
item_span,
499
503
& format ! ( "`{}` should be clean but is not" , dep_node_str) ) ;
500
- }*/
504
+ }
501
505
}
502
506
503
507
fn check_item ( & mut self , item_id : hir:: HirId , item_span : Span ) {
0 commit comments