-
Notifications
You must be signed in to change notification settings - Fork 785
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add
experimental-async
feature (#3931)
* add `experimental-async` feature * gate async doctests on feature
- Loading branch information
1 parent
fe84fed
commit 57bbc32
Showing
15 changed files
with
129 additions
and
110 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Add `experimental-async` feature. |
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
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,22 @@ | ||
use pyo3::prelude::*; | ||
|
||
#[pyfunction] | ||
async fn cancel_handle_repeated(#[pyo3(cancel_handle, cancel_handle)] _param: String) {} | ||
|
||
#[pyfunction] | ||
async fn cancel_handle_repeated2( | ||
#[pyo3(cancel_handle)] _param: String, | ||
#[pyo3(cancel_handle)] _param2: String, | ||
) { | ||
} | ||
|
||
#[pyfunction] | ||
fn cancel_handle_synchronous(#[pyo3(cancel_handle)] _param: String) {} | ||
|
||
#[pyfunction] | ||
async fn cancel_handle_wrong_type(#[pyo3(cancel_handle)] _param: String) {} | ||
|
||
#[pyfunction] | ||
async fn missing_cancel_handle_attribute(_param: pyo3::coroutine::CancelHandle) {} | ||
|
||
fn main() {} |
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,72 @@ | ||
error: `cancel_handle` may only be specified once per argument | ||
--> tests/ui/invalid_cancel_handle.rs:4:55 | ||
| | ||
4 | async fn cancel_handle_repeated(#[pyo3(cancel_handle, cancel_handle)] _param: String) {} | ||
| ^^^^^^^^^^^^^ | ||
|
||
error: `cancel_handle` may only be specified once | ||
--> tests/ui/invalid_cancel_handle.rs:9:28 | ||
| | ||
9 | #[pyo3(cancel_handle)] _param2: String, | ||
| ^^^^^^^ | ||
|
||
error: `cancel_handle` attribute can only be used with `async fn` | ||
--> tests/ui/invalid_cancel_handle.rs:14:53 | ||
| | ||
14 | fn cancel_handle_synchronous(#[pyo3(cancel_handle)] _param: String) {} | ||
| ^^^^^^ | ||
|
||
error[E0308]: mismatched types | ||
--> tests/ui/invalid_cancel_handle.rs:16:1 | ||
| | ||
16 | #[pyfunction] | ||
| ^^^^^^^^^^^^^ | ||
| | | ||
| expected `String`, found `CancelHandle` | ||
| arguments to this function are incorrect | ||
| | ||
note: function defined here | ||
--> tests/ui/invalid_cancel_handle.rs:17:10 | ||
| | ||
17 | async fn cancel_handle_wrong_type(#[pyo3(cancel_handle)] _param: String) {} | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ -------------- | ||
= note: this error originates in the attribute macro `pyfunction` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error[E0277]: the trait bound `CancelHandle: PyClass` is not satisfied | ||
--> tests/ui/invalid_cancel_handle.rs:20:50 | ||
| | ||
20 | async fn missing_cancel_handle_attribute(_param: pyo3::coroutine::CancelHandle) {} | ||
| ^^^^ the trait `PyClass` is not implemented for `CancelHandle` | ||
| | ||
= help: the trait `PyClass` is implemented for `pyo3::coroutine::Coroutine` | ||
= note: required for `CancelHandle` to implement `FromPyObject<'_>` | ||
= note: required for `CancelHandle` to implement `PyFunctionArgument<'_, '_>` | ||
note: required by a bound in `extract_argument` | ||
--> src/impl_/extract_argument.rs | ||
| | ||
| pub fn extract_argument<'a, 'py, T>( | ||
| ---------------- required by a bound in this function | ||
... | ||
| T: PyFunctionArgument<'a, 'py>, | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `extract_argument` | ||
|
||
error[E0277]: the trait bound `CancelHandle: Clone` is not satisfied | ||
--> tests/ui/invalid_cancel_handle.rs:20:50 | ||
| | ||
20 | async fn missing_cancel_handle_attribute(_param: pyo3::coroutine::CancelHandle) {} | ||
| ^^^^ the trait `Clone` is not implemented for `CancelHandle` | ||
| | ||
= help: the following other types implement trait `PyFunctionArgument<'a, 'py>`: | ||
&'a pyo3::Bound<'py, T> | ||
&'a pyo3::coroutine::Coroutine | ||
&'a mut pyo3::coroutine::Coroutine | ||
= note: required for `CancelHandle` to implement `FromPyObject<'_>` | ||
= note: required for `CancelHandle` to implement `PyFunctionArgument<'_, '_>` | ||
note: required by a bound in `extract_argument` | ||
--> src/impl_/extract_argument.rs | ||
| | ||
| pub fn extract_argument<'a, 'py, T>( | ||
| ---------------- required by a bound in this function | ||
... | ||
| T: PyFunctionArgument<'a, 'py>, | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `extract_argument` |