about summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser/pat.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-07-29 22:58:21 +0000
committerbors <bors@rust-lang.org>2023-07-29 22:58:21 +0000
commitb969b830aa8cac0ded5cced9e4a47e124183a6ee (patch)
tree6cb91960ea7f815879f1fd99ce92c61929f6ae35 /compiler/rustc_parse/src/parser/pat.rs
parent32303b219d4dffa447aa606bc11c7a648f44a862 (diff)
parent744e7709396cba216400b5d5d78d25aa0663399b (diff)
downloadrust-b969b830aa8cac0ded5cced9e4a47e124183a6ee.tar.gz
rust-b969b830aa8cac0ded5cced9e4a47e124183a6ee.zip
Auto merge of #113704 - compiler-errors:rpitit-assumed-wf-inherit, r=spastorino
Make RPITITs inherit the `assumed_wf_types` of their parent method

... and then move the RPITIT well-formedness check to just use the regular logic of wfchecking an associated type.

---

We need to inherit the `assumed_wf_types` of the RPITIT's parent function in order for the given code to be considered well-formed:

```rust
trait Foo {
  fn bar<'a, T>(_: &'a T) -> impl Iterator<Output = &'a T>;
}
```

Since for `&'a T` to be WF, we need `T: 'a`.

In order for this to work for late-bound lifetimes, we need to do some additional mapping of any late-bound lifetimes captured by these assumed wf types. This is because within the body of the function (and thus in the `assumed_wf_types`), they're represented as `ReFree` variants of the original late-bound lifetimes declared in the function's generics, but in the RPITIT's GAT, they're represented as "reified" `ReEarlyBound` vars (duplicated during opaque type lowering). Luckily, the mapping between these two is already [stored in the opaque](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/hir/struct.OpaqueTy.html#structfield.lifetime_mapping).

Fixes #113796
Diffstat (limited to 'compiler/rustc_parse/src/parser/pat.rs')
0 files changed, 0 insertions, 0 deletions