Skip to content

Commit d6bf776

Browse files
committed
Fix incremental tests
1 parent 5c45420 commit d6bf776

File tree

3 files changed

+31
-10
lines changed

3 files changed

+31
-10
lines changed

src/librustc_incremental/persist/dirty_clean.rs

+21-6
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use rustc::hir::itemlikevisit::ItemLikeVisitor;
2424
use rustc::hir::intravisit;
2525
use rustc::ich::{ATTR_DIRTY, ATTR_CLEAN};
2626
use rustc::ty::TyCtxt;
27+
use rustc_data_structures::fingerprint::Fingerprint;
2728
use rustc_data_structures::fx::FxHashSet;
2829
use syntax::ast::{self, Attribute, NestedMetaItem};
2930
use syntax::symbol::{Symbol, sym};
@@ -71,6 +72,7 @@ const BASE_IMPL: &[&str] = &[
7172
/// code, i.e., functions+methods
7273
const BASE_MIR: &[&str] = &[
7374
label_strs::optimized_mir,
75+
label_strs::promoted_mir,
7476
label_strs::mir_built,
7577
];
7678

@@ -472,26 +474,39 @@ impl DirtyCleanVisitor<'tcx> {
472474
fn assert_dirty(&self, item_span: Span, dep_node: DepNode) {
473475
debug!("assert_dirty({:?})", dep_node);
474476

475-
let dep_node_index = self.tcx.dep_graph.dep_node_index_of(&dep_node);
476-
let current_fingerprint = self.tcx.dep_graph.fingerprint_of(dep_node_index);
477+
let current_fingerprint = self.get_fingerprint(&dep_node);
477478
let prev_fingerprint = self.tcx.dep_graph.prev_fingerprint_of(&dep_node);
478479

479-
if Some(current_fingerprint) == prev_fingerprint {
480+
if current_fingerprint == prev_fingerprint {
480481
let dep_node_str = self.dep_node_str(&dep_node);
481482
self.tcx.sess.span_err(
482483
item_span,
483484
&format!("`{}` should be dirty but is not", dep_node_str));
484485
}
485486
}
486487

488+
fn get_fingerprint(&self, dep_node: &DepNode) -> Option<Fingerprint> {
489+
if self.tcx.dep_graph.dep_node_exists(dep_node) {
490+
let dep_node_index = self.tcx.dep_graph.dep_node_index_of(dep_node);
491+
Some(self.tcx.dep_graph.fingerprint_of(dep_node_index))
492+
} else {
493+
None
494+
}
495+
}
496+
487497
fn assert_clean(&self, item_span: Span, dep_node: DepNode) {
488498
debug!("assert_clean({:?})", dep_node);
489499

490-
let dep_node_index = self.tcx.dep_graph.dep_node_index_of(&dep_node);
491-
let current_fingerprint = self.tcx.dep_graph.fingerprint_of(dep_node_index);
500+
let current_fingerprint = self.get_fingerprint(&dep_node);
492501
let prev_fingerprint = self.tcx.dep_graph.prev_fingerprint_of(&dep_node);
493502

494-
if Some(current_fingerprint) != prev_fingerprint {
503+
// if the node wasn't previously evaluated and now is (or vice versa),
504+
// then the node isn't actually clean or dirty.
505+
if (current_fingerprint == None) ^ (prev_fingerprint == None) {
506+
return;
507+
}
508+
509+
if current_fingerprint != prev_fingerprint {
495510
let dep_node_str = self.dep_node_str(&dep_node);
496511
self.tcx.sess.span_err(
497512
item_span,

src/test/incremental/hashes/for_loops.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ pub fn change_iterable() {
9494
}
9595

9696
#[cfg(not(cfail1))]
97-
#[rustc_clean(cfg="cfail2", except="HirBody, mir_built")]
97+
#[rustc_clean(cfg="cfail2", except="HirBody, mir_built, promoted_mir")]
9898
#[rustc_clean(cfg="cfail3")]
9999
pub fn change_iterable() {
100100
let mut _x = 0;

src/test/incremental/hashes/inherent_impls.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ impl Foo {
4242
#[rustc_clean(cfg="cfail2")]
4343
#[rustc_clean(cfg="cfail3")]
4444
impl Foo {
45-
#[rustc_clean(cfg="cfail2", except="HirBody,optimized_mir,mir_built,typeck_tables_of")]
45+
#[rustc_clean(
46+
cfg="cfail2",
47+
except="HirBody,optimized_mir,promoted_mir,mir_built,typeck_tables_of"
48+
)]
4649
#[rustc_clean(cfg="cfail3")]
4750
pub fn method_body() {
4851
println!("Hello, world!");
@@ -63,7 +66,10 @@ impl Foo {
6366
#[rustc_clean(cfg="cfail2")]
6467
#[rustc_clean(cfg="cfail3")]
6568
impl Foo {
66-
#[rustc_clean(cfg="cfail2", except="HirBody,optimized_mir,mir_built,typeck_tables_of")]
69+
#[rustc_clean(
70+
cfg="cfail2",
71+
except="HirBody,optimized_mir,promoted_mir,mir_built,typeck_tables_of"
72+
)]
6773
#[rustc_clean(cfg="cfail3")]
6874
#[inline]
6975
pub fn method_body_inlined() {
@@ -97,7 +103,7 @@ impl Foo {
97103
#[rustc_clean(cfg="cfail2", except="Hir,HirBody")]
98104
#[rustc_clean(cfg="cfail3")]
99105
impl Foo {
100-
#[rustc_dirty(cfg="cfail2", except="type_of,predicates_of")]
106+
#[rustc_dirty(cfg="cfail2", except="type_of,predicates_of,promoted_mir")]
101107
#[rustc_clean(cfg="cfail3")]
102108
pub fn method_selfness(&self) { }
103109
}

0 commit comments

Comments
 (0)