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