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.
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.
11 #![deny(late_bound_lifetime_arguments)]
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 {} }
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)>)
26 fn early_tricky_implicit<'a>(_: fn(&u8),
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
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
74 S::early_tricky_explicit::<'static>(loop {}, loop {}); // OK
75 S::early_tricky_implicit::<'static>(loop {}, loop {}); // OK
79 S::late_early::<'static>(S, &0);
80 //~^ ERROR cannot specify lifetime arguments explicitly
81 //~| WARN this was previously accepted
83 S::late_implicit_early::<'static>(S, &0);
84 //~^ ERROR cannot specify lifetime arguments explicitly
85 //~| WARN this was previously accepted
88 fn lint_not_inference_error() {
89 fn f<'early, 'late, T: 'early>() {}
91 // Make sure `u8` is substituted and not replaced with an inference variable
93 //~^ ERROR cannot specify lifetime arguments explicitly
94 //~| WARN this was previously accepted