about summary refs log tree commit diff
path: root/tests/ui/lifetimes/constructor-lifetime-early-binding-error.rs
blob: 2d5a444a942d5da8adc3788c54d7da7ce5fd69cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
//! Tests that all lifetime parameters in struct (`S`) and enum (`E`) constructors are
//! treated as early bound, similar to associated items, rather than late bound as in manual
//! constructors.

struct S<'a, 'b>(&'a u8, &'b u8);
enum E<'a, 'b> {
    V(&'a u8),
    U(&'b u8),
}

fn main() {
    S(&0, &0); // OK
    S::<'static>(&0, &0);
    //~^ ERROR struct takes 2 lifetime arguments
    S::<'static, 'static, 'static>(&0, &0);
    //~^ ERROR struct takes 2 lifetime arguments
    E::V(&0); // OK
    E::V::<'static>(&0);
    //~^ ERROR enum takes 2 lifetime arguments
    E::V::<'static, 'static, 'static>(&0);
    //~^ ERROR enum takes 2 lifetime arguments
}