]> git.lizzy.rs Git - rust.git/blob - tests/ui/regions/regions-implied-bounds-projection-gap-hr-1.rs
internally change regions to be covariant
[rust.git] / tests / ui / regions / regions-implied-bounds-projection-gap-hr-1.rs
1 // The "projection gap" is particularly "fun" around higher-ranked
2 // projections.  This is because the current code is hard-coded to say
3 // that a projection that contains escaping regions, like `<T as
4 // Trait2<'y, 'z>>::Foo` where `'z` is bound, can only be found to
5 // outlive a region if all components that appear free (`'y`, where)
6 // outlive that region. However, we DON'T add those components to the
7 // implied bounds set, but rather we treat projections with escaping
8 // regions as opaque entities, just like projections without escaping
9 // regions.
10
11 trait Trait1<T> { }
12
13 trait Trait2<'a, 'b> {
14     type Foo;
15 }
16
17 // As a side-effect of the conservative process above, the type of
18 // this argument `t` is not automatically considered well-formed,
19 // since for it to be WF, we would need to know that `'y: 'x`, but we
20 // do not infer that.
21 fn callee<'x, 'y, T>(t: &'x dyn for<'z> Trait1< <T as Trait2<'y, 'z>>::Foo >)
22     //~^ ERROR the trait bound `for<'z> T: Trait2<'y, 'z>` is not satisfied
23     //~| ERROR the trait bound `for<'z> T: Trait2<'y, 'z>` is not satisfied
24 {
25 }
26
27 fn main() { }