Skip to content

Commit c8da70a

Browse files
authored
Unrolled build for rust-lang#136806
Rollup merge of rust-lang#136806 - adwinwhite:cycle-in-pretty-print-rpitit, r=compiler-errors Fix cycle when debug-printing opaque types from RPITIT Extend rust-lang#66594 to opaque types from RPITIT. Before this PR, enabling debug logging like `RUSTC_LOG="[check_type_bounds]"` for code containing RPITIT produces a query cycle of `explicit_item_bounds`, as pretty printing for opaque type calls [it](https://github.com/rust-lang/rust/blob/d9a4a47b8b3dc0bdff83360cea2013200d60d49c/compiler/rustc_middle/src/ty/print/pretty.rs#L1001).
2 parents 6dce9f8 + a634246 commit c8da70a

File tree

1 file changed

+45
-43
lines changed

1 file changed

+45
-43
lines changed

Diff for: compiler/rustc_hir_analysis/src/collect/item_bounds.rs

+45-43
Original file line numberDiff line numberDiff line change
@@ -30,53 +30,55 @@ fn associated_type_bounds<'tcx>(
3030
span: Span,
3131
filter: PredicateFilter,
3232
) -> &'tcx [(ty::Clause<'tcx>, Span)] {
33-
let item_ty = Ty::new_projection_from_args(
34-
tcx,
35-
assoc_item_def_id.to_def_id(),
36-
GenericArgs::identity_for_item(tcx, assoc_item_def_id),
37-
);
38-
39-
let icx = ItemCtxt::new(tcx, assoc_item_def_id);
40-
let mut bounds = Bounds::default();
41-
icx.lowerer().lower_bounds(item_ty, hir_bounds, &mut bounds, ty::List::empty(), filter);
42-
// Associated types are implicitly sized unless a `?Sized` bound is found
43-
match filter {
44-
PredicateFilter::All
45-
| PredicateFilter::SelfOnly
46-
| PredicateFilter::SelfTraitThatDefines(_)
47-
| PredicateFilter::SelfAndAssociatedTypeBounds => {
48-
icx.lowerer().add_sized_bound(&mut bounds, item_ty, hir_bounds, None, span);
33+
ty::print::with_reduced_queries!({
34+
let item_ty = Ty::new_projection_from_args(
35+
tcx,
36+
assoc_item_def_id.to_def_id(),
37+
GenericArgs::identity_for_item(tcx, assoc_item_def_id),
38+
);
39+
40+
let icx = ItemCtxt::new(tcx, assoc_item_def_id);
41+
let mut bounds = Bounds::default();
42+
icx.lowerer().lower_bounds(item_ty, hir_bounds, &mut bounds, ty::List::empty(), filter);
43+
// Associated types are implicitly sized unless a `?Sized` bound is found
44+
match filter {
45+
PredicateFilter::All
46+
| PredicateFilter::SelfOnly
47+
| PredicateFilter::SelfTraitThatDefines(_)
48+
| PredicateFilter::SelfAndAssociatedTypeBounds => {
49+
icx.lowerer().add_sized_bound(&mut bounds, item_ty, hir_bounds, None, span);
50+
}
51+
// `ConstIfConst` is only interested in `~const` bounds.
52+
PredicateFilter::ConstIfConst | PredicateFilter::SelfConstIfConst => {}
4953
}
50-
// `ConstIfConst` is only interested in `~const` bounds.
51-
PredicateFilter::ConstIfConst | PredicateFilter::SelfConstIfConst => {}
52-
}
5354

54-
let trait_def_id = tcx.local_parent(assoc_item_def_id);
55-
let trait_predicates = tcx.trait_explicit_predicates_and_bounds(trait_def_id);
56-
57-
let item_trait_ref = ty::TraitRef::identity(tcx, tcx.parent(assoc_item_def_id.to_def_id()));
58-
let bounds_from_parent =
59-
trait_predicates.predicates.iter().copied().filter_map(|(clause, span)| {
60-
remap_gat_vars_and_recurse_into_nested_projections(
61-
tcx,
62-
filter,
63-
item_trait_ref,
64-
assoc_item_def_id,
65-
span,
66-
clause,
67-
)
68-
});
69-
70-
let all_bounds = tcx.arena.alloc_from_iter(bounds.clauses().chain(bounds_from_parent));
71-
debug!(
72-
"associated_type_bounds({}) = {:?}",
73-
tcx.def_path_str(assoc_item_def_id.to_def_id()),
74-
all_bounds
75-
);
55+
let trait_def_id = tcx.local_parent(assoc_item_def_id);
56+
let trait_predicates = tcx.trait_explicit_predicates_and_bounds(trait_def_id);
57+
58+
let item_trait_ref = ty::TraitRef::identity(tcx, tcx.parent(assoc_item_def_id.to_def_id()));
59+
let bounds_from_parent =
60+
trait_predicates.predicates.iter().copied().filter_map(|(clause, span)| {
61+
remap_gat_vars_and_recurse_into_nested_projections(
62+
tcx,
63+
filter,
64+
item_trait_ref,
65+
assoc_item_def_id,
66+
span,
67+
clause,
68+
)
69+
});
70+
71+
let all_bounds = tcx.arena.alloc_from_iter(bounds.clauses().chain(bounds_from_parent));
72+
debug!(
73+
"associated_type_bounds({}) = {:?}",
74+
tcx.def_path_str(assoc_item_def_id.to_def_id()),
75+
all_bounds
76+
);
7677

77-
assert_only_contains_predicates_from(filter, all_bounds, item_ty);
78+
assert_only_contains_predicates_from(filter, all_bounds, item_ty);
7879

79-
all_bounds
80+
all_bounds
81+
})
8082
}
8183

8284
/// The code below is quite involved, so let me explain.

0 commit comments

Comments
 (0)