]> git.lizzy.rs Git - rust.git/blob - tests/ui/async-await/unused-lifetime.rs
Rollup merge of #106625 - Swatinem:ref/cov6, r=nagisa
[rust.git] / tests / ui / async-await / unused-lifetime.rs
1 // Check "unused_lifetimes" lint on both async and sync functions
2 // Both cases should be diagnosed the same way.
3
4 // edition:2018
5
6 #![deny(unused_lifetimes)]
7
8 async fn async_wrong_without_args<'a>() {} //~ ERROR lifetime parameter `'a` never used
9
10 async fn async_wrong_1_lifetime<'a>(_: &i32) {} //~ ERROR lifetime parameter `'a` never used
11
12 async fn async_wrong_2_lifetimes<'a, 'b>(_: &'a i32, _: &i32) {} //~ ERROR lifetime parameter `'b` never used
13
14 async fn async_right_1_lifetime<'a>(_: &'a i32) {}
15
16 async fn async_right_2_lifetimes<'a, 'b>(_: &'a i32, _: &'b i32) {}
17
18 async fn async_right_trait_bound_lifetime<'a, I>(_: I)
19 where
20     I: Iterator<Item = &'a i32>
21 {}
22
23 fn wrong_without_args<'a>() {} //~ ERROR lifetime parameter `'a` never used
24
25 fn wrong_1_lifetime<'a>(_: &i32) {} //~ ERROR lifetime parameter `'a` never used
26
27 fn wrong_2_lifetimes<'a, 'b>(_: &'a i32, _: &i32) {} //~ ERROR lifetime parameter `'b` never used
28
29 fn right_1_lifetime<'a>(_: &'a i32) {}
30
31 fn right_2_lifetimes<'a, 'b>(_: &'a i32, _: &'b i32) {}
32
33 fn right_trait_bound_lifetime<'a, I>(_: I)
34 where
35     I: Iterator<Item = &'a i32>
36 {}
37
38
39 fn main() {}