Adapt tests from #105258
This commit is contained in:
parent
473c88dfb6
commit
8ad5ea7b01
@ -1,15 +1,61 @@
|
||||
error: return type captures more lifetimes than trait definition
|
||||
--> $DIR/signature-mismatch.rs:17:47
|
||||
--> $DIR/signature-mismatch.rs:36:47
|
||||
|
|
||||
LL | fn async_fn<'a>(&self, buff: &'a [u8]) -> impl Future<Output = Vec<u8>> + 'a {
|
||||
| -- this lifetime was captured ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: hidden type must only reference lifetimes captured by this impl trait
|
||||
--> $DIR/signature-mismatch.rs:11:40
|
||||
--> $DIR/signature-mismatch.rs:17:40
|
||||
|
|
||||
LL | fn async_fn(&self, buff: &[u8]) -> impl Future<Output = Vec<u8>>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
= note: hidden type inferred to be `impl Future<Output = Vec<u8>> + 'a`
|
||||
|
||||
error: aborting due to previous error
|
||||
error: return type captures more lifetimes than trait definition
|
||||
--> $DIR/signature-mismatch.rs:41:57
|
||||
|
|
||||
LL | fn async_fn_early<'a: 'a>(&self, buff: &'a [u8]) -> impl Future<Output = Vec<u8>> + 'a {
|
||||
| -- this lifetime was captured ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: hidden type must only reference lifetimes captured by this impl trait
|
||||
--> $DIR/signature-mismatch.rs:18:57
|
||||
|
|
||||
LL | fn async_fn_early<'a: 'a>(&self, buff: &'a [u8]) -> impl Future<Output = Vec<u8>>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
= note: hidden type inferred to be `impl Future<Output = Vec<u8>> + 'a`
|
||||
|
||||
error: return type captures more lifetimes than trait definition
|
||||
--> $DIR/signature-mismatch.rs:49:10
|
||||
|
|
||||
LL | fn async_fn_multiple<'a, 'b>(
|
||||
| -- this lifetime was captured
|
||||
...
|
||||
LL | ) -> impl Future<Output = Vec<u8>> + Captures2<'a, 'b> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: hidden type must only reference lifetimes captured by this impl trait
|
||||
--> $DIR/signature-mismatch.rs:20:12
|
||||
|
|
||||
LL | -> impl Future<Output = Vec<u8>> + Captures<'a>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
= note: hidden type inferred to be `impl Future<Output = Vec<u8>> + Captures2<'a, 'b>`
|
||||
|
||||
error[E0309]: the parameter type `T` may not live long enough
|
||||
--> $DIR/signature-mismatch.rs:58:10
|
||||
|
|
||||
LL | ) -> impl Future<Output = Vec<u8>> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `impl Future<Output = Vec<u8>>` will meet its required lifetime bounds...
|
||||
|
|
||||
note: ...that is required by this bound
|
||||
--> $DIR/signature-mismatch.rs:25:42
|
||||
|
|
||||
LL | ) -> impl Future<Output = Vec<u8>> + 'a;
|
||||
| ^^
|
||||
help: consider adding an explicit lifetime bound...
|
||||
|
|
||||
LL | fn async_fn_reduce_outlive<'a, 'b, T: 'a>(
|
||||
| ++++
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0309`.
|
||||
|
@ -1,15 +1,61 @@
|
||||
error: return type captures more lifetimes than trait definition
|
||||
--> $DIR/signature-mismatch.rs:17:47
|
||||
--> $DIR/signature-mismatch.rs:36:47
|
||||
|
|
||||
LL | fn async_fn<'a>(&self, buff: &'a [u8]) -> impl Future<Output = Vec<u8>> + 'a {
|
||||
| -- this lifetime was captured ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: hidden type must only reference lifetimes captured by this impl trait
|
||||
--> $DIR/signature-mismatch.rs:11:40
|
||||
--> $DIR/signature-mismatch.rs:17:40
|
||||
|
|
||||
LL | fn async_fn(&self, buff: &[u8]) -> impl Future<Output = Vec<u8>>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
= note: hidden type inferred to be `impl Future<Output = Vec<u8>> + 'a`
|
||||
|
||||
error: aborting due to previous error
|
||||
error: return type captures more lifetimes than trait definition
|
||||
--> $DIR/signature-mismatch.rs:41:57
|
||||
|
|
||||
LL | fn async_fn_early<'a: 'a>(&self, buff: &'a [u8]) -> impl Future<Output = Vec<u8>> + 'a {
|
||||
| -- this lifetime was captured ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: hidden type must only reference lifetimes captured by this impl trait
|
||||
--> $DIR/signature-mismatch.rs:18:57
|
||||
|
|
||||
LL | fn async_fn_early<'a: 'a>(&self, buff: &'a [u8]) -> impl Future<Output = Vec<u8>>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
= note: hidden type inferred to be `impl Future<Output = Vec<u8>> + 'a`
|
||||
|
||||
error: return type captures more lifetimes than trait definition
|
||||
--> $DIR/signature-mismatch.rs:49:10
|
||||
|
|
||||
LL | fn async_fn_multiple<'a, 'b>(
|
||||
| -- this lifetime was captured
|
||||
...
|
||||
LL | ) -> impl Future<Output = Vec<u8>> + Captures2<'a, 'b> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: hidden type must only reference lifetimes captured by this impl trait
|
||||
--> $DIR/signature-mismatch.rs:20:12
|
||||
|
|
||||
LL | -> impl Future<Output = Vec<u8>> + Captures<'a>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
= note: hidden type inferred to be `impl Future<Output = Vec<u8>> + Captures2<'a, 'b>`
|
||||
|
||||
error[E0309]: the parameter type `T` may not live long enough
|
||||
--> $DIR/signature-mismatch.rs:58:10
|
||||
|
|
||||
LL | ) -> impl Future<Output = Vec<u8>> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `impl Future<Output = Vec<u8>>` will meet its required lifetime bounds...
|
||||
|
|
||||
note: ...that is required by this bound
|
||||
--> $DIR/signature-mismatch.rs:25:42
|
||||
|
|
||||
LL | ) -> impl Future<Output = Vec<u8>> + 'a;
|
||||
| ^^
|
||||
help: consider adding an explicit lifetime bound...
|
||||
|
|
||||
LL | fn async_fn_reduce_outlive<'a, 'b, T: 'a>(
|
||||
| ++++
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0309`.
|
||||
|
@ -7,8 +7,27 @@
|
||||
|
||||
use std::future::Future;
|
||||
|
||||
trait Captures<'a> {}
|
||||
impl<T> Captures<'_> for T {}
|
||||
|
||||
trait Captures2<'a, 'b> {}
|
||||
impl<T> Captures2<'_, '_> for T {}
|
||||
|
||||
pub trait AsyncTrait {
|
||||
fn async_fn(&self, buff: &[u8]) -> impl Future<Output = Vec<u8>>;
|
||||
fn async_fn_early<'a: 'a>(&self, buff: &'a [u8]) -> impl Future<Output = Vec<u8>>;
|
||||
fn async_fn_multiple<'a>(&'a self, buff: &[u8])
|
||||
-> impl Future<Output = Vec<u8>> + Captures<'a>;
|
||||
fn async_fn_reduce_outlive<'a, T>(
|
||||
&'a self,
|
||||
buff: &[u8],
|
||||
t: T,
|
||||
) -> impl Future<Output = Vec<u8>> + 'a;
|
||||
fn async_fn_reduce<'a, T>(
|
||||
&'a self,
|
||||
buff: &[u8],
|
||||
t: T,
|
||||
) -> impl Future<Output = Vec<u8>> + Captures<'a>;
|
||||
}
|
||||
|
||||
pub struct Struct;
|
||||
@ -18,6 +37,40 @@ impl AsyncTrait for Struct {
|
||||
//~^ ERROR return type captures more lifetimes than trait definition
|
||||
async move { buff.to_vec() }
|
||||
}
|
||||
|
||||
fn async_fn_early<'a: 'a>(&self, buff: &'a [u8]) -> impl Future<Output = Vec<u8>> + 'a {
|
||||
//~^ ERROR return type captures more lifetimes than trait definition
|
||||
async move { buff.to_vec() }
|
||||
}
|
||||
|
||||
fn async_fn_multiple<'a, 'b>(
|
||||
&'a self,
|
||||
buff: &'b [u8],
|
||||
) -> impl Future<Output = Vec<u8>> + Captures2<'a, 'b> {
|
||||
//~^ ERROR return type captures more lifetimes than trait definition
|
||||
async move { buff.to_vec() }
|
||||
}
|
||||
|
||||
fn async_fn_reduce_outlive<'a, 'b, T>(
|
||||
&'a self,
|
||||
buff: &'b [u8],
|
||||
t: T,
|
||||
) -> impl Future<Output = Vec<u8>> {
|
||||
//~^ ERROR the parameter type `T` may not live long enough
|
||||
async move {
|
||||
let _t = t;
|
||||
vec![]
|
||||
}
|
||||
}
|
||||
|
||||
// OK: We remove the `Captures<'a>`, providing a guarantee that we don't capture `'a`,
|
||||
// but we still fulfill the `Captures<'a>` trait bound.
|
||||
fn async_fn_reduce<'a, 'b, T>(&'a self, buff: &'b [u8], t: T) -> impl Future<Output = Vec<u8>> {
|
||||
async move {
|
||||
let _t = t;
|
||||
vec![]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
Loading…
x
Reference in New Issue
Block a user