Prevent cycle in implied predicates computation
This commit is contained in:
parent
1d447a9946
commit
6edbc8d875
3 changed files with 49 additions and 8 deletions
|
@ -640,16 +640,30 @@ pub(super) fn implied_predicates_with_filter(
|
|||
|
||||
// Now require that immediate supertraits are converted, which will, in
|
||||
// turn, reach indirect supertraits, so we detect cycles now instead of
|
||||
// overflowing during elaboration.
|
||||
if matches!(filter, PredicateFilter::SelfOnly) {
|
||||
for &(pred, span) in implied_bounds {
|
||||
debug!("superbound: {:?}", pred);
|
||||
if let ty::ClauseKind::Trait(bound) = pred.kind().skip_binder()
|
||||
&& bound.polarity == ty::ImplPolarity::Positive
|
||||
{
|
||||
tcx.at(span).super_predicates_of(bound.def_id());
|
||||
// overflowing during elaboration. Same for implied predicates, which
|
||||
// make sure we walk into associated type bounds.
|
||||
match filter {
|
||||
PredicateFilter::SelfOnly => {
|
||||
for &(pred, span) in implied_bounds {
|
||||
debug!("superbound: {:?}", pred);
|
||||
if let ty::ClauseKind::Trait(bound) = pred.kind().skip_binder()
|
||||
&& bound.polarity == ty::ImplPolarity::Positive
|
||||
{
|
||||
tcx.at(span).super_predicates_of(bound.def_id());
|
||||
}
|
||||
}
|
||||
}
|
||||
PredicateFilter::SelfAndAssociatedTypeBounds => {
|
||||
for &(pred, span) in implied_bounds {
|
||||
debug!("superbound: {:?}", pred);
|
||||
if let ty::ClauseKind::Trait(bound) = pred.kind().skip_binder()
|
||||
&& bound.polarity == ty::ImplPolarity::Positive
|
||||
{
|
||||
tcx.at(span).implied_predicates_of(bound.def_id());
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
ty::GenericPredicates { parent: None, predicates: implied_bounds }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue