Fix query cycle when tracing explicit_item_bounds

This commit is contained in:
Matthew Jasper 2020-10-28 19:50:08 +00:00
parent ffe52882ed
commit 1f5c655d0c
2 changed files with 9 additions and 9 deletions

View File

@ -65,7 +65,7 @@ thread_local! {
/// Avoids running any queries during any prints that occur
/// during the closure. This may alter the appearance of some
/// types (e.g. forcing verbose printing for opaque types).
/// This method is used during some queries (e.g. `predicates_of`
/// This method is used during some queries (e.g. `explicit_item_bounds`
/// for opaque types), to ensure that any debug printing that
/// occurs during the query computation does not end up recursively
/// calling the same query.

View File

@ -61,23 +61,23 @@ fn opaque_type_bounds<'tcx>(
bounds: &'tcx [hir::GenericBound<'tcx>],
span: Span,
) -> &'tcx [(ty::Predicate<'tcx>, Span)] {
let item_ty =
tcx.mk_opaque(opaque_def_id, InternalSubsts::identity_for_item(tcx, opaque_def_id));
ty::print::with_no_queries(|| {
let item_ty =
tcx.mk_opaque(opaque_def_id, InternalSubsts::identity_for_item(tcx, opaque_def_id));
let bounds = ty::print::with_no_queries(|| {
AstConv::compute_bounds(
let bounds = AstConv::compute_bounds(
&ItemCtxt::new(tcx, opaque_def_id),
item_ty,
bounds,
SizedByDefault::Yes,
span,
)
});
.predicates(tcx, item_ty);
let bounds = bounds.predicates(tcx, item_ty);
debug!("opaque_type_bounds({}) = {:?}", tcx.def_path_str(opaque_def_id), bounds);
debug!("opaque_type_bounds({}) = {:?}", tcx.def_path_str(opaque_def_id), bounds);
tcx.arena.alloc_slice(&bounds)
tcx.arena.alloc_slice(&bounds)
})
}
pub(super) fn explicit_item_bounds(