You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
error[E0053]: method `__str__` has an incompatible type for trait
--> src/lib.rs:3:9
|
3 | fn __str__(&self) -> pyo3::prelude::PyResult<String> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected associated type, found enum `std::result::Result`
|
= note: expected fn pointer `fn(&'p S) -> <S as pyo3::class::basic::PyObjectStrProtocol<'p>>::Result`
found fn pointer `fn(&S) -> std::result::Result<std::string::String, pyo3::err::PyErr>`
= note: consider constraining the associated type `<S as pyo3::class::basic::PyObjectStrProtocol<'p>>::Result` to `std::result::Result<std::string::String, pyo3::err::PyErr>` or calling a method that returns `<S as pyo3::class::basic::PyObjectStrProtocol<'p>>::Result`
Note that the equivalent code (commented out in the example) compiles fine.
This is pyo3 0.12.3, but I've seen the same error from previous versions.
The text was updated successfully, but these errors were encountered:
I think it relates to expanding a macro inside the impl block, ie when the proc_macro sees tokens that originated from a macro. I can write a py_object_protocol macro provided it doesn't make a macro call inside the impl.
Looks like it's due to the fact that macros aren't eagerly expanded in the input to a proc_macro. This would be addressed by eager macro expansion in rust-lang/rfcs#2320.
Thanks @1tgr for reporting this. I'm not sure if there's anything easy that can be done to resolve this on our side - as you say it might require upstream support.
I might have a play with this sometime to get my head around it further. Won't promise anything though!
The code generated for this example by the proc_macro causes a compiler error:
Compiler error from the example above:
Note that the equivalent code (commented out in the example) compiles fine.
This is pyo3 0.12.3, but I've seen the same error from previous versions.
The text was updated successfully, but these errors were encountered: