1515
1616use std:: iter:: FromIterator ;
1717use std:: vec:: Vec ;
18- use rustc:: dep_graph:: { DepNode , label_strs} ;
18+ use rustc:: dep_graph:: { CompletedDepGraph , ReconstructedDepGraph , DepNode , label_strs} ;
1919use rustc:: hir;
2020use rustc:: hir:: { ItemKind as HirItem , ImplItemKind , TraitItemKind } ;
2121use rustc:: hir:: Node as HirNode ;
@@ -206,16 +206,21 @@ impl Assertion {
206206 }
207207}
208208
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+ ) {
210213 // can't add `#[rustc_dirty]` etc without opting in to this feature
211214 if !tcx. features ( ) . rustc_attrs {
212215 return ;
213216 }
214217
215218 tcx. dep_graph . with_ignore ( || {
219+ let graph = ReconstructedDepGraph :: new ( dep_graph) ;
216220 let krate = tcx. hir ( ) . krate ( ) ;
217221 let mut dirty_clean_visitor = DirtyCleanVisitor {
218222 tcx,
223+ graph,
219224 checked_attrs : Default :: default ( ) ,
220225 } ;
221226 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>) {
236241
237242struct DirtyCleanVisitor < ' a , ' tcx : ' a > {
238243 tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
244+ graph : ReconstructedDepGraph ,
239245 checked_attrs : FxHashSet < ast:: AttrId > ,
240246}
241247
@@ -460,7 +466,7 @@ impl<'a, 'tcx> DirtyCleanVisitor<'a, 'tcx> {
460466 } )
461467 }
462468
463- fn _dep_node_str ( & self , dep_node : & DepNode ) -> String {
469+ fn dep_node_str ( & self , dep_node : & DepNode ) -> String {
464470 if let Some ( def_id) = dep_node. extract_def_id ( self . tcx ) {
465471 format ! ( "{:?}({})" ,
466472 dep_node. kind,
@@ -470,34 +476,32 @@ impl<'a, 'tcx> DirtyCleanVisitor<'a, 'tcx> {
470476 }
471477 }
472478
473- fn assert_dirty ( & self , _item_span : Span , dep_node : DepNode ) {
479+ fn assert_dirty ( & self , item_span : Span , dep_node : DepNode ) {
474480 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) ;
478483 let prev_fingerprint = self . tcx . dep_graph . prev_fingerprint_of ( & dep_node) ;
479484
480485 if Some ( current_fingerprint) == prev_fingerprint {
481486 let dep_node_str = self . dep_node_str ( & dep_node) ;
482487 self . tcx . sess . span_err (
483488 item_span,
484489 & format ! ( "`{}` should be dirty but is not" , dep_node_str) ) ;
485- }*/
490+ }
486491 }
487492
488- fn assert_clean ( & self , _item_span : Span , dep_node : DepNode ) {
493+ fn assert_clean ( & self , item_span : Span , dep_node : DepNode ) {
489494 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) ;
493497 let prev_fingerprint = self . tcx . dep_graph . prev_fingerprint_of ( & dep_node) ;
494498
495499 if Some ( current_fingerprint) != prev_fingerprint {
496500 let dep_node_str = self . dep_node_str ( & dep_node) ;
497501 self . tcx . sess . span_err (
498502 item_span,
499503 & format ! ( "`{}` should be clean but is not" , dep_node_str) ) ;
500- }*/
504+ }
501505 }
502506
503507 fn check_item ( & mut self , item_id : hir:: HirId , item_span : Span ) {
0 commit comments