1 // Check "unused_lifetimes" lint on both async and sync functions
5 #![deny(unused_lifetimes)]
8 // Async part with unused lifetimes
10 // Even wrong cases don't cause errors because async functions are desugared with all lifetimes
11 // involved in the signature. So, we cannot predict what lifetimes are unused in async function.
12 async fn async_wrong_without_args<'a>() {}
14 async fn async_wrong_1_lifetime<'a>(_: &i32) {}
16 async fn async_wrong_2_lifetimes<'a, 'b>(_: &'a i32, _: &i32) {}
18 async fn async_right_1_lifetime<'a>(_: &'a i32) {}
20 async fn async_right_2_lifetimes<'a, 'b>(_: &'a i32, _: &'b i32) {}
22 async fn async_right_trait_bound_lifetime<'a, I>(_: I)
24 I: Iterator<Item = &'a i32>
28 // Sync part with unused lifetimes
30 // These functions are compiled as supposed
31 fn wrong_without_args<'a>() {} //~ ERROR lifetime parameter `'a` never used
33 fn wrong_1_lifetime<'a>(_: &i32) {} //~ ERROR lifetime parameter `'a` never used
35 fn wrong_2_lifetimes<'a, 'b>(_: &'a i32, _: &i32) {} //~ ERROR lifetime parameter `'b` never used
37 fn right_1_lifetime<'a>(_: &'a i32) {}
39 fn right_2_lifetimes<'a, 'b>(_: &'a i32, _: &'b i32) {}
41 fn right_trait_bound_lifetime<'a, I>(_: I)
43 I: Iterator<Item = &'a i32>