Skip to content

Commit 987631d

Browse files
committed
Move query functions out from the define_maps! macro
1 parent 4036d2b commit 987631d

File tree

8 files changed

+327
-300
lines changed

8 files changed

+327
-300
lines changed

src/librustc/ty/maps/config.rs

+15-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
use dep_graph::SerializedDepNodeIndex;
12+
use dep_graph::DepNode;
1213
use hir::def_id::{CrateNum, DefId, DefIndex};
1314
use mir::interpret::{GlobalId};
1415
use traits::query::{CanonicalPredicateGoal, CanonicalProjectionGoal, CanonicalTyGoal};
@@ -19,20 +20,31 @@ use ty::maps::Query;
1920
use ty::maps::QueryMap;
2021

2122
use std::hash::Hash;
23+
use std::fmt::Debug;
2224
use syntax_pos::symbol::InternedString;
2325
use rustc_data_structures::sync::Lock;
26+
use rustc_data_structures::stable_hasher::HashStable;
27+
use ich::StableHashingContext;
2428

2529
/// Query configuration and description traits.
2630
2731
pub trait QueryConfig<'tcx> {
28-
type Key: Eq + Hash + Clone;
29-
type Value: Clone;
32+
const NAME: &'static str;
33+
34+
type Key: Eq + Hash + Clone + Debug;
35+
type Value: Clone + for<'a> HashStable<StableHashingContext<'a>>;
3036

3137
fn query(key: Self::Key) -> Query<'tcx>;
3238
fn query_map<'a>(tcx: TyCtxt<'a, 'tcx, '_>) -> &'a Lock<QueryMap<'tcx, Self>>;
39+
40+
fn to_dep_node(tcx: TyCtxt<'_, 'tcx, '_>, key: &Self::Key) -> DepNode;
41+
42+
fn compute(tcx: TyCtxt<'_, 'tcx, '_>, key: Self::Key) -> Self::Value;
43+
44+
fn handle_cycle_error(tcx: TyCtxt<'_, 'tcx, '_>) -> Self::Value;
3345
}
3446

35-
pub(super) trait QueryDescription<'tcx>: QueryConfig<'tcx> {
47+
pub trait QueryDescription<'tcx>: QueryConfig<'tcx> {
3648
fn describe(tcx: TyCtxt, key: Self::Key) -> String;
3749

3850
#[inline]

src/librustc/ty/maps/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
// except according to those terms.
1010

1111
use dep_graph::{DepConstructor, DepNode};
12-
use errors::DiagnosticBuilder;
1312
use hir::def_id::{CrateNum, DefId, DefIndex};
1413
use hir::def::{Def, Export};
1514
use hir::{self, TraitCandidate, ItemLocalId, TransFnAttrs};
@@ -43,7 +42,7 @@ use ty::{self, CrateInherentImpls, ParamEnvAnd, Ty, TyCtxt};
4342
use ty::steal::Steal;
4443
use ty::subst::Substs;
4544
use util::nodemap::{DefIdSet, DefIdMap, ItemLocalSet};
46-
use util::common::{profq_msg, ErrorReported, ProfileQueriesMsg};
45+
use util::common::{ErrorReported};
4746

4847
use rustc_data_structures::indexed_set::IdxSetBuf;
4948
use rustc_target::spec::PanicStrategy;

0 commit comments

Comments
 (0)