fix declarative-modules compile error (#4054)
* fix declarative-modules compile error * add newsfragment
This commit is contained in:
parent
c8b59d7117
commit
ee5216f406
|
@ -0,0 +1 @@
|
||||||
|
Fixes a compile error when exporting a `#[pyclass]` living in a different Rust module using the declarative-module feature.
|
|
@ -1614,7 +1614,7 @@ impl<'a> PyClassImplsBuilder<'a> {
|
||||||
quote! {
|
quote! {
|
||||||
impl #cls {
|
impl #cls {
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
const _PYO3_DEF: #pyo3_path::impl_::pymodule::AddClassToModule<Self> = #pyo3_path::impl_::pymodule::AddClassToModule::new();
|
pub const _PYO3_DEF: #pyo3_path::impl_::pymodule::AddClassToModule<Self> = #pyo3_path::impl_::pymodule::AddClassToModule::new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,13 @@ use pyo3::types::PyBool;
|
||||||
#[path = "../src/tests/common.rs"]
|
#[path = "../src/tests/common.rs"]
|
||||||
mod common;
|
mod common;
|
||||||
|
|
||||||
|
mod some_module {
|
||||||
|
use pyo3::prelude::*;
|
||||||
|
|
||||||
|
#[pyclass]
|
||||||
|
pub struct SomePyClass;
|
||||||
|
}
|
||||||
|
|
||||||
#[pyclass]
|
#[pyclass]
|
||||||
struct ValueClass {
|
struct ValueClass {
|
||||||
value: usize,
|
value: usize,
|
||||||
|
@ -50,6 +57,10 @@ mod declarative_module {
|
||||||
#[pymodule_export]
|
#[pymodule_export]
|
||||||
use super::{declarative_module2, double, MyError, ValueClass as Value};
|
use super::{declarative_module2, double, MyError, ValueClass as Value};
|
||||||
|
|
||||||
|
// test for #4036
|
||||||
|
#[pymodule_export]
|
||||||
|
use super::some_module::SomePyClass;
|
||||||
|
|
||||||
#[pymodule]
|
#[pymodule]
|
||||||
mod inner {
|
mod inner {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
Loading…
Reference in New Issue