fix declarative-modules compile error (#4054)
* fix declarative-modules compile error * add newsfragment
This commit is contained in:
parent
c8b59d7117
commit
ee5216f406
1
newsfragments/4054.fixed.md
Normal file
1
newsfragments/4054.fixed.md
Normal file
|
@ -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! {
|
||||
impl #cls {
|
||||
#[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"]
|
||||
mod common;
|
||||
|
||||
mod some_module {
|
||||
use pyo3::prelude::*;
|
||||
|
||||
#[pyclass]
|
||||
pub struct SomePyClass;
|
||||
}
|
||||
|
||||
#[pyclass]
|
||||
struct ValueClass {
|
||||
value: usize,
|
||||
|
@ -50,6 +57,10 @@ mod declarative_module {
|
|||
#[pymodule_export]
|
||||
use super::{declarative_module2, double, MyError, ValueClass as Value};
|
||||
|
||||
// test for #4036
|
||||
#[pymodule_export]
|
||||
use super::some_module::SomePyClass;
|
||||
|
||||
#[pymodule]
|
||||
mod inner {
|
||||
use super::*;
|
||||
|
|
Loading…
Reference in a new issue