Skip to content

Commit 6316abb

Browse files
committed
Skip executing MIR effect checking, but instead check that it is already executed elsewhere
1 parent e701447 commit 6316abb

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

src/librustc/ty/query/plumbing.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,23 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
606606
}
607607
}
608608

609+
/// Check that a query has already executed
610+
pub(super) fn assert_done<Q: QueryDescription<'gcx>>(self, key: Q::Key) -> () {
611+
let dep_node = Q::to_dep_node(self, &key);
612+
613+
if self.dep_graph.try_mark_green(self, &dep_node).is_some() {
614+
// It is already green
615+
return;
616+
}
617+
618+
match JobOwner::<'_, 'gcx, Q>::try_get(self, DUMMY_SP, &key) {
619+
TryGetJob::NotYetStarted(_) => {
620+
bug!("query should already be done {}, key={:?}", Q::NAME, key);
621+
},
622+
TryGetJob::JobCompleted(..) => {}
623+
}
624+
}
625+
609626
#[allow(dead_code)]
610627
fn force_query<Q: QueryDescription<'gcx>>(
611628
self,
@@ -969,6 +986,12 @@ macro_rules! define_queries_inner {
969986
fn handle_cycle_error(tcx: TyCtxt<'_, 'tcx, '_>) -> Self::Value {
970987
handle_cycle_error!([$($modifiers)*][tcx])
971988
}
989+
}
990+
991+
impl<'a, $tcx, 'lcx> queries::$name<$tcx> {
992+
pub fn assert_done(tcx: TyCtxt<'a, $tcx, 'lcx>, key: $K) -> () {
993+
tcx.assert_done::<queries::$name<'_>>(key);
994+
}
972995
})*
973996

974997
#[derive(Copy, Clone)]

src/librustc_driver/driver.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use rustc::hir::map as hir_map;
55
use rustc::lint;
66
use rustc::middle::{self, reachable, resolve_lifetime, stability};
77
use rustc::ty::{self, AllArenas, Resolutions, TyCtxt};
8+
use rustc::ty::query::queries;
89
use rustc::traits;
910
use rustc::util::common::{install_panic_hook, time, ErrorReported};
1011
use rustc::util::profiling::ProfileCategory;
@@ -1284,11 +1285,13 @@ where
12841285
rustc_traits::lowering::dump_program_clauses(tcx);
12851286
});
12861287

1287-
time(sess, "MIR effect checking", || {
1288+
if cfg!(debug_assertions) {
1289+
// `unsafety_check_result` should be executed by mir_borrowck.
1290+
// Ensure that is the case
12881291
tcx.par_body_owners(|def_id| {
1289-
tcx.ensure().unsafety_check_result(def_id);
1290-
})
1291-
});
1292+
queries::unsafety_check_result::assert_done(tcx, def_id);
1293+
});
1294+
}
12921295

12931296
time(sess, "layout testing", || layout_test::test_layout(tcx));
12941297

0 commit comments

Comments
 (0)