1
Fork 0

Avoid calling queries during query stack printing

This commit is contained in:
Oli Scherer 2023-06-27 09:07:14 +00:00 committed by Philipp Krones
parent 5d3377dd67
commit b0142f603d
No known key found for this signature in database
GPG key ID: 1CA0DF2AF59D68A5
5 changed files with 38 additions and 13 deletions

View file

@ -94,6 +94,10 @@ macro_rules! define_helper {
$tl.with(|c| c.set(self.0))
}
}
pub fn $name() -> bool {
$tl.with(|c| c.get())
}
)+
}
}
@ -676,7 +680,7 @@ pub trait PrettyPrinter<'tcx>:
p!(")")
}
ty::FnDef(def_id, substs) => {
if NO_QUERIES.with(|q| q.get()) {
if with_no_queries() {
p!(print_def_path(def_id, substs));
} else {
let sig = self.tcx().fn_sig(def_id).subst(self.tcx(), substs);
@ -732,7 +736,7 @@ pub trait PrettyPrinter<'tcx>:
p!(print_def_path(def_id, &[]));
}
ty::Alias(ty::Projection | ty::Inherent | ty::Weak, ref data) => {
if !(self.should_print_verbose() || NO_QUERIES.with(|q| q.get()))
if !(self.should_print_verbose() || with_no_queries())
&& self.tcx().is_impl_trait_in_trait(data.def_id)
{
return self.pretty_print_opaque_impl_type(data.def_id, data.substs);
@ -779,7 +783,7 @@ pub trait PrettyPrinter<'tcx>:
return Ok(self);
}
_ => {
if NO_QUERIES.with(|q| q.get()) {
if with_no_queries() {
p!(print_def_path(def_id, &[]));
return Ok(self);
} else {
@ -1746,7 +1750,8 @@ impl DerefMut for FmtPrinter<'_, '_> {
impl<'a, 'tcx> FmtPrinter<'a, 'tcx> {
pub fn new(tcx: TyCtxt<'tcx>, ns: Namespace) -> Self {
Self::new_with_limit(tcx, ns, tcx.type_length_limit())
let limit = if with_no_queries() { Limit::new(1048576) } else { tcx.type_length_limit() };
Self::new_with_limit(tcx, ns, limit)
}
pub fn new_with_limit(tcx: TyCtxt<'tcx>, ns: Namespace, type_length_limit: Limit) -> Self {