-
Notifications
You must be signed in to change notification settings - Fork 915
Open
Description
The following code does not compile with the experimental-async feature enabled:
#[pyclass]
struct Value(i32);
#[pymethods]
impl Value {
#[new]
fn new(x: i32) -> Self {
Self(x)
}
}
#[pyfunction]
async fn add_two_values(obj: &Value, obj2: &Value) -> Value {
Value(obj.0 + obj2.0)
}The error is:
error[E0521]: borrowed data escapes outside of function
--> tests/test_coroutine.rs:373:5
|
373 | #[pyfunction]
| ^^^^^^^^^^^^^
| |
| `py` is a reference that is only valid in the function body
| `py` escapes the function body here
| lifetime `'py` defined here
| argument requires that `'py` must outlive `'static`
|
= note: this error originates in the attribute macro `pyfunction` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0716]: temporary value dropped while borrowed
--> tests/test_coroutine.rs:373:5
|
373 | #[pyfunction]
| ^^^^^^^^^^^^-
| | |
| | temporary value is freed at the end of this statement
| creates a temporary value which is freed while still in use
| argument requires that borrow lasts for `'static`
|
= note: this error originates in the attribute macro `pyfunction` (in Nightly builds, run with -Z macro-backtrace for more info)
Metadata
Metadata
Assignees
Labels
No labels