Skip to content

Commit 1f5c655

Browse files
committed
Fix query cycle when tracing explicit_item_bounds
1 parent ffe5288 commit 1f5c655

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

compiler/rustc_middle/src/ty/print/pretty.rs

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

compiler/rustc_typeck/src/collect/item_bounds.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -61,23 +61,23 @@ fn opaque_type_bounds<'tcx>(
6161
bounds: &'tcx [hir::GenericBound<'tcx>],
6262
span: Span,
6363
) -> &'tcx [(ty::Predicate<'tcx>, Span)] {
64-
let item_ty =
65-
tcx.mk_opaque(opaque_def_id, InternalSubsts::identity_for_item(tcx, opaque_def_id));
64+
ty::print::with_no_queries(|| {
65+
let item_ty =
66+
tcx.mk_opaque(opaque_def_id, InternalSubsts::identity_for_item(tcx, opaque_def_id));
6667

67-
let bounds = ty::print::with_no_queries(|| {
68-
AstConv::compute_bounds(
68+
let bounds = AstConv::compute_bounds(
6969
&ItemCtxt::new(tcx, opaque_def_id),
7070
item_ty,
7171
bounds,
7272
SizedByDefault::Yes,
7373
span,
7474
)
75-
});
75+
.predicates(tcx, item_ty);
7676

77-
let bounds = bounds.predicates(tcx, item_ty);
78-
debug!("opaque_type_bounds({}) = {:?}", tcx.def_path_str(opaque_def_id), bounds);
77+
debug!("opaque_type_bounds({}) = {:?}", tcx.def_path_str(opaque_def_id), bounds);
7978

80-
tcx.arena.alloc_slice(&bounds)
79+
tcx.arena.alloc_slice(&bounds)
80+
})
8181
}
8282

8383
pub(super) fn explicit_item_bounds(

0 commit comments

Comments
 (0)