]> git.lizzy.rs Git - rust.git/blob - src/test/ui/regions/region-bounds-on-objects-and-type-parameters.rs
Rollup merge of #57107 - mjbshaw:thread_local_test, r=nikomatsakis
[rust.git] / src / test / ui / regions / region-bounds-on-objects-and-type-parameters.rs
1 // Test related to when a region bound is required to be specified.
2
3 trait IsStatic : 'static { }
4 trait IsSend : Send { }
5 trait Is<'a> : 'a { }
6 trait Is2<'a> : 'a { }
7 trait SomeTrait { }
8
9 // Bounds on object types:
10
11 struct Foo<'a,'b,'c> { //~ ERROR parameter `'c` is never used
12     // All of these are ok, because we can derive exactly one bound:
13     a: Box<IsStatic>,
14     b: Box<Is<'static>>,
15     c: Box<Is<'a>>,
16     d: Box<IsSend>,
17     e: Box<Is<'a>+Send>, // we can derive two bounds, but one is 'static, so ok
18     f: Box<SomeTrait>,   // OK, defaults to 'static due to RFC 599.
19     g: Box<SomeTrait+'a>,
20
21     z: Box<Is<'a>+'b+'c>,
22     //~^ ERROR only a single explicit lifetime bound is permitted
23     //~| ERROR lifetime bound not satisfied
24 }
25
26 fn test<
27     'a,
28     'b,
29     A:IsStatic,
30     B:Is<'a>+Is2<'b>, // OK in a parameter, but not an object type.
31     C:'b+Is<'a>+Is2<'b>,
32     D:Is<'a>+Is2<'static>,
33     E:'a+'b           // OK in a parameter, but not an object type.
34 >() { }
35
36 fn main() { }