Skip to content

Commit 6c4a49e

Browse files
committed
Move impl of Queries with its definition.
1 parent be79e63 commit 6c4a49e

File tree

1 file changed

+49
-49
lines changed

1 file changed

+49
-49
lines changed

src/librustc/ty/query/plumbing.rs

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -842,55 +842,6 @@ macro_rules! define_queries_inner {
842842
input: ($(([$($modifiers)*] [$($attr)*] [$name]))*)
843843
}
844844

845-
impl<$tcx> Queries<$tcx> {
846-
pub fn new(
847-
providers: IndexVec<CrateNum, Providers<$tcx>>,
848-
fallback_extern_providers: Providers<$tcx>,
849-
on_disk_cache: OnDiskCache<'tcx>,
850-
) -> Self {
851-
Queries {
852-
providers,
853-
fallback_extern_providers: Box::new(fallback_extern_providers),
854-
on_disk_cache,
855-
$($name: Default::default()),*
856-
}
857-
}
858-
859-
pub fn try_collect_active_jobs(
860-
&self
861-
) -> Option<FxHashMap<QueryJobId, QueryJobInfo<'tcx>>> {
862-
let mut jobs = FxHashMap::default();
863-
864-
$(
865-
// We use try_lock_shards here since we are called from the
866-
// deadlock handler, and this shouldn't be locked.
867-
let shards = self.$name.shards.try_lock_shards()?;
868-
let shards = shards.iter().enumerate();
869-
jobs.extend(shards.flat_map(|(shard_id, shard)| {
870-
shard.active.iter().filter_map(move |(k, v)| {
871-
if let QueryResult::Started(ref job) = *v {
872-
let id = QueryJobId {
873-
job: job.id,
874-
shard: u16::try_from(shard_id).unwrap(),
875-
kind:
876-
<queries::$name<'tcx> as QueryAccessors<'tcx>>::DEP_KIND,
877-
};
878-
let info = QueryInfo {
879-
span: job.span,
880-
query: Query::$name(k.clone())
881-
};
882-
Some((id, QueryJobInfo { info, job: job.clone() }))
883-
} else {
884-
None
885-
}
886-
})
887-
}));
888-
)*
889-
890-
Some(jobs)
891-
}
892-
}
893-
894845
#[allow(nonstandard_style)]
895846
#[derive(Clone, Debug)]
896847
pub enum Query<$tcx> {
@@ -1132,6 +1083,55 @@ macro_rules! define_queries_struct {
11321083

11331084
$($(#[$attr])* $name: QueryState<$tcx, queries::$name<$tcx>>,)*
11341085
}
1086+
1087+
impl<$tcx> Queries<$tcx> {
1088+
pub fn new(
1089+
providers: IndexVec<CrateNum, Providers<$tcx>>,
1090+
fallback_extern_providers: Providers<$tcx>,
1091+
on_disk_cache: OnDiskCache<'tcx>,
1092+
) -> Self {
1093+
Queries {
1094+
providers,
1095+
fallback_extern_providers: Box::new(fallback_extern_providers),
1096+
on_disk_cache,
1097+
$($name: Default::default()),*
1098+
}
1099+
}
1100+
1101+
pub fn try_collect_active_jobs(
1102+
&self
1103+
) -> Option<FxHashMap<QueryJobId, QueryJobInfo<'tcx>>> {
1104+
let mut jobs = FxHashMap::default();
1105+
1106+
$(
1107+
// We use try_lock_shards here since we are called from the
1108+
// deadlock handler, and this shouldn't be locked.
1109+
let shards = self.$name.shards.try_lock_shards()?;
1110+
let shards = shards.iter().enumerate();
1111+
jobs.extend(shards.flat_map(|(shard_id, shard)| {
1112+
shard.active.iter().filter_map(move |(k, v)| {
1113+
if let QueryResult::Started(ref job) = *v {
1114+
let id = QueryJobId {
1115+
job: job.id,
1116+
shard: u16::try_from(shard_id).unwrap(),
1117+
kind:
1118+
<queries::$name<'tcx> as QueryAccessors<'tcx>>::DEP_KIND,
1119+
};
1120+
let info = QueryInfo {
1121+
span: job.span,
1122+
query: Query::$name(k.clone())
1123+
};
1124+
Some((id, QueryJobInfo { info, job: job.clone() }))
1125+
} else {
1126+
None
1127+
}
1128+
})
1129+
}));
1130+
)*
1131+
1132+
Some(jobs)
1133+
}
1134+
}
11351135
};
11361136
}
11371137

0 commit comments

Comments
 (0)