rust-cpython
rust-cpython copied to clipboard
Consistently refer to the right `Result` in macro expansion
Without this, importing any other crate's Result
type alias in a module that uses cpython's macros causes compilation to fail in a variety of interesting ways.
Repro:
use cpython::{py_class, PyResult};
use std::io::Result;
py_class!(class Struct |py| {
def __new__(_cls) -> PyResult<Struct> {
Struct::create_instance(py)
}
});
The resulting diagnostic:
error[E0107]: this type alias takes 1 generic argument but 2 generic arguments were supplied
--> src/main.rs:4:1
|
4 | / py_class!(class Struct |py| {
5 | | def __new__(_cls) -> PyResult<Struct> {
6 | | Struct::create_instance(py)
7 | | }
8 | | });
| | ^
| | |
| |__expected 1 generic argument
| help: remove this generic argument
|
note: type alias defined here, with 1 generic parameter: `T`
--> nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/io/error.rs:55:10
|
55 | pub type Result<T> = result::Result<T, Error>;
| ^^^^^^ -
= note: this error originates in the macro `$crate::py_class_impl` (in Nightly builds, run with -Z macro-backtrace for more info)