Move depth_limit_error out of QueryContext trait.

It's defined and used in `rustc_query_impl`; `rustc_query_system`
doesn't need it. So it can just be an inherent method on `QueryCtxt`.
This commit is contained in:
Nicholas Nethercote 2026-02-02 10:41:03 +11:00
parent 8e2c9c69c6
commit c6afd45ac1
2 changed files with 17 additions and 19 deletions

View file

@ -48,6 +48,23 @@ impl<'tcx> QueryCtxt<'tcx> {
pub fn new(tcx: TyCtxt<'tcx>) -> Self {
QueryCtxt { tcx }
}
fn depth_limit_error(self, job: QueryJobId) {
let query_map = self.collect_active_jobs(true).expect("failed to collect active queries");
let (info, depth) = job.find_dep_kind_root(query_map);
let suggested_limit = match self.tcx.recursion_limit() {
Limit(0) => Limit(2),
limit => limit * 2,
};
self.tcx.sess.dcx().emit_fatal(QueryOverflow {
span: info.job.span,
note: QueryOverflowNote { desc: info.frame.info.extract().description, depth },
suggested_limit,
crate_name: self.tcx.crate_name(LOCAL_CRATE),
});
}
}
impl<'tcx> HasDepContext for QueryCtxt<'tcx> {
@ -155,23 +172,6 @@ impl<'tcx> QueryContext<'tcx> for QueryCtxt<'tcx> {
tls::enter_context(&new_icx, compute)
})
}
fn depth_limit_error(self, job: QueryJobId) {
let query_map = self.collect_active_jobs(true).expect("failed to collect active queries");
let (info, depth) = job.find_dep_kind_root(query_map);
let suggested_limit = match self.tcx.recursion_limit() {
Limit(0) => Limit(2),
limit => limit * 2,
};
self.tcx.sess.dcx().emit_fatal(QueryOverflow {
span: info.job.span,
note: QueryOverflowNote { desc: info.frame.info.extract().description, depth },
suggested_limit,
crate_name: self.tcx.crate_name(LOCAL_CRATE),
});
}
}
pub(super) fn try_mark_green<'tcx>(tcx: TyCtxt<'tcx>, dep_node: &dep_graph::DepNode) -> bool {

View file

@ -181,6 +181,4 @@ pub trait QueryContext<'tcx>: HasDepContext {
/// new query job while it executes.
fn start_query<R>(self, token: QueryJobId, depth_limit: bool, compute: impl FnOnce() -> R)
-> R;
fn depth_limit_error(self, job: QueryJobId);
}