1
Fork 0

correct span, add help message and add UI test when query depth overflows

This commit is contained in:
SparrowLii 2022-09-15 15:45:17 +08:00
parent 44506f38e0
commit 89fd6ae458
8 changed files with 82 additions and 24 deletions

View file

@ -19,8 +19,10 @@ use rustc_query_system::query::{
force_query, QueryConfig, QueryContext, QueryDescription, QueryJobId, QueryMap,
QuerySideEffects, QueryStackFrame,
};
use rustc_query_system::Value;
use rustc_query_system::{LayoutOfDepth, QueryOverflow, Value};
use rustc_serialize::Decodable;
use rustc_session::Limit;
use rustc_span::def_id::LOCAL_CRATE;
use std::any::Any;
use std::num::NonZeroU64;
use thin_vec::ThinVec;
@ -127,6 +129,29 @@ impl QueryContext for QueryCtxt<'_> {
})
})
}
fn depth_limit_error(&self, job: QueryJobId) {
let mut span = None;
let mut layout_of_depth = None;
if let Some(map) = self.try_collect_active_jobs() {
if let Some((info, depth)) = job.try_find_layout_root(map) {
span = Some(info.job.span);
layout_of_depth = Some(LayoutOfDepth { desc: info.query.description, depth });
}
}
let suggested_limit = match self.recursion_limit() {
Limit(0) => Limit(2),
limit => limit * 2,
};
self.sess.emit_fatal(QueryOverflow {
span,
layout_of_depth,
suggested_limit,
crate_name: self.crate_name(LOCAL_CRATE),
});
}
}
impl<'tcx> QueryCtxt<'tcx> {