diff options
| author | Jubilee <workingjubilee@gmail.com> | 2024-10-04 19:19:22 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-04 19:19:22 -0700 |
| commit | 9510c7366d4a0adb24117bb312a78314963cb8d4 (patch) | |
| tree | 550c11e7dc6927d2b587760092504b4ec5774b9d /compiler/rustc_mir_transform/src/coverage/graph.rs | |
| parent | f09e5a785b6be5a6c9acacb80c44427bbb0fa2e9 (diff) | |
| parent | fd7ee484f9da99120116dc560452dd551d4c6496 (diff) | |
| download | rust-9510c7366d4a0adb24117bb312a78314963cb8d4.tar.gz rust-9510c7366d4a0adb24117bb312a78314963cb8d4.zip | |
Rollup merge of #130367 - compiler-errors:super-unconstrained, r=spastorino
Check elaborated projections from dyn don't mention unconstrained late bound lifetimes
Check that the projections that are *not* explicitly written but which we deduce from elaborating the principal of a `dyn` *also* do not reference unconstrained late-bound lifetimes, just like the ones that the user writes by hand.
That is to say, given:
```
trait Foo<T>: Bar<Assoc = T> {}
trait Bar {
type Assoc;
}
```
The type `dyn for<'a> Foo<&'a T>` (basically) elaborates to `dyn for<'a> Foo<&'a T> + for<'a> Bar<Assoc = &'a T>`[^1]. However, the `Bar` projection predicate is not well-formed, since `'a` must show up in the trait's arguments to be referenced in the term of a projection. We must error in this situation[^well], or else `dyn for<'a> Foo<&'a T>` is unsound.
We already detect this for user-written projections during HIR->rustc_middle conversion, so this largely replicates that logic using the helper functions that were already conveniently defined.
---
I'm cratering this first to see the fallout; if it's minimal or zero, then let's land it as-is. If not, the way that this is implemented is very conducive to an FCW.
---
Fixes #130347
[^1]: We don't actually elaborate it like that in rustc; we only keep the principal trait ref `Foo<&'a T>` and the projection part of `Bar<Assoc = ...>`, but it's useful to be a bit verbose here for the purpose of explaining the issue.
[^well]: Well, we could also make `dyn for<'a> Foo<&'a T>` *not* implement `for<'a> Bar<Assoc = &'a T>`, but this is inconsistent with the case where the user writes `Assoc = ...` in the type itself, and it overly complicates the implementation of trait objects' built-in impls.
Diffstat (limited to 'compiler/rustc_mir_transform/src/coverage/graph.rs')
0 files changed, 0 insertions, 0 deletions
