]> git.proxmox.com Git - rustc.git/blame - src/tools/clippy/tests/ui/extra_unused_lifetimes.rs
Update upstream source from tag 'upstream/1.52.1+dfsg1'
[rustc.git] / src / tools / clippy / tests / ui / extra_unused_lifetimes.rs
CommitLineData
f20569fa
XL
1#![allow(
2 unused,
3 dead_code,
4 clippy::needless_lifetimes,
5 clippy::needless_pass_by_value,
6 clippy::needless_arbitrary_self_type
7)]
8#![warn(clippy::extra_unused_lifetimes)]
9
10fn empty() {}
11
12fn used_lt<'a>(x: &'a u8) {}
13
14fn unused_lt<'a>(x: u8) {}
15
16fn unused_lt_transitive<'a, 'b: 'a>(x: &'b u8) {
17 // 'a is useless here since it's not directly bound
18}
19
20fn lt_return<'a, 'b: 'a>(x: &'b u8) -> &'a u8 {
21 panic!()
22}
23
24fn lt_return_only<'a>() -> &'a u8 {
25 panic!()
26}
27
28fn unused_lt_blergh<'a>(x: Option<Box<dyn Send + 'a>>) {}
29
30trait Foo<'a> {
31 fn x(&self, a: &'a u8);
32}
33
34impl<'a> Foo<'a> for u8 {
35 fn x(&self, a: &'a u8) {}
36}
37
38struct Bar;
39
40impl Bar {
41 fn x<'a>(&self) {}
42}
43
44// test for #489 (used lifetimes in bounds)
45pub fn parse<'a, I: Iterator<Item = &'a str>>(_it: &mut I) {
46 unimplemented!()
47}
48pub fn parse2<'a, I>(_it: &mut I)
49where
50 I: Iterator<Item = &'a str>,
51{
52 unimplemented!()
53}
54
55struct X {
56 x: u32,
57}
58
59impl X {
60 fn self_ref_with_lifetime<'a>(&'a self) {}
61 fn explicit_self_with_lifetime<'a>(self: &'a Self) {}
62}
63
64// Methods implementing traits must have matching lifetimes
65mod issue4291 {
66 trait BadTrait {
67 fn unused_lt<'a>(x: u8) {}
68 }
69
70 impl BadTrait for () {
71 fn unused_lt<'a>(_x: u8) {}
72 }
73}
74
75fn main() {}