]> git.lizzy.rs Git - rust.git/blob - src/test/ui/regions/regions-implied-bounds-projection-gap-hr-1.rs
Auto merge of #54624 - arielb1:evaluate-outlives, r=nikomatsakis
[rust.git] / src / test / ui / regions / regions-implied-bounds-projection-gap-hr-1.rs
1 // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // The "projection gap" is particularly "fun" around higher-ranked
12 // projections.  This is because the current code is hard-coded to say
13 // that a projection that contains escaping regions, like `<T as
14 // Trait2<'y, 'z>>::Foo` where `'z` is bound, can only be found to
15 // outlive a region if all components that appear free (`'y`, where)
16 // outlive that region. However, we DON'T add those components to the
17 // implied bounds set, but rather we treat projections with escaping
18 // regions as opaque entities, just like projections without escaping
19 // regions.
20
21 trait Trait1<T> { }
22
23 trait Trait2<'a, 'b> {
24     type Foo;
25 }
26
27 // As a side-effect of the conservative process above, the type of
28 // this argument `t` is not automatically considered well-formed,
29 // since for it to be WF, we would need to know that `'y: 'x`, but we
30 // do not infer that.
31 fn callee<'x, 'y, T>(t: &'x for<'z> Trait1< <T as Trait2<'y, 'z>>::Foo >)
32     //~^ ERROR reference has a longer lifetime than the data it references
33 {
34 }
35
36 fn main() { }