From 8089ba8a87dfa626c2122ad0e54defd94b796bc1 Mon Sep 17 00:00:00 2001 From: Thomas Pellissier-Tanon Date: Wed, 25 Mar 2026 19:30:39 +0100 Subject: [PATCH] Run tests with macros and without experimental inspect We are currently not testing pyo3 with the `macros` feature enabled but without `full` enabled --- noxfile.py | 2 +- tests/test_compile_error.rs | 3 ++- tests/ui/invalid_pyclass_args.stderr | 33 ++-------------------------- 3 files changed, 5 insertions(+), 33 deletions(-) diff --git a/noxfile.py b/noxfile.py index 42cf158e1b5..27b68f44e95 100644 --- a/noxfile.py +++ b/noxfile.py @@ -1494,7 +1494,7 @@ def _get_feature_sets() -> Tuple[Optional[str], ...]: if is_rust_nightly(): features += ",nightly" - return (None, "abi3", features, f"abi3,{features}") + return (None, "abi3", "macros", "abi3,macros", features, f"abi3,{features}") _RELEASE_LINE_START = "release: " diff --git a/tests/test_compile_error.rs b/tests/test_compile_error.rs index 423f0dd5cea..1bca1d15371 100644 --- a/tests/test_compile_error.rs +++ b/tests/test_compile_error.rs @@ -9,6 +9,7 @@ fn test_compile_errors() { #[cfg(not(feature = "experimental-inspect"))] t.compile_fail("tests/ui/invalid_property_args.rs"); t.compile_fail("tests/ui/invalid_proto_pymethods.rs"); + #[cfg(not(feature = "experimental-inspect"))] #[cfg(not(all(Py_LIMITED_API, not(Py_3_10))))] // to avoid PyFunctionArgument for &str t.compile_fail("tests/ui/invalid_pyclass_args.rs"); t.compile_fail("tests/ui/invalid_pyclass_doc.rs"); @@ -78,7 +79,7 @@ fn test_compile_errors() { t.pass("tests/ui/pymodule_missing_docs.rs"); #[cfg(not(any(Py_LIMITED_API, feature = "experimental-inspect")))] t.pass("tests/ui/forbid_unsafe.rs"); - #[cfg(all(Py_LIMITED_API, not(feature = "experimental-async")))] + #[cfg(all(Py_LIMITED_API, not(Py_3_12), not(feature = "experimental-async")))] // output changes with async feature t.compile_fail("tests/ui/abi3_inheritance.rs"); #[cfg(all(Py_LIMITED_API, not(Py_3_9)))] diff --git a/tests/ui/invalid_pyclass_args.stderr b/tests/ui/invalid_pyclass_args.stderr index f63db6926dd..9dab7481a38 100644 --- a/tests/ui/invalid_pyclass_args.stderr +++ b/tests/ui/invalid_pyclass_args.stderr @@ -192,35 +192,6 @@ error[E0119]: conflicting implementations of trait `PyClassNewTextSignature` for | = note: this error originates in the attribute macro `pymethods` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0277]: `Box` cannot be used as a Python function argument - --> tests/ui/invalid_pyclass_args.rs:205:12 - | -205 | field: Box, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `PyFunctionArgument<'_, '_, '_, false>` is not implemented for `Box` - | - = note: implement `FromPyObject` to enable using `Box` as a function argument - = note: `Python<'py>` is also a valid argument type to pass the Python token into `#[pyfunction]`s and `#[pymethods]` -help: the following other types implement trait `PyFunctionArgument<'a, 'holder, 'py, IMPLEMENTS_FROMPYOBJECT>` - --> src/impl_/extract_argument.rs - | - | / impl<'a, 'holder, 'py, T: 'a + 'py> PyFunctionArgument<'a, 'holder, 'py, false> - | | for &'holder Bound<'py, T> - | | where - | | T: PyTypeCheck, - | |___________________^ `&'holder pyo3::Bound<'py, T>` implements `PyFunctionArgument<'a, 'holder, 'py, false>` -... - | / impl<'a, 'holder, 'py, T> PyFunctionArgument<'a, 'holder, 'py, false> for Option - | | where - | | T: PyFunctionArgument<'a, 'holder, 'py, false>, - | |___________________________________________________^ `Option` implements `PyFunctionArgument<'a, 'holder, 'py, false>` -... - | impl<'a, 'holder, T: PyClass> PyFunctionArgument<'a, 'holder, '_, false> for &'holder T { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `&'holder T` implements `PyFunctionArgument<'a, 'holder, '_, false>` -... - | / impl<'a, 'holder, T: PyClass> PyFunctionArgument<'a, 'holder, '_, false> - | | for &'holder mut T - | |______________________^ `&'holder mut T` implements `PyFunctionArgument<'a, 'holder, '_, false>` - error[E0592]: duplicate definitions with name `__pymethod___richcmp____` --> tests/ui/invalid_pyclass_args.rs:37:1 | @@ -456,11 +427,11 @@ error[E0277]: `Box` cannot be used as a Pyt --> tests/ui/invalid_pyclass_args.rs:205:12 | 205 | field: Box, - | ^^^ the trait `pyo3::PyClass` is not implemented for `Box` + | ^^^ the trait `PyClass` is not implemented for `Box` | = note: implement `FromPyObject` to enable using `Box` as a function argument = note: `Python<'py>` is also a valid argument type to pass the Python token into `#[pyfunction]`s and `#[pymethods]` - = help: the following other types implement trait `pyo3::PyClass`: + = help: the following other types implement trait `PyClass`: Coord Coord2 Coord3