-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add `Sync` argument which marks the returned `Future` as `Sync`
- Loading branch information
Showing
21 changed files
with
343 additions
and
28 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
use async_recursion::async_recursion; | ||
|
||
#[async_recursion(Sync)] | ||
async fn send_and_sync() {} | ||
|
||
fn assert_is_send_and_sync(_: impl Send + Sync) {} | ||
|
||
#[test] | ||
fn test_sync_argument() { | ||
assert_is_send_and_sync(send_and_sync()); | ||
} |
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,5 @@ | ||
use async_recursion::async_recursion; | ||
#[must_use] | ||
fn no_send_bound() -> ::core::pin::Pin<Box<dyn ::core::future::Future<Output = ()>>> { | ||
Box::pin(async move {}) | ||
} |
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,4 @@ | ||
use async_recursion::async_recursion; | ||
|
||
#[async_recursion(?Send)] | ||
async fn no_send_bound() {} |
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,25 @@ | ||
use async_recursion::async_recursion; | ||
#[must_use] | ||
fn not_send_sync_1() -> ::core::pin::Pin< | ||
Box<dyn ::core::future::Future<Output = ()> + ::core::marker::Sync>, | ||
> { | ||
Box::pin(async move {}) | ||
} | ||
#[must_use] | ||
fn not_send_sync_2() -> ::core::pin::Pin< | ||
Box<dyn ::core::future::Future<Output = ()> + ::core::marker::Sync>, | ||
> { | ||
Box::pin(async move {}) | ||
} | ||
#[must_use] | ||
fn sync_not_send_1() -> ::core::pin::Pin< | ||
Box<dyn ::core::future::Future<Output = ()> + ::core::marker::Sync>, | ||
> { | ||
Box::pin(async move {}) | ||
} | ||
#[must_use] | ||
fn sync_not_send_2() -> ::core::pin::Pin< | ||
Box<dyn ::core::future::Future<Output = ()> + ::core::marker::Sync>, | ||
> { | ||
Box::pin(async move {}) | ||
} |
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,13 @@ | ||
use async_recursion::async_recursion; | ||
|
||
#[async_recursion(?Send, Sync)] | ||
async fn not_send_sync_1() {} | ||
|
||
#[async_recursion(?Send,Sync)] | ||
async fn not_send_sync_2() {} | ||
|
||
#[async_recursion(Sync, ?Send)] | ||
async fn sync_not_send_1() {} | ||
|
||
#[async_recursion(Sync,?Send)] | ||
async fn sync_not_send_2() {} |
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,11 @@ | ||
use async_recursion::async_recursion; | ||
#[must_use] | ||
fn sync() -> ::core::pin::Pin< | ||
Box< | ||
dyn ::core::future::Future< | ||
Output = (), | ||
> + ::core::marker::Send + ::core::marker::Sync, | ||
>, | ||
> { | ||
Box::pin(async move {}) | ||
} |
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,4 @@ | ||
use async_recursion::async_recursion; | ||
|
||
#[async_recursion(Sync)] | ||
async fn sync() {} |
19 changes: 19 additions & 0 deletions
19
tests/expand/lifetimes_explicit_async_recursion_bound.expanded.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,19 @@ | ||
use async_recursion::async_recursion; | ||
#[must_use] | ||
fn explicit_async_recursion_bound<'life0, 'life1, 'async_recursion>( | ||
t: &'life0 T, | ||
p: &'life1 [String], | ||
prefix: Option<&'async_recursion [u8]>, | ||
layer: Option<&'async_recursion [u8]>, | ||
) -> ::core::pin::Pin< | ||
Box< | ||
dyn ::core::future::Future<Output = ()> + 'async_recursion + ::core::marker::Send, | ||
>, | ||
> | ||
where | ||
'life0: 'async_recursion, | ||
'life1: 'async_recursion, | ||
'async_recursion: 'async_recursion, | ||
{ | ||
Box::pin(async move {}) | ||
} |
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,12 @@ | ||
// Test that an explicit `async_recursion bound is left alone. | ||
// This is a workaround many | ||
use async_recursion::async_recursion; | ||
|
||
|
||
#[async_recursion] | ||
async fn explicit_async_recursion_bound( | ||
t: &T, | ||
p: &[String], | ||
prefix: Option<&'async_recursion [u8]>, | ||
layer: Option<&'async_recursion [u8]>, | ||
) {} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
use async_recursion::async_recursion; | ||
|
||
fn assert_is_sync(_: impl Sync) {} | ||
|
||
|
||
#[async_recursion] | ||
async fn send_not_sync() {} | ||
|
||
#[async_recursion(?Send)] | ||
async fn not_send_not_sync() {} | ||
|
||
fn main() { | ||
assert_is_sync(send_not_sync()); | ||
assert_is_sync(not_send_not_sync()); | ||
} |
Oops, something went wrong.