rust/compiler/rustc_ty_utils/src
bors bf62436bce Auto merge of #114602 - compiler-errors:rpit-outlives-sadness, r=oli-obk
Map RPIT duplicated lifetimes back to fn captured lifetimes

Use the [`lifetime_mapping`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/hir/struct.OpaqueTy.html#structfield.lifetime_mapping) to map an RPIT's captured lifetimes back to the early- or late-bound lifetimes from its parent function. We may be going thru several layers of mapping, since opaques can be nested, so we introduce `TyCtxt::map_rpit_lifetime_to_fn_lifetime` to loop through several opaques worth of mapping, and handle turning it into a `ty::Region` as well.

We can then use this instead of the identity substs for RPITs in `check_opaque_meets_bounds` to address #114285.

We can then also use `map_rpit_lifetime_to_fn_lifetime` to properly install bidirectional-outlives predicates for both RPITs and RPITITs. This addresses #114601.

I based this on #114574, but I don't actually know how much of that PR we still need, so some code may be redundant now... 🤷

---

Fixes #114597
Fixes #114579
Fixes #114285

Also fixes #114601, since it turns out we had other bugs with RPITITs and their duplicated lifetime params 😅.

Supersedes #114574

r? `@oli-obk`
2023-08-08 13:03:10 +00:00
..
abi.rs refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00
assoc.rs tighten span slightly for synthetic item 2023-07-27 22:20:32 +00:00
common_traits.rs Move expansion of query macros in rustc_middle to rustc_middle::query 2023-05-15 08:49:13 +02:00
consts.rs Rollup merge of #113539 - agnarrarendelle:master, r=workingjubilee 2023-07-17 00:14:05 +02:00
errors.rs Re-use error code for duplicate error 2023-06-22 15:51:14 +00:00
implied_bounds.rs Auto merge of #114602 - compiler-errors:rpit-outlives-sadness, r=oli-obk 2023-08-08 13:03:10 +00:00
instance.rs Make everything builtin! 2023-07-25 16:08:58 +00:00
layout.rs Use upvar_tys in more places, make it a list 2023-08-01 23:19:31 +00:00
layout_sanity_check.rs Revert "Auto merge of #113166 - moulins:ref-niches-initial, r=oli-obk" 2023-07-21 22:35:57 -07:00
lib.rs Take RPITITs inherit the assumed_wf_types of their parent fn 2023-07-29 21:19:33 +00:00
needs_drop.rs Use upvar_tys in more places, make it a list 2023-08-01 23:19:31 +00:00
opaque_types.rs Store the laziness of type aliases in the DefKind 2023-08-07 15:54:31 +02:00
representability.rs refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00
structural_match.rs Move expansion of query macros in rustc_middle to rustc_middle::query 2023-05-15 08:49:13 +02:00
ty.rs Fix a comment 2023-08-01 23:10:38 +00:00