-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't duplicate anonymous lifetimes for async fn in traits
- Loading branch information
1 parent
43a7802
commit 4e05cfb
Showing
6 changed files
with
164 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
tests/ui/async-await/return-type-notation/issue-110963-early.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// edition: 2021 | ||
// known-bug: #110963 | ||
|
||
#![feature(return_type_notation)] | ||
#![feature(async_fn_in_trait)] | ||
|
||
trait HealthCheck { | ||
async fn check<'a: 'a>(&'a mut self) -> bool; | ||
} | ||
|
||
async fn do_health_check_par<HC>(hc: HC) | ||
where | ||
HC: HealthCheck<check(): Send> + Send + 'static, | ||
{ | ||
spawn(async move { | ||
let mut hc = hc; | ||
if !hc.check().await { | ||
log_health_check_failure().await; | ||
} | ||
}); | ||
} | ||
|
||
async fn log_health_check_failure() {} | ||
|
||
fn main() {} | ||
|
||
// Fake tokio spawn | ||
|
||
use std::future::Future; | ||
use std::pin::Pin; | ||
use std::task::{Context, Poll}; | ||
|
||
fn spawn<F>(future: F) -> JoinHandle | ||
where | ||
F: Future + Send + 'static, | ||
F::Output: Send + 'static, | ||
{ | ||
loop {} | ||
} | ||
|
||
struct JoinHandle; | ||
|
||
impl Future for JoinHandle { | ||
type Output = (); | ||
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { | ||
loop {} | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
tests/ui/async-await/return-type-notation/issue-110963-early.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/issue-110963-early.rs:4:12 | ||
| | ||
LL | #![feature(return_type_notation)] | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information | ||
= note: `#[warn(incomplete_features)]` on by default | ||
|
||
warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/issue-110963-early.rs:5:12 | ||
| | ||
LL | #![feature(async_fn_in_trait)] | ||
| ^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information | ||
|
||
error: higher-ranked lifetime error | ||
--> $DIR/issue-110963-early.rs:15:5 | ||
| | ||
LL | / spawn(async move { | ||
LL | | let mut hc = hc; | ||
LL | | if !hc.check().await { | ||
LL | | log_health_check_failure().await; | ||
LL | | } | ||
LL | | }); | ||
| |______^ | ||
| | ||
= note: could not prove `[async block@$DIR/issue-110963-early.rs:15:11: 20:6]: Send` | ||
|
||
error: higher-ranked lifetime error | ||
--> $DIR/issue-110963-early.rs:15:5 | ||
| | ||
LL | / spawn(async move { | ||
LL | | let mut hc = hc; | ||
LL | | if !hc.check().await { | ||
LL | | log_health_check_failure().await; | ||
LL | | } | ||
LL | | }); | ||
| |______^ | ||
| | ||
= note: could not prove `[async block@$DIR/issue-110963-early.rs:15:11: 20:6]: Send` | ||
|
||
error: aborting due to 2 previous errors; 2 warnings emitted | ||
|
50 changes: 50 additions & 0 deletions
50
tests/ui/async-await/return-type-notation/issue-110963-late.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// edition: 2021 | ||
// check-pass | ||
|
||
#![feature(return_type_notation)] | ||
//~^ WARN the feature `return_type_notation` is incomplete | ||
#![feature(async_fn_in_trait)] | ||
//~^ WARN the feature `async_fn_in_trait` is incomplete | ||
|
||
trait HealthCheck { | ||
async fn check(&mut self) -> bool; | ||
} | ||
|
||
async fn do_health_check_par<HC>(hc: HC) | ||
where | ||
HC: HealthCheck<check(): Send> + Send + 'static, | ||
{ | ||
spawn(async move { | ||
let mut hc = hc; | ||
if !hc.check().await { | ||
log_health_check_failure().await; | ||
} | ||
}); | ||
} | ||
|
||
async fn log_health_check_failure() {} | ||
|
||
fn main() {} | ||
|
||
// Fake tokio spawn | ||
|
||
use std::future::Future; | ||
use std::pin::Pin; | ||
use std::task::{Context, Poll}; | ||
|
||
fn spawn<F>(future: F) -> JoinHandle | ||
where | ||
F: Future + Send + 'static, | ||
F::Output: Send + 'static, | ||
{ | ||
loop {} | ||
} | ||
|
||
struct JoinHandle; | ||
|
||
impl Future for JoinHandle { | ||
type Output = (); | ||
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { | ||
loop {} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
tests/ui/async-await/return-type-notation/issue-110963-late.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/issue-110963-late.rs:4:12 | ||
| | ||
LL | #![feature(return_type_notation)] | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information | ||
= note: `#[warn(incomplete_features)]` on by default | ||
|
||
warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/issue-110963-late.rs:6:12 | ||
| | ||
LL | #![feature(async_fn_in_trait)] | ||
| ^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information | ||
|
||
warning: 2 warnings emitted | ||
|