2019-06-25 09:55:32 -05:00
|
|
|
// edition:2018
|
|
|
|
|
|
|
|
// Test that a feature gate is needed to use `impl Trait` as the
|
|
|
|
// return type of an async.
|
|
|
|
|
|
|
|
trait Trait<'a> { }
|
|
|
|
impl<T> Trait<'_> for T { }
|
|
|
|
|
2021-09-23 10:21:01 -05:00
|
|
|
// Fails to recognize that both 'a and 'b are mentioned and should thus be accepted
|
|
|
|
async fn async_ret_impl_trait3<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a> + 'b {
|
2022-04-01 12:13:25 -05:00
|
|
|
//~^ ERROR lifetime may not live long enough
|
2021-09-23 10:21:01 -05:00
|
|
|
(a, b)
|
|
|
|
}
|
|
|
|
|
2019-06-25 09:55:32 -05:00
|
|
|
// Only `'a` permitted in return type, not `'b`.
|
|
|
|
async fn async_ret_impl_trait1<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a> {
|
2021-09-23 10:21:01 -05:00
|
|
|
//~^ ERROR captures lifetime that does not appear in bounds
|
2019-06-25 09:55:32 -05:00
|
|
|
(a, b)
|
|
|
|
}
|
|
|
|
|
2019-06-29 05:52:35 -05:00
|
|
|
// As above, but `'b: 'a`, so return type can be inferred to `(&'a u8,
|
2019-06-25 09:55:32 -05:00
|
|
|
// &'a u8)`.
|
|
|
|
async fn async_ret_impl_trait2<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a>
|
|
|
|
where
|
|
|
|
'b: 'a,
|
|
|
|
{
|
|
|
|
(a, b)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
}
|