Rollup merge of #92710 - jackh726:issue-92280, r=nikomatsakis
Include Projections when elaborating TypeOutlives Fixes #92280 In `Elaborator`, we elaborate that `Foo<<Bar as Baz>::Assoc>: 'a` -> `<Bar as Baz>::Assoc: 'a`. This is the same rule that would be applied to any other `Param`. If there are escaping vars, we continue to do nothing. r? `@nikomatsakis`
This commit is contained in:
commit
9835b90c91
6 changed files with 92 additions and 6 deletions
|
@ -164,7 +164,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
|
|||
"cannot process registered region obligations in a snapshot"
|
||||
);
|
||||
|
||||
debug!("process_registered_region_obligations()");
|
||||
debug!(?param_env, "process_registered_region_obligations()");
|
||||
|
||||
let my_region_obligations = self.take_registered_region_obligations();
|
||||
|
||||
|
@ -356,6 +356,8 @@ where
|
|||
let trait_bounds: Vec<_> =
|
||||
self.verify_bound.projection_declared_bounds_from_trait(projection_ty).collect();
|
||||
|
||||
debug!(?trait_bounds);
|
||||
|
||||
// Compute the bounds we can derive from the environment. This
|
||||
// is an "approximate" match -- in some cases, these bounds
|
||||
// may not apply.
|
||||
|
|
|
@ -241,10 +241,19 @@ impl<'tcx> Elaborator<'tcx> {
|
|||
|
||||
Component::UnresolvedInferenceVariable(_) => None,
|
||||
|
||||
Component::Projection(_) | Component::EscapingProjection(_) => {
|
||||
// We can probably do more here. This
|
||||
// corresponds to a case like `<T as
|
||||
// Foo<'a>>::U: 'b`.
|
||||
Component::Projection(projection) => {
|
||||
// We might end up here if we have `Foo<<Bar as Baz>::Assoc>: 'a`.
|
||||
// With this, we can deduce that `<Bar as Baz>::Assoc: 'a`.
|
||||
let ty =
|
||||
tcx.mk_projection(projection.item_def_id, projection.substs);
|
||||
Some(ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(
|
||||
ty, r_min,
|
||||
)))
|
||||
}
|
||||
|
||||
Component::EscapingProjection(_) => {
|
||||
// We might be able to do more here, but we don't
|
||||
// want to deal with escaping vars right now.
|
||||
None
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue