Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #[pyclass] could not be named Probe #4794

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions newsfragments/4794.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fix `#[pyclass]` could not be named `Probe`
5 changes: 2 additions & 3 deletions pyo3-macros-backend/src/pyclass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2294,10 +2294,9 @@ impl<'a> PyClassImplsBuilder<'a> {
let assertions = if attr.options.unsendable.is_some() {
TokenStream::new()
} else {
let assert = quote_spanned! { cls.span() => assert_pyclass_sync::<#cls>(); };
let assert = quote_spanned! { cls.span() => #pyo3_path::impl_::pyclass::assert_pyclass_sync::<#cls>(); };
quote! {
const _: () = {
use #pyo3_path::impl_::pyclass::*;
#assert
};
}
Expand Down Expand Up @@ -2337,7 +2336,7 @@ impl<'a> PyClassImplsBuilder<'a> {
static DOC: #pyo3_path::sync::GILOnceCell<::std::borrow::Cow<'static, ::std::ffi::CStr>> = #pyo3_path::sync::GILOnceCell::new();
DOC.get_or_try_init(py, || {
let collector = PyClassImplCollector::<Self>::new();
build_pyclass_doc(<#cls as #pyo3_path::PyTypeInfo>::NAME, #doc, collector.new_text_signature())
build_pyclass_doc(<Self as #pyo3_path::PyTypeInfo>::NAME, #doc, collector.new_text_signature())
}).map(::std::ops::Deref::deref)
}

Expand Down
1 change: 1 addition & 0 deletions tests/test_compile_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,5 @@ fn test_compile_errors() {
#[cfg(all(not(Py_LIMITED_API), Py_3_11))]
t.compile_fail("tests/ui/invalid_base_class.rs");
t.pass("tests/ui/ambiguous_associated_items.rs");
t.pass("tests/ui/pyclass_probe.rs");
}
6 changes: 6 additions & 0 deletions tests/ui/pyclass_probe.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
use pyo3::prelude::*;

#[pyclass]
pub struct Probe {}

fn main() {}
4 changes: 2 additions & 2 deletions tests/ui/pyclass_send.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ note: required because it appears within the type `NotSyncNotSend`
|
5 | struct NotSyncNotSend(*mut c_void);
| ^^^^^^^^^^^^^^
note: required by a bound in `pyo3::impl_::pyclass::assertions::assert_pyclass_sync`
note: required by a bound in `assert_pyclass_sync`
--> src/impl_/pyclass/assertions.rs
|
| pub const fn assert_pyclass_sync<T>()
Expand Down Expand Up @@ -52,7 +52,7 @@ note: required because it appears within the type `SendNotSync`
|
8 | struct SendNotSync(*mut c_void);
| ^^^^^^^^^^^
note: required by a bound in `pyo3::impl_::pyclass::assertions::assert_pyclass_sync`
note: required by a bound in `assert_pyclass_sync`
--> src/impl_/pyclass/assertions.rs
|
| pub const fn assert_pyclass_sync<T>()
Expand Down
Loading