Skip to content

Commit 44a0522

Browse files
incr.comp.: Use ensure() for some coherence-related queries.
1 parent dba52ce commit 44a0522

File tree

4 files changed

+10
-15
lines changed

4 files changed

+10
-15
lines changed

src/librustc/ty/maps/config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ impl<'tcx> QueryDescription<'tcx> for queries::type_param_predicates<'tcx> {
102102
}
103103

104104
impl<'tcx> QueryDescription<'tcx> for queries::coherent_trait<'tcx> {
105-
fn describe(tcx: TyCtxt, (_, def_id): (CrateNum, DefId)) -> String {
105+
fn describe(tcx: TyCtxt, def_id: DefId) -> String {
106106
format!("coherence checking all impls of trait `{}`",
107107
tcx.item_path_str(def_id))
108108
}

src/librustc/ty/maps/mod.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ define_maps! { <'tcx>
187187

188188
[] fn has_typeck_tables: HasTypeckTables(DefId) -> bool,
189189

190-
[] fn coherent_trait: coherent_trait_dep_node((CrateNum, DefId)) -> (),
190+
[] fn coherent_trait: CoherenceCheckTrait(DefId) -> (),
191191

192192
[] fn borrowck: BorrowCheck(DefId) -> Rc<BorrowCheckResult>,
193193

@@ -385,10 +385,6 @@ fn fulfill_obligation_dep_node<'tcx>((param_env, trait_ref):
385385
}
386386
}
387387

388-
fn coherent_trait_dep_node<'tcx>((_, def_id): (CrateNum, DefId)) -> DepConstructor<'tcx> {
389-
DepConstructor::CoherenceCheckTrait(def_id)
390-
}
391-
392388
fn crate_inherent_impls_dep_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
393389
DepConstructor::Coherence
394390
}

src/librustc/ty/util.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//! misc. type-system utilities too small to deserve their own file
1212
1313
use hir::def::Def;
14-
use hir::def_id::{DefId, LOCAL_CRATE};
14+
use hir::def_id::DefId;
1515
use hir::map::{DefPathData, Node};
1616
use hir;
1717
use ich::NodeIdHashingMode;
@@ -427,7 +427,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
427427
return None;
428428
};
429429

430-
self.coherent_trait((LOCAL_CRATE, drop_trait));
430+
ty::maps::queries::coherent_trait::ensure(self, drop_trait);
431431

432432
let mut dtor_did = None;
433433
let ty = self.type_of(adt_did);

src/librustc_typeck/coherence/mod.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
// done by the orphan and overlap modules. Then we build up various
1616
// mappings. That mapping code resides here.
1717

18-
use hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
19-
use rustc::ty::{TyCtxt, TypeFoldable};
18+
use hir::def_id::{DefId, LOCAL_CRATE};
19+
use rustc::ty::{self, TyCtxt, TypeFoldable};
2020
use rustc::ty::maps::Providers;
2121

2222
use syntax::ast;
@@ -113,8 +113,7 @@ pub fn provide(providers: &mut Providers) {
113113
};
114114
}
115115

116-
fn coherent_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
117-
(_, def_id): (CrateNum, DefId)) {
116+
fn coherent_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) {
118117
let impls = tcx.hir.trait_impls(def_id);
119118
for &impl_id in impls {
120119
check_impl(tcx, impl_id);
@@ -127,14 +126,14 @@ fn coherent_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
127126

128127
pub fn check_coherence<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
129128
for &trait_def_id in tcx.hir.krate().trait_impls.keys() {
130-
tcx.coherent_trait((LOCAL_CRATE, trait_def_id));
129+
ty::maps::queries::coherent_trait::ensure(tcx, trait_def_id);
131130
}
132131

133132
unsafety::check(tcx);
134133
orphan::check(tcx);
135134
overlap::check_auto_impls(tcx);
136135

137136
// these queries are executed for side-effects (error reporting):
138-
tcx.crate_inherent_impls(LOCAL_CRATE);
139-
tcx.crate_inherent_impls_overlap_check(LOCAL_CRATE);
137+
ty::maps::queries::crate_inherent_impls::ensure(tcx, LOCAL_CRATE);
138+
ty::maps::queries::crate_inherent_impls_overlap_check::ensure(tcx, LOCAL_CRATE);
140139
}

0 commit comments

Comments
 (0)