diff --git a/pyo3-macros-backend/src/pyclass.rs b/pyo3-macros-backend/src/pyclass.rs index 747c0153b95..a83ba880271 100644 --- a/pyo3-macros-backend/src/pyclass.rs +++ b/pyo3-macros-backend/src/pyclass.rs @@ -2324,11 +2324,11 @@ impl<'a> PyClassImplsBuilder<'a> { let assertions = if attr.options.unsendable.is_some() { TokenStream::new() } else { - quote_spanned! { - cls.span() => + let assert = quote_spanned! { cls.span() => assert_pyclass_sync::<#cls>(); }; + quote! { const _: () = { use #pyo3_path::impl_::pyclass::*; - assert_pyclass_sync::<#cls>(); + #assert }; } };