Skip to content

Commit 309065d

Browse files
committed
Hygeine for #[pyclass] enums.
1 parent 469d72a commit 309065d

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

pyo3-macros-backend/src/pyclass.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ fn impl_enum_class(
471471
fn __pyo3__repr__(&self) -> &'static str {
472472
match self {
473473
#(#variants_repr)*
474-
_ => unreachable!("Unsupported variant type."),
474+
_ => ::core::unreachable!("Unsupported variant type."),
475475
}
476476
}
477477
}

pyo3-macros-backend/src/pyimpl.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,9 @@ pub fn gen_default_slot_impls(cls: &syn::Ident, method_defs: Vec<TokenStream>) -
234234
impl #cls {
235235
#(#method_defs)*
236236
}
237-
impl ::pyo3::class::impl_::PyClassDefaultSlots<#cls>
238-
for ::pyo3::class::impl_::PyClassImplCollector<#cls> {
239-
fn py_class_default_slots(self) -> &'static [::pyo3::ffi::PyType_Slot] {
237+
impl _pyo3::class::impl_::PyClassDefaultSlots<#cls>
238+
for _pyo3::class::impl_::PyClassImplCollector<#cls> {
239+
fn py_class_default_slots(self) -> &'static [_pyo3::ffi::PyType_Slot] {
240240
&[#(#proto_impls),*]
241241
}
242242
}

src/test_hygiene/pyclass.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,9 @@ pub struct Bar {
2828
#[pyo3(get, set)]
2929
c: ::std::option::Option<crate::Py<Foo2>>,
3030
}
31+
32+
#[crate::pyclass]
33+
#[pyo3(crate = "crate")]
34+
pub enum Enum {
35+
Var0,
36+
}

0 commit comments

Comments
 (0)