]> git.lizzy.rs Git - rust.git/blob - tests/ui/unused_lt.rs
Merge remote-tracking branch 'upstream/master'
[rust.git] / tests / ui / unused_lt.rs
1 // Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution.
3 //
4 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7 // option. This file may not be copied, modified, or distributed
8 // except according to those terms.
9
10
11
12
13 #![allow(unused, dead_code, clippy::needless_lifetimes, clippy::needless_pass_by_value, clippy::trivially_copy_pass_by_ref)]
14 #![warn(clippy::extra_unused_lifetimes)]
15
16 fn empty() {
17
18 }
19
20
21 fn used_lt<'a>(x: &'a u8) {
22
23 }
24
25
26 fn unused_lt<'a>(x: u8) {
27
28 }
29
30 fn unused_lt_transitive<'a, 'b: 'a>(x: &'b u8) {
31     // 'a is useless here since it's not directly bound
32 }
33
34 fn lt_return<'a, 'b: 'a>(x: &'b u8) -> &'a u8 {
35     panic!()
36 }
37
38 fn lt_return_only<'a>() -> &'a u8 {
39     panic!()
40 }
41
42 fn unused_lt_blergh<'a>(x: Option<Box<Send+'a>>) {
43
44 }
45
46
47 trait Foo<'a> {
48     fn x(&self, a: &'a u8);
49 }
50
51 impl<'a> Foo<'a> for u8 {
52     fn x(&self, a: &'a u8) {
53
54     }
55 }
56
57 struct Bar;
58
59 impl Bar {
60     fn x<'a>(&self) {}
61 }
62
63 // test for #489 (used lifetimes in bounds)
64 pub fn parse<'a, I: Iterator<Item=&'a str>>(_it: &mut I) {
65     unimplemented!()
66 }
67 pub fn parse2<'a, I>(_it: &mut I) where I: Iterator<Item=&'a str>{
68     unimplemented!()
69 }
70
71 struct X { x: u32 }
72
73 impl X {
74     fn self_ref_with_lifetime<'a>(&'a self) {}
75     fn explicit_self_with_lifetime<'a>(self: &'a Self) {}
76 }
77
78 fn main() {
79
80 }