}
#[derive(Clone)]
-pub(super) struct CycleError<'tcx> {
+pub struct CycleError<'tcx> {
/// The query and related span which uses the cycle
pub(super) usage: Option<(Span, Query<'tcx>)>,
pub(super) cycle: Vec<QueryInfo<'tcx>>,
$($(#[$attr:meta])*
[$($modifiers:tt)*] fn $name:ident: $node:ident($K:ty) -> $V:ty,)*) => {
+ use std::mem;
+ use ty::maps::job::QueryResult;
use rustc_data_structures::sync::Lock;
+ use {
+ rustc_data_structures::stable_hasher::HashStable,
+ rustc_data_structures::stable_hasher::StableHasherResult,
+ rustc_data_structures::stable_hasher::StableHasher,
+ ich::StableHashingContext
+ };
define_map_struct! {
tcx: $tcx,
$($name: Lock::new(QueryMap::new())),*
}
}
+
+ pub fn collect_active_jobs(&self) -> Vec<Lrc<QueryJob<$tcx>>> {
+ let mut jobs = Vec::new();
+
+ $(for v in self.$name.lock().active.values() {
+ match *v {
+ QueryResult::Started(ref job) => jobs.push(job.clone()),
+ _ => (),
+ }
+ })*
+
+ return jobs;
+ }
}
#[allow(bad_style)]
- #[derive(Copy, Clone, Debug, PartialEq, Eq)]
+ #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
pub enum Query<$tcx> {
$($(#[$attr])* $name($K)),*
}
}
}
+ impl<'a, $tcx> HashStable<StableHashingContext<'a>> for Query<$tcx> {
+ fn hash_stable<W: StableHasherResult>(&self,
+ hcx: &mut StableHashingContext<'a>,
+ hasher: &mut StableHasher<W>) {
+ mem::discriminant(self).hash_stable(hcx, hasher);
+ match *self {
+ $(Query::$name(key) => key.hash_stable(hcx, hasher),)*
+ }
+ }
+ }
+
pub mod queries {
use std::marker::PhantomData;