Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
58 additions
and
41 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,19 @@ | ||
/// If it does nothing, was it ever really there? 👻 | ||
/// | ||
/// This is code that is just type checked to e.g. create better compile errors, | ||
/// but that never affects anything at runtime, | ||
use crate::{IntoPy, PyErr, PyObject}; | ||
|
||
#[allow(clippy::wrong_self_convention)] | ||
pub trait IntoPyResult<T> { | ||
fn into_py_result(&mut self) {} | ||
} | ||
|
||
impl<T> IntoPyResult<T> for T where T: IntoPy<PyObject> {} | ||
|
||
impl<T, E> IntoPyResult<T> for Result<T, E> | ||
where | ||
T: IntoPy<PyObject>, | ||
E: Into<PyErr>, | ||
{ | ||
} |
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 |
---|---|---|
@@ -1,12 +1,22 @@ | ||
error[E0599]: the method `into_py_result` exists for enum `Result<(), MyError>`, but its trait bounds were not satisfied | ||
error[E0599]: no method named `into_py_result` found for enum `Result` in the current scope | ||
--> tests/ui/invalid_result_conversion.rs:21:1 | ||
| | ||
21 | #[pyfunction] | ||
| ^^^^^^^^^^^^^ method cannot be called on `Result<(), MyError>` due to unsatisfied trait bounds | ||
| ^^^^^^^^^^^^^ method not found in `Result<(), MyError>` | ||
| | ||
= note: the following trait bounds were not satisfied: | ||
`&Result<(), MyError>: IntoPy<Py<PyAny>>` | ||
which is required by `&Result<(), MyError>: IntoPyResult<Result<&Result<(), MyError>, PyErr>>` | ||
`&mut Result<(), MyError>: IntoPy<Py<PyAny>>` | ||
which is required by `&mut Result<(), MyError>: IntoPyResult<Result<&mut Result<(), MyError>, PyErr>>` | ||
= 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 `Result<(), MyError>: IntoPyCallbackOutput<_>` is not satisfied | ||
--> tests/ui/invalid_result_conversion.rs:21:1 | ||
| | ||
21 | #[pyfunction] | ||
| ^^^^^^^^^^^^^ the trait `IntoPyCallbackOutput<_>` is not implemented for `Result<(), MyError>` | ||
| | ||
= help: the following implementations were found: | ||
<Result<T, E> as IntoPyCallbackOutput<U>> | ||
note: required by a bound in `pyo3::callback::convert` | ||
--> src/callback.rs | ||
| | ||
| T: IntoPyCallbackOutput<U>, | ||
| ^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `pyo3::callback::convert` | ||
= note: this error originates in the attribute macro `pyfunction` (in Nightly builds, run with -Z macro-backtrace for more info) |
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