]> git.lizzy.rs Git - rust.git/blob - src/test/ui/methods/method-call-lifetime-args-fail.rs
move an `assert!` to the right place
[rust.git] / src / test / ui / methods / method-call-lifetime-args-fail.rs
1 struct S;
2
3 impl S {
4     fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {}
5     fn late_implicit(self, _: &u8, _: &u8) {}
6     fn early<'a, 'b>(self) -> (&'a u8, &'b u8) { loop {} }
7     fn late_early<'a, 'b>(self, _: &'a u8) -> &'b u8 { loop {} }
8     fn late_implicit_early<'b>(self, _: &u8) -> &'b u8 { loop {} }
9     fn late_implicit_self_early<'b>(&self) -> &'b u8 { loop {} }
10     fn late_unused_early<'a, 'b>(self) -> &'b u8 { loop {} }
11     fn life_and_type<'a, T>(self) -> &'a T { loop {} }
12 }
13
14 fn method_call() {
15     S.early(); // OK
16     S.early::<'static>();
17     //~^ ERROR this associated function takes 2 lifetime arguments but 1 lifetime argument
18     S.early::<'static, 'static, 'static>();
19     //~^ ERROR this associated function takes 2 lifetime arguments but 3 lifetime arguments were supplied
20     let _: &u8 = S.life_and_type::<'static>();
21     S.life_and_type::<u8>();
22     S.life_and_type::<'static, u8>();
23 }
24
25 fn ufcs() {
26     S::late(S, &0, &0); // OK
27     S::late::<'static>(S, &0, &0);
28     //~^ ERROR cannot specify lifetime arguments explicitly
29     S::late::<'static, 'static>(S, &0, &0);
30     //~^ ERROR cannot specify lifetime arguments explicitly
31     S::late::<'static, 'static, 'static>(S, &0, &0);
32     //~^ ERROR cannot specify lifetime arguments explicitly
33     S::late_early(S, &0); // OK
34     S::late_early::<'static, 'static>(S, &0);
35     //~^ ERROR cannot specify lifetime arguments explicitly
36     S::late_early::<'static, 'static, 'static>(S, &0);
37     //~^ ERROR cannot specify lifetime arguments explicitly
38
39     S::late_implicit(S, &0, &0); // OK
40     S::late_implicit::<'static>(S, &0, &0);
41     //~^ ERROR cannot specify lifetime arguments explicitly
42     S::late_implicit::<'static, 'static>(S, &0, &0);
43     //~^ ERROR cannot specify lifetime arguments explicitly
44     S::late_implicit::<'static, 'static, 'static>(S, &0, &0);
45     //~^ ERROR cannot specify lifetime arguments explicitly
46     S::late_implicit_early(S, &0); // OK
47     S::late_implicit_early::<'static, 'static>(S, &0);
48     //~^ ERROR cannot specify lifetime arguments explicitly
49     S::late_implicit_early::<'static, 'static, 'static>(S, &0);
50     //~^ ERROR cannot specify lifetime arguments explicitly
51     S::late_implicit_self_early(&S); // OK
52     S::late_implicit_self_early::<'static, 'static>(&S);
53     //~^ ERROR cannot specify lifetime arguments explicitly
54     S::late_implicit_self_early::<'static, 'static, 'static>(&S);
55     //~^ ERROR cannot specify lifetime arguments explicitly
56     S::late_unused_early(S); // OK
57     S::late_unused_early::<'static, 'static>(S);
58     //~^ ERROR cannot specify lifetime arguments explicitly
59     S::late_unused_early::<'static, 'static, 'static>(S);
60     //~^ ERROR cannot specify lifetime arguments explicitly
61
62     S::early(S); // OK
63     S::early::<'static>(S);
64     //~^ ERROR this associated function takes 2 lifetime arguments but 1 lifetime argument
65     S::early::<'static, 'static, 'static>(S);
66     //~^ ERROR this associated function takes 2 lifetime arguments but 3 lifetime arguments were supplied
67     let _: &u8 = S::life_and_type::<'static>(S);
68     S::life_and_type::<u8>(S);
69     S::life_and_type::<'static, u8>(S);
70 }
71
72 fn main() {}