2020-12-03 23:06:53 -06:00
|
|
|
// Check "unused_lifetimes" lint on both async and sync functions
|
2022-05-10 14:15:30 -05:00
|
|
|
// Both cases should be diagnosed the same way.
|
2019-10-15 12:05:13 -05:00
|
|
|
|
2020-12-03 23:06:53 -06:00
|
|
|
//@ edition:2018
|
2019-10-15 12:05:13 -05:00
|
|
|
|
|
|
|
#![deny(unused_lifetimes)]
|
2020-12-03 23:06:53 -06:00
|
|
|
|
2022-05-10 14:15:30 -05:00
|
|
|
async fn async_wrong_without_args<'a>() {} //~ ERROR lifetime parameter `'a` never used
|
2020-12-03 23:06:53 -06:00
|
|
|
|
2022-05-10 14:15:30 -05:00
|
|
|
async fn async_wrong_1_lifetime<'a>(_: &i32) {} //~ ERROR lifetime parameter `'a` never used
|
2020-12-03 23:06:53 -06:00
|
|
|
|
2022-05-10 14:15:30 -05:00
|
|
|
async fn async_wrong_2_lifetimes<'a, 'b>(_: &'a i32, _: &i32) {} //~ ERROR lifetime parameter `'b` never used
|
2020-12-03 23:06:53 -06:00
|
|
|
|
|
|
|
async fn async_right_1_lifetime<'a>(_: &'a i32) {}
|
|
|
|
|
|
|
|
async fn async_right_2_lifetimes<'a, 'b>(_: &'a i32, _: &'b i32) {}
|
|
|
|
|
|
|
|
async fn async_right_trait_bound_lifetime<'a, I>(_: I)
|
|
|
|
where
|
|
|
|
I: Iterator<Item = &'a i32>
|
|
|
|
{}
|
|
|
|
|
|
|
|
fn wrong_without_args<'a>() {} //~ ERROR lifetime parameter `'a` never used
|
|
|
|
|
|
|
|
fn wrong_1_lifetime<'a>(_: &i32) {} //~ ERROR lifetime parameter `'a` never used
|
|
|
|
|
|
|
|
fn wrong_2_lifetimes<'a, 'b>(_: &'a i32, _: &i32) {} //~ ERROR lifetime parameter `'b` never used
|
|
|
|
|
|
|
|
fn right_1_lifetime<'a>(_: &'a i32) {}
|
|
|
|
|
|
|
|
fn right_2_lifetimes<'a, 'b>(_: &'a i32, _: &'b i32) {}
|
|
|
|
|
|
|
|
fn right_trait_bound_lifetime<'a, I>(_: I)
|
|
|
|
where
|
|
|
|
I: Iterator<Item = &'a i32>
|
|
|
|
{}
|
|
|
|
|
2019-10-15 12:05:13 -05:00
|
|
|
|
|
|
|
fn main() {}
|