diff options
| author | Michael Goulet <michael@errs.io> | 2023-05-04 17:24:13 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2023-05-04 17:24:13 +0000 |
| commit | 930eece9d34b67533cf3d27c06253e806a5add0f (patch) | |
| tree | 43ac520695b17eeb60ee8047676670d8ba4bc999 /compiler/rustc_hir_analysis/src | |
| parent | eac35583d2ffb5ed9e564dee0822c9a244058ee0 (diff) | |
| download | rust-930eece9d34b67533cf3d27c06253e806a5add0f.tar.gz rust-930eece9d34b67533cf3d27c06253e806a5add0f.zip | |
Don't compute trait super bounds unless they're positive
Diffstat (limited to 'compiler/rustc_hir_analysis/src')
| -rw-r--r-- | compiler/rustc_hir_analysis/src/collect/predicates_of.rs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/compiler/rustc_hir_analysis/src/collect/predicates_of.rs b/compiler/rustc_hir_analysis/src/collect/predicates_of.rs index 83470342a76..c1e12b554e9 100644 --- a/compiler/rustc_hir_analysis/src/collect/predicates_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/predicates_of.rs @@ -657,14 +657,15 @@ pub(super) fn implied_predicates_with_filter( &*tcx.arena.alloc_from_iter(superbounds.predicates().chain(where_bounds_that_match)); debug!(?implied_bounds); - // Now require that immediate supertraits are converted, - // which will, in turn, reach indirect supertraits. + // 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) { - // Now require that immediate supertraits are converted, - // which will, in turn, reach indirect supertraits. for &(pred, span) in implied_bounds { debug!("superbound: {:?}", pred); - if let ty::PredicateKind::Clause(ty::Clause::Trait(bound)) = pred.kind().skip_binder() { + if let ty::PredicateKind::Clause(ty::Clause::Trait(bound)) = pred.kind().skip_binder() + && bound.polarity == ty::ImplPolarity::Positive + { tcx.at(span).super_predicates_of(bound.def_id()); } } |
