diff options
| author | bors <bors@rust-lang.org> | 2023-08-21 13:10:15 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-08-21 13:10:15 +0000 |
| commit | fe5f5912579d02c4e6088c89574493dfa988531a (patch) | |
| tree | 5fea91bb8cdeed115b19497711926d232245e988 /compiler | |
| parent | b131febeb0e957628ab3d01f295e7c2333acf474 (diff) | |
| parent | 31032ecb1550a402a726e9c244f6a716b214cc9d (diff) | |
| download | rust-fe5f5912579d02c4e6088c89574493dfa988531a.tar.gz rust-fe5f5912579d02c4e6088c89574493dfa988531a.zip | |
Auto merge of #115039 - jackh726:impl_compare_add_alias_obligations, r=aliemjay
Add projection obligations when comparing impl too Fixes #115033 In the test, when we ask for WF obligations of `DatasetIter<'a, ArrayBase<D>>`, we get back two important obligations: `[<D as Data>::Elem -> ?1, ?1: 'a]`. If we don't add the projection obligation, `?1` remains unconstrained. An alternative solution would be to use unnormalized obligations, where we only have one relevant obligation: `<D as Data>::Elem: 'a`. This would leave no inference vars unconstrained.
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_hir_analysis/src/check/compare_impl_item.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs index ad02ca252c4..bd0ab6463f0 100644 --- a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs +++ b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs @@ -342,9 +342,16 @@ fn compare_method_predicate_entailment<'tcx>( continue; }; for obligation in obligations { + debug!(?obligation); match obligation.predicate.kind().skip_binder() { + // We need to register Projection oblgiations too, because we may end up with + // an implied `X::Item: 'a`, which gets desugared into `X::Item = ?0`, `?0: 'a`. + // If we only register the region outlives obligation, this leads to an unconstrained var. + // See `implied_bounds_entailment_alias_var` test. ty::PredicateKind::Clause( - ty::ClauseKind::RegionOutlives(..) | ty::ClauseKind::TypeOutlives(..), + ty::ClauseKind::RegionOutlives(..) + | ty::ClauseKind::TypeOutlives(..) + | ty::ClauseKind::Projection(..), ) => ocx.register_obligation(obligation), ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(arg)) => { if wf_args_seen.insert(arg) { |
