Skip to content

Commit 603a55f

Browse files
authored
fix #[pyclass] could not be named Probe (PyO3#4794)
1 parent 0777c6e commit 603a55f

File tree

5 files changed

+12
-5
lines changed

5 files changed

+12
-5
lines changed

newsfragments/4794.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fix `#[pyclass]` could not be named `Probe`

pyo3-macros-backend/src/pyclass.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2294,10 +2294,9 @@ impl<'a> PyClassImplsBuilder<'a> {
22942294
let assertions = if attr.options.unsendable.is_some() {
22952295
TokenStream::new()
22962296
} else {
2297-
let assert = quote_spanned! { cls.span() => assert_pyclass_sync::<#cls>(); };
2297+
let assert = quote_spanned! { cls.span() => #pyo3_path::impl_::pyclass::assert_pyclass_sync::<#cls>(); };
22982298
quote! {
22992299
const _: () = {
2300-
use #pyo3_path::impl_::pyclass::*;
23012300
#assert
23022301
};
23032302
}
@@ -2337,7 +2336,7 @@ impl<'a> PyClassImplsBuilder<'a> {
23372336
static DOC: #pyo3_path::sync::GILOnceCell<::std::borrow::Cow<'static, ::std::ffi::CStr>> = #pyo3_path::sync::GILOnceCell::new();
23382337
DOC.get_or_try_init(py, || {
23392338
let collector = PyClassImplCollector::<Self>::new();
2340-
build_pyclass_doc(<#cls as #pyo3_path::PyTypeInfo>::NAME, #doc, collector.new_text_signature())
2339+
build_pyclass_doc(<Self as #pyo3_path::PyTypeInfo>::NAME, #doc, collector.new_text_signature())
23412340
}).map(::std::ops::Deref::deref)
23422341
}
23432342

tests/test_compile_error.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,5 @@ fn test_compile_errors() {
6767
#[cfg(all(not(Py_LIMITED_API), Py_3_11))]
6868
t.compile_fail("tests/ui/invalid_base_class.rs");
6969
t.pass("tests/ui/ambiguous_associated_items.rs");
70+
t.pass("tests/ui/pyclass_probe.rs");
7071
}

tests/ui/pyclass_probe.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
use pyo3::prelude::*;
2+
3+
#[pyclass]
4+
pub struct Probe {}
5+
6+
fn main() {}

tests/ui/pyclass_send.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ note: required because it appears within the type `NotSyncNotSend`
1010
|
1111
5 | struct NotSyncNotSend(*mut c_void);
1212
| ^^^^^^^^^^^^^^
13-
note: required by a bound in `pyo3::impl_::pyclass::assertions::assert_pyclass_sync`
13+
note: required by a bound in `assert_pyclass_sync`
1414
--> src/impl_/pyclass/assertions.rs
1515
|
1616
| pub const fn assert_pyclass_sync<T>()
@@ -52,7 +52,7 @@ note: required because it appears within the type `SendNotSync`
5252
|
5353
8 | struct SendNotSync(*mut c_void);
5454
| ^^^^^^^^^^^
55-
note: required by a bound in `pyo3::impl_::pyclass::assertions::assert_pyclass_sync`
55+
note: required by a bound in `assert_pyclass_sync`
5656
--> src/impl_/pyclass/assertions.rs
5757
|
5858
| pub const fn assert_pyclass_sync<T>()

0 commit comments

Comments
 (0)