]> git.lizzy.rs Git - rust.git/blob - tests/ui/methods/method-call-lifetime-args-lint-fail.rs
Rollup merge of #106709 - khuey:disable_split_dwarf_inlining_by_default, r=davidtwco
[rust.git] / tests / ui / methods / method-call-lifetime-args-lint-fail.rs
1 #![deny(late_bound_lifetime_arguments)]
2 #![allow(unused)]
3
4 struct S;
5
6 impl S {
7     fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {}
8     fn late_implicit(self, _: &u8, _: &u8) {}
9     fn late_early<'a, 'b>(self, _: &'a u8) -> &'b u8 { loop {} }
10     fn late_implicit_early<'b>(self, _: &u8) -> &'b u8 { loop {} }
11
12     // 'late lifetimes here belong to nested types not to the tested functions.
13     fn early_tricky_explicit<'a>(_: for<'late> fn(&'late u8),
14                                  _: Box<dyn for<'late> Fn(&'late u8)>)
15                                  -> &'a u8 { loop {} }
16     fn early_tricky_implicit<'a>(_: fn(&u8),
17                                  _: Box<dyn Fn(&u8)>)
18                                  -> &'a u8 { loop {} }
19 }
20
21 fn method_call() {
22     S.late(&0, &0); // OK
23     S.late::<'static>(&0, &0);
24     //~^ ERROR cannot specify lifetime arguments explicitly
25     //~| WARN this was previously accepted
26     S.late::<'static, 'static>(&0, &0);
27     //~^ ERROR cannot specify lifetime arguments explicitly
28     //~| WARN this was previously accepted
29     S.late::<'static, 'static, 'static>(&0, &0);
30     //~^ ERROR cannot specify lifetime arguments explicitly
31     //~| WARN this was previously accepted
32     S.late_early(&0); // OK
33     S.late_early::<'static>(&0);
34     //~^ ERROR cannot specify lifetime arguments explicitly
35     //~| WARN this was previously accepted
36     S.late_early::<'static, 'static>(&0);
37     //~^ ERROR cannot specify lifetime arguments explicitly
38     //~| WARN this was previously accepted
39     S.late_early::<'static, 'static, 'static>(&0);
40     //~^ ERROR cannot specify lifetime arguments explicitly
41     //~| WARN this was previously accepted
42
43     S.late_implicit(&0, &0); // OK
44     S.late_implicit::<'static>(&0, &0);
45     //~^ ERROR cannot specify lifetime arguments explicitly
46     //~| WARN this was previously accepted
47     S.late_implicit::<'static, 'static>(&0, &0);
48     //~^ ERROR cannot specify lifetime arguments explicitly
49     //~| WARN this was previously accepted
50     S.late_implicit::<'static, 'static, 'static>(&0, &0);
51     //~^ ERROR cannot specify lifetime arguments explicitly
52     //~| WARN this was previously accepted
53     S.late_implicit_early(&0); // OK
54     S.late_implicit_early::<'static>(&0);
55     //~^ ERROR cannot specify lifetime arguments explicitly
56     //~| WARN this was previously accepted
57     S.late_implicit_early::<'static, 'static>(&0);
58     //~^ ERROR cannot specify lifetime arguments explicitly
59     //~| WARN this was previously accepted
60     S.late_implicit_early::<'static, 'static, 'static>(&0);
61     //~^ ERROR cannot specify lifetime arguments explicitly
62     //~| WARN this was previously accepted
63
64     S::early_tricky_explicit::<'static>(loop {}, loop {}); // OK
65     S::early_tricky_implicit::<'static>(loop {}, loop {}); // OK
66 }
67
68 fn ufcs() {
69     S::late_early::<'static>(S, &0);
70     //~^ ERROR cannot specify lifetime arguments explicitly
71     //~| WARN this was previously accepted
72
73     S::late_implicit_early::<'static>(S, &0);
74     //~^ ERROR cannot specify lifetime arguments explicitly
75     //~| WARN this was previously accepted
76 }
77
78 fn lint_not_inference_error() {
79     fn f<'early, 'late, T: 'early>() {}
80
81     // Make sure `u8` is substituted and not replaced with an inference variable
82     f::<'static, u8>;
83     //~^ ERROR cannot specify lifetime arguments explicitly
84     //~| WARN this was previously accepted
85 }
86
87 fn main() {}