Skip to content

DO NOT MERGE: Test with memoffset/unstable_offset_of feature #3545

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

Closed
wants to merge 1 commit into from

Conversation

joshlf
Copy link

@joshlf joshlf commented Oct 24, 2023

Testing as part of rust-lang/rust#111839

Thank you for contributing to PyO3!

By submitting these contributions you agree for them to be dual-licensed under PyO3's MIT OR Apache-2.0 license.

Please consider adding the following to your pull request:

  • an entry for this PR in newsfragments - see [https://pyo3.rs/main/contributing.html#documenting-changes]
    • or start the PR title with docs: if this is a docs-only change to skip the check
  • docs to all new functions and / or detail in the guide
  • tests for all new or changed functions

PyO3's CI pipeline will check your pull request. To run its tests
locally, you can run nox. See nox --list-sessions
for a list of supported actions.

@joshlf
Copy link
Author

joshlf commented Oct 24, 2023

I tested this locally. I got trybuild failures, which seem to be a result of a compiler version mismatch, although I'm not sure what compiler version was used to generated .stderr files.

Specifically, I ran:

$ TRYBUILD=overwrite cargo +nightly test --features memoffset/unstable_offset_of

Then, I ran the same command without TRYBUILD=overwrite, and tests passed.

Here's the diff, which shows that the .stderr file output seems to just be cosmetic; no actual behavior changes:

Diff
$ git diff
diff --git a/tests/ui/deprecations.stderr b/tests/ui/deprecations.stderr
index d1b2c301..fbd893e7 100644
--- a/tests/ui/deprecations.stderr
+++ b/tests/ui/deprecations.stderr
@@ -14,4 +14,4 @@ error: use of deprecated constant `pyo3::impl_::deprecations::PYCLASS_TEXT_SIGNA
  --> tests/ui/deprecations.rs:6:8
   |
 6 | #[pyo3(text_signature = "()")]
-  |        ^^^^^^^^^^^^^^
+  |        ^^^^^^^^^^^^^^^^^^^^^
diff --git a/tests/ui/invalid_frompy_derive.stderr b/tests/ui/invalid_frompy_derive.stderr
index 8ed03caa..077c3150 100644
--- a/tests/ui/invalid_frompy_derive.stderr
+++ b/tests/ui/invalid_frompy_derive.stderr
@@ -130,7 +130,7 @@ error: only one of `attribute` or `item` can be provided
    --> tests/ui/invalid_frompy_derive.rs:118:5
     |
 118 |     #[pyo3(item, attribute)]
-    |     ^
+    |     ^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: expected one of: `transparent`, `from_item_all`, `annotation`, `crate`
    --> tests/ui/invalid_frompy_derive.rs:123:8
@@ -154,13 +154,15 @@ error: FromPyObject can be derived with at most one lifetime parameter
    --> tests/ui/invalid_frompy_derive.rs:141:22
     |
 141 | enum TooManyLifetimes<'a, 'b> {
-    |                      ^
+    |                      ^^^^^^^^
 
 error: #[derive(FromPyObject)] is not supported for unions
    --> tests/ui/invalid_frompy_derive.rs:147:1
     |
-147 | union Union {
-    | ^^^^^
+147 | / union Union {
+148 | |     a: usize,
+149 | | }
+    | |_^
 
 error: cannot derive FromPyObject for empty structs and variants
    --> tests/ui/invalid_frompy_derive.rs:151:10
@@ -186,7 +188,7 @@ error: `getter` is not permitted on tuple struct elements.
    --> tests/ui/invalid_frompy_derive.rs:169:27
     |
 169 | struct InvalidTupleGetter(#[pyo3(item("foo"))] String);
-    |                           ^
+    |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: `transparent` structs may not have a `getter` for the inner field
    --> tests/ui/invalid_frompy_derive.rs:175:5
diff --git a/tests/ui/invalid_frozen_pyclass_borrow.stderr b/tests/ui/invalid_frozen_pyclass_borrow.stderr
index 5e09d512..9f166bfc 100644
--- a/tests/ui/invalid_frozen_pyclass_borrow.stderr
+++ b/tests/ui/invalid_frozen_pyclass_borrow.stderr
@@ -8,7 +8,7 @@ error[E0271]: type mismatch resolving `<Foo as PyClass>::Frozen == False`
   --> tests/ui/invalid_frozen_pyclass_borrow.rs:11:19
    |
 11 |     fn mut_method(&mut self) {}
-   |                   ^ expected `False`, found `True`
+   |                   ^^^^^^^^^ expected `False`, found `True`
    |
 note: required by a bound in `extract_pyclass_ref_mut`
   --> src/impl_/extract_argument.rs
diff --git a/tests/ui/invalid_need_module_arg_position.stderr b/tests/ui/invalid_need_module_arg_position.stderr
index 8fce151f..d5824bc3 100644
--- a/tests/ui/invalid_need_module_arg_position.stderr
+++ b/tests/ui/invalid_need_module_arg_position.stderr
@@ -2,4 +2,4 @@ error: expected &PyModule as first argument with `pass_module`
  --> tests/ui/invalid_need_module_arg_position.rs:6:21
   |
 6 |     fn fail(string: &str, module: &PyModule) -> PyResult<&str> {
-  |                     ^
+  |                     ^^^^
diff --git a/tests/ui/invalid_property_args.stderr b/tests/ui/invalid_property_args.stderr
index a41b6c79..df87335d 100644
--- a/tests/ui/invalid_property_args.stderr
+++ b/tests/ui/invalid_property_args.stderr
@@ -38,7 +38,7 @@ error: `name` may only be specified once
   --> tests/ui/invalid_property_args.rs:37:42
    |
 37 | struct MultipleName(#[pyo3(name = "foo", name = "bar")] i32);
-   |                                          ^^^^
+   |                                          ^^^^^^^^^^^^
 
 error: `name` is useless without `get` or `set`
   --> tests/ui/invalid_property_args.rs:40:33
diff --git a/tests/ui/invalid_pyclass_enum.stderr b/tests/ui/invalid_pyclass_enum.stderr
index 8f340a76..0cd775eb 100644
--- a/tests/ui/invalid_pyclass_enum.stderr
+++ b/tests/ui/invalid_pyclass_enum.stderr
@@ -8,7 +8,7 @@ error: enums can't extend from other classes
  --> tests/ui/invalid_pyclass_enum.rs:9:11
   |
 9 | #[pyclass(extends = PyList)]
-  |           ^^^^^^^
+  |           ^^^^^^^^^^^^^^^^
 
 error: #[pyclass] can't be used on enums without any variants
   --> tests/ui/invalid_pyclass_enum.rs:16:18
diff --git a/tests/ui/invalid_pyfunction_signatures.stderr b/tests/ui/invalid_pyfunction_signatures.stderr
index dbca169d..3afdedcd 100644
--- a/tests/ui/invalid_pyfunction_signatures.stderr
+++ b/tests/ui/invalid_pyfunction_signatures.stderr
@@ -26,7 +26,7 @@ error: `*args` not allowed after `*`
   --> tests/ui/invalid_pyfunction_signatures.rs:25:24
    |
 25 | #[pyo3(signature = (*, *args))]
-   |                        ^
+   |                        ^^^^^
 
 error: `*` not allowed after `*`
   --> tests/ui/invalid_pyfunction_signatures.rs:31:24
@@ -38,13 +38,13 @@ error: `*args` not allowed after `**kwargs`
   --> tests/ui/invalid_pyfunction_signatures.rs:35:31
    |
 35 | #[pyo3(signature = (**kwargs, *args))]
-   |                               ^
+   |                               ^^^^^
 
 error: `**kwargs_b` not allowed after `**kwargs_a`
   --> tests/ui/invalid_pyfunction_signatures.rs:41:33
    |
 41 | #[pyo3(signature = (**kwargs_a, **kwargs_b))]
-   |                                 ^
+   |                                 ^^^^^^^^^^
 
 error: arguments of type `Python` must not be part of the signature
   --> tests/ui/invalid_pyfunction_signatures.rs:47:27
diff --git a/tests/ui/invalid_pyfunctions.stderr b/tests/ui/invalid_pyfunctions.stderr
index 9f140926..5514b36a 100644
--- a/tests/ui/invalid_pyfunctions.stderr
+++ b/tests/ui/invalid_pyfunctions.stderr
@@ -8,7 +8,7 @@ error: Python functions cannot have `impl Trait` arguments
  --> tests/ui/invalid_pyfunctions.rs:7:36
   |
 7 | fn impl_trait_function(impl_trait: impl AsRef<PyAny>) {}
-  |                                    ^^^^
+  |                                    ^^^^^^^^^^^^^^^^^
 
 error: `async fn` is not yet supported for Python functions.
 
diff --git a/tests/ui/invalid_pymethod_names.stderr b/tests/ui/invalid_pymethod_names.stderr
index 1e7a6f44..7ded46d1 100644
--- a/tests/ui/invalid_pymethod_names.stderr
+++ b/tests/ui/invalid_pymethod_names.stderr
@@ -8,7 +8,7 @@ error: `name` may only be specified once
   --> tests/ui/invalid_pymethod_names.rs:18:12
    |
 18 |     #[pyo3(name = "bar")]
-   |            ^^^^
+   |            ^^^^^^^^^^^^
 
 error: `name` not allowed with `#[new]`
   --> tests/ui/invalid_pymethod_names.rs:24:19
diff --git a/tests/ui/invalid_pymethods.stderr b/tests/ui/invalid_pymethods.stderr
index 24fb5242..7cfda7f7 100644
--- a/tests/ui/invalid_pymethods.stderr
+++ b/tests/ui/invalid_pymethods.stderr
@@ -8,43 +8,43 @@ error: `#[classattr]` does not take any arguments
   --> tests/ui/invalid_pymethods.rs:14:5
    |
 14 |     #[classattr(foobar)]
-   |     ^
+   |     ^^^^^^^^^^^^^^^^^^^^
 
 error: static method needs #[staticmethod] attribute
   --> tests/ui/invalid_pymethods.rs:20:5
    |
 20 |     fn staticmethod_without_attribute() {}
-   |     ^^
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: unexpected receiver
   --> tests/ui/invalid_pymethods.rs:26:35
    |
 26 |     fn staticmethod_with_receiver(&self) {}
-   |                                   ^
+   |                                   ^^^^^
 
 error: Expected `cls: &PyType` as the first argument to `#[classmethod]`
   --> tests/ui/invalid_pymethods.rs:32:34
    |
 32 |     fn classmethod_with_receiver(&self) {}
-   |                                  ^
+   |                                  ^^^^^
 
 error: expected receiver for `#[getter]`
   --> tests/ui/invalid_pymethods.rs:38:5
    |
 38 |     fn getter_without_receiver() {}
-   |     ^^
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: expected receiver for `#[setter]`
   --> tests/ui/invalid_pymethods.rs:44:5
    |
 44 |     fn setter_without_receiver() {}
-   |     ^^
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: static method needs #[staticmethod] attribute
   --> tests/ui/invalid_pymethods.rs:50:5
    |
 50 |     fn text_signature_on_call() {}
-   |     ^^
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: `text_signature` not allowed with `getter`
   --> tests/ui/invalid_pymethods.rs:56:12
@@ -74,7 +74,7 @@ error: `text_signature` may only be specified once
   --> tests/ui/invalid_pymethods.rs:83:12
    |
 83 |     #[pyo3(text_signature = None)]
-   |            ^^^^^^^^^^^^^^
+   |            ^^^^^^^^^^^^^^^^^^^^^
 
 error: `signature` not allowed with `getter`
   --> tests/ui/invalid_pymethods.rs:90:12
@@ -97,15 +97,21 @@ error: `signature` not allowed with `classattr`
 error: `#[new]` may not be combined with `#[classmethod]` `#[staticmethod]`, `#[classattr]`, `#[getter]`, and `#[setter]`
    --> tests/ui/invalid_pymethods.rs:110:7
     |
-110 |     #[new]
-    |       ^^^
+110 |       #[new]
+    |  _______^
+111 | |     #[classmethod]
+112 | |     #[staticmethod]
+113 | |     #[classattr]
+114 | |     #[getter(x)]
+115 | |     #[setter(x)]
+    | |____________^
 
 error: `#[new]` does not take any arguments
        = help: did you mean `#[new] #[pyo3(signature = ())]`?
    --> tests/ui/invalid_pymethods.rs:121:7
     |
 121 |     #[new(signature = ())]
-    |       ^^^
+    |       ^^^^^^^^^^^^^^^^^^^
 
 error: `#[new]` does not take any arguments
        = note: this was previously accepted and ignored
@@ -119,21 +125,21 @@ error: `#[classmethod]` does not take any arguments
    --> tests/ui/invalid_pymethods.rs:133:7
     |
 133 |     #[classmethod(signature = ())]
-    |       ^^^^^^^^^^^
+    |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: `#[staticmethod]` does not take any arguments
        = help: did you mean `#[staticmethod] #[pyo3(signature = ())]`?
    --> tests/ui/invalid_pymethods.rs:139:7
     |
 139 |     #[staticmethod(signature = ())]
-    |       ^^^^^^^^^^^^
+    |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: `#[classattr]` does not take any arguments
        = help: did you mean `#[classattr] #[pyo3(signature = ())]`?
    --> tests/ui/invalid_pymethods.rs:145:7
     |
 145 |     #[classattr(signature = ())]
-    |       ^^^^^^^^^
+    |       ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: Python functions cannot have generic type parameters
    --> tests/ui/invalid_pymethods.rs:151:23
@@ -145,13 +151,13 @@ error: Python functions cannot have `impl Trait` arguments
    --> tests/ui/invalid_pymethods.rs:156:48
     |
 156 |     fn impl_trait_method_first_arg(impl_trait: impl AsRef<PyAny>) {}
-    |                                                ^^^^
+    |                                                ^^^^^^^^^^^^^^^^^
 
 error: Python functions cannot have `impl Trait` arguments
    --> tests/ui/invalid_pymethods.rs:161:56
     |
 161 |     fn impl_trait_method_second_arg(&self, impl_trait: impl AsRef<PyAny>) {}
-    |                                                        ^^^^
+    |                                                        ^^^^^^^^^^^^^^^^^
 
 error: `async fn` is not yet supported for Python functions.
 
@@ -179,7 +185,7 @@ error: macros cannot be used as items in `#[pymethods]` impl blocks
    --> tests/ui/invalid_pymethods.rs:212:5
     |
 212 |     macro_invocation!();
-    |     ^^^^^^^^^^^^^^^^
+    |     ^^^^^^^^^^^^^^^^^^^^
 
 error[E0119]: conflicting implementations of trait `pyo3::impl_::pyclass::PyClassNewTextSignature<TwoNew>` for type `pyo3::impl_::pyclass::PyClassImplCollector<TwoNew>`
    --> tests/ui/invalid_pymethods.rs:182:1
diff --git a/tests/ui/reject_generics.stderr b/tests/ui/reject_generics.stderr
index 2285b927..a4250e74 100644
--- a/tests/ui/reject_generics.stderr
+++ b/tests/ui/reject_generics.stderr
@@ -2,7 +2,7 @@ error: #[pyclass] cannot have generic parameters. For an explanation, see https:
  --> tests/ui/reject_generics.rs:4:25
   |
 4 | struct ClassWithGenerics<A> {
-  |                         ^
+  |                         ^^^
 
 error: #[pyclass] cannot have lifetime parameters. For an explanation, see https://pyo3.rs/latest/class.html#no-lifetime-parameters
  --> tests/ui/reject_generics.rs:9:27

</details>

@joshlf joshlf closed this Oct 24, 2023
@joshlf joshlf deleted the patch-1 branch October 24, 2023 11:14
@adamreichold
Copy link
Member

I tested this locally. I got trybuild failures, which seem to be a result of a compiler version mismatch, although I'm not sure what compiler version was used to generated .stderr files.

As indicated by

- if: inputs.rust != 'stable'
name: Ignore changed error messages when using trybuild
run: echo "TRYBUILD=overwrite" >> "$GITHUB_ENV"

we check the compiler output only on the current stable.

@davidhewitt
Copy link
Member

Also @joshlf if you want this more permanently tested in our CI, I think it'd be fine to update our nightly feature to depend on the memoffset/unstable_offset_of feature.

@joshlf
Copy link
Author

joshlf commented Oct 25, 2023

Also @joshlf if you want this more permanently tested in our CI, I think it'd be fine to update our nightly feature to depend on the memoffset/unstable_offset_of feature.

We've got what we need for rust-lang/rust#111839, but thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants