From 1840bc5ded1ba0eb3f83519b955fa14c1c11ace5 Mon Sep 17 00:00:00 2001 From: Owen Leung Date: Fri, 10 Jan 2025 07:44:59 +0800 Subject: [PATCH] ci: updates for Rust 1.84 (#4846) * Fix failing ruff fmt test * Add newsfragments * remove changelog * use wasm32-wasip1 in CI * update ui tests * use `wasm32-wasip1` in noxfile * update one more ui test * fix clippy beta * bump `EMSCRIPTEN_VERSION` * emscripten link `sqlite3` * emscipten update node --------- Co-authored-by: Nathan Goldbaum Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com> --- .github/workflows/ci.yml | 4 ++-- emscripten/Makefile | 2 +- noxfile.py | 7 ++++--- pyo3-build-config/src/impl_.rs | 2 +- pyo3-ffi/src/datetime.rs | 2 +- src/types/any.rs | 2 +- src/types/module.rs | 2 +- tests/ui/invalid_cancel_handle.stderr | 4 ++-- tests/ui/invalid_property_args.stderr | 2 +- tests/ui/invalid_pycallargs.stderr | 4 ++++ tests/ui/invalid_pyclass_args.stderr | 8 ++++---- tests/ui/invalid_pyfunctions.stderr | 2 +- tests/ui/invalid_pymethod_receiver.stderr | 2 +- tests/ui/invalid_pymethods.stderr | 2 +- tests/ui/invalid_result_conversion.stderr | 2 +- tests/ui/not_send.stderr | 2 +- tests/ui/not_send2.stderr | 2 +- tests/ui/pyclass_send.stderr | 12 ++++++------ 18 files changed, 34 insertions(+), 29 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f4b13f80dd7..76c5ab06f29 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -115,7 +115,7 @@ jobs: { os: "ubuntu-latest", python-architecture: "x64", - rust-target: "wasm32-wasi", + rust-target: "wasm32-wasip1", }, { os: "windows-latest", @@ -489,7 +489,7 @@ jobs: components: rust-src - uses: actions/setup-node@v4 with: - node-version: 14 + node-version: 18 - run: python -m pip install --upgrade pip && pip install nox - uses: actions/cache@v4 id: cache diff --git a/emscripten/Makefile b/emscripten/Makefile index af224854c26..54094382c1b 100644 --- a/emscripten/Makefile +++ b/emscripten/Makefile @@ -4,7 +4,7 @@ CURDIR=$(abspath .) BUILDROOT ?= $(CURDIR)/builddir PYMAJORMINORMICRO ?= 3.11.0 -EMSCRIPTEN_VERSION=3.1.13 +EMSCRIPTEN_VERSION=3.1.68 export EMSDKDIR = $(BUILDROOT)/emsdk diff --git a/noxfile.py b/noxfile.py index 25cb8d1eb92..ed7759f5f99 100644 --- a/noxfile.py +++ b/noxfile.py @@ -339,6 +339,7 @@ def test_emscripten(session: nox.Session): f"-C link-arg=-lpython{info.pymajorminor}", "-C link-arg=-lexpat", "-C link-arg=-lmpdec", + "-C link-arg=-lsqlite3", "-C link-arg=-lz", "-C link-arg=-lbz2", "-C link-arg=-sALLOW_MEMORY_GROWTH=1", @@ -351,7 +352,7 @@ def test_emscripten(session: nox.Session): session, "bash", "-c", - f"source {info.builddir/'emsdk/emsdk_env.sh'} && cargo test", + f"source {info.builddir / 'emsdk/emsdk_env.sh'} && cargo test", ) @@ -797,7 +798,7 @@ def _get_rust_default_target() -> str: def _get_feature_sets() -> Tuple[Tuple[str, ...], ...]: """Returns feature sets to use for clippy job""" cargo_target = os.getenv("CARGO_BUILD_TARGET", "") - if "wasm32-wasi" not in cargo_target: + if "wasm32-wasip1" not in cargo_target: # multiple-pymethods not supported on wasm return ( ("--no-default-features",), @@ -951,7 +952,7 @@ def set( f"""\ implementation={implementation} version={version} -build_flags={','.join(build_flags)} +build_flags={",".join(build_flags)} suppress_build_script_link_lines=true """ ) diff --git a/pyo3-build-config/src/impl_.rs b/pyo3-build-config/src/impl_.rs index 05bb58ac7aa..f130c2d6557 100644 --- a/pyo3-build-config/src/impl_.rs +++ b/pyo3-build-config/src/impl_.rs @@ -2001,7 +2001,7 @@ fn unescape(escaped: &str) -> Vec { } } - bytes.push(unhex(chunk[0]) << 4 | unhex(chunk[1])); + bytes.push((unhex(chunk[0]) << 4) | unhex(chunk[1])); } bytes diff --git a/pyo3-ffi/src/datetime.rs b/pyo3-ffi/src/datetime.rs index e529e0fce50..7f2d7958364 100644 --- a/pyo3-ffi/src/datetime.rs +++ b/pyo3-ffi/src/datetime.rs @@ -119,7 +119,7 @@ pub struct PyDateTime_DateTime { pub unsafe fn PyDateTime_GET_YEAR(o: *mut PyObject) -> c_int { // This should work for Date or DateTime let data = (*(o as *mut PyDateTime_Date)).data; - c_int::from(data[0]) << 8 | c_int::from(data[1]) + (c_int::from(data[0]) << 8) | c_int::from(data[1]) } #[inline] diff --git a/src/types/any.rs b/src/types/any.rs index 1ebc5d40a0b..0725453e569 100644 --- a/src/types/any.rs +++ b/src/types/any.rs @@ -949,7 +949,7 @@ impl<'py> PyAnyMethods<'py> for Bound<'py, PyAny> { } } - inner(self.py(), self.getattr(attr_name).map_err(Into::into)) + inner(self.py(), self.getattr(attr_name)) } fn getattr(&self, attr_name: N) -> PyResult> diff --git a/src/types/module.rs b/src/types/module.rs index fd7299cb084..99dc1be233b 100644 --- a/src/types/module.rs +++ b/src/types/module.rs @@ -443,7 +443,7 @@ impl<'py> PyModuleMethods<'py> for Bound<'py, PyModule> { Err(err) => { if err.is_instance_of::(self.py()) { let l = PyList::empty(self.py()); - self.setattr(__all__, &l).map_err(PyErr::from)?; + self.setattr(__all__, &l)?; Ok(l) } else { Err(err) diff --git a/tests/ui/invalid_cancel_handle.stderr b/tests/ui/invalid_cancel_handle.stderr index bd2b588df32..90a8caa4229 100644 --- a/tests/ui/invalid_cancel_handle.stderr +++ b/tests/ui/invalid_cancel_handle.stderr @@ -42,7 +42,7 @@ error[E0277]: the trait bound `CancelHandle: PyFunctionArgument<'_, '_>` is not --> tests/ui/invalid_cancel_handle.rs:20:50 | 20 | async fn missing_cancel_handle_attribute(_param: pyo3::coroutine::CancelHandle) {} - | ^^^^ the trait `PyClass` is not implemented for `CancelHandle`, which is required by `CancelHandle: PyFunctionArgument<'_, '_>` + | ^^^^ the trait `PyClass` is not implemented for `CancelHandle` | = help: the trait `PyClass` is implemented for `pyo3::coroutine::Coroutine` = note: required for `CancelHandle` to implement `FromPyObject<'_>` @@ -61,7 +61,7 @@ error[E0277]: the trait bound `CancelHandle: PyFunctionArgument<'_, '_>` is not --> tests/ui/invalid_cancel_handle.rs:20:50 | 20 | async fn missing_cancel_handle_attribute(_param: pyo3::coroutine::CancelHandle) {} - | ^^^^ the trait `Clone` is not implemented for `CancelHandle`, which is required by `CancelHandle: PyFunctionArgument<'_, '_>` + | ^^^^ the trait `Clone` is not implemented for `CancelHandle` | = help: the following other types implement trait `PyFunctionArgument<'a, 'py>`: &'a mut pyo3::coroutine::Coroutine diff --git a/tests/ui/invalid_property_args.stderr b/tests/ui/invalid_property_args.stderr index f2fea2a1dd5..5ef01fa210a 100644 --- a/tests/ui/invalid_property_args.stderr +++ b/tests/ui/invalid_property_args.stderr @@ -52,7 +52,7 @@ error[E0277]: `PhantomData` cannot be converted to a Python object 45 | value: ::std::marker::PhantomData, | ^ required by `#[pyo3(get)]` to create a readable property from a field of type `PhantomData` | - = help: the trait `IntoPyObject<'_>` is not implemented for `PhantomData`, which is required by `for<'py> PhantomData: PyO3GetField<'py>` + = help: the trait `IntoPyObject<'_>` is not implemented for `PhantomData` = note: implement `IntoPyObject` for `&PhantomData` or `IntoPyObject + Clone` for `PhantomData` to define the conversion = help: the following other types implement trait `IntoPyObject<'py>`: &&'a T diff --git a/tests/ui/invalid_pycallargs.stderr b/tests/ui/invalid_pycallargs.stderr index 93c0bc19b7f..78867b6855a 100644 --- a/tests/ui/invalid_pycallargs.stderr +++ b/tests/ui/invalid_pycallargs.stderr @@ -27,3 +27,7 @@ note: required by a bound in `call1` | where | A: PyCallArgs<'py>; | ^^^^^^^^^^^^^^^ required by this bound in `PyAnyMethods::call1` +help: use a unary tuple instead + | +6 | any.call1(("foo",)); + | + ++ diff --git a/tests/ui/invalid_pyclass_args.stderr b/tests/ui/invalid_pyclass_args.stderr index 15aa0387cc6..c13edc071d5 100644 --- a/tests/ui/invalid_pyclass_args.stderr +++ b/tests/ui/invalid_pyclass_args.stderr @@ -100,21 +100,21 @@ error: expected one of: `get`, `set`, `name` 85 | #[pyo3(pop)] | ^^^ -error: invalid format string: expected `'}'` but string was terminated +error: invalid format string: expected `}` but string was terminated --> tests/ui/invalid_pyclass_args.rs:105:19 | 105 | #[pyclass(str = "{")] - | -^ expected `'}'` in format string + | -^ expected `}` in format string | | | because of this opening brace | = note: if you intended to print `{`, you can escape it using `{{` -error: invalid format string: expected `'}'`, found `'$'` +error: invalid format string: expected `}`, found `$` --> tests/ui/invalid_pyclass_args.rs:109:19 | 109 | #[pyclass(str = "{$}")] - | -^ expected `'}'` in format string + | -^ expected `}` in format string | | | because of this opening brace | diff --git a/tests/ui/invalid_pyfunctions.stderr b/tests/ui/invalid_pyfunctions.stderr index 271c5a806be..e48c522976a 100644 --- a/tests/ui/invalid_pyfunctions.stderr +++ b/tests/ui/invalid_pyfunctions.stderr @@ -44,7 +44,7 @@ error[E0277]: the trait bound `&str: From tests/ui/invalid_pyfunctions.rs:33:14 | 33 | _string: &str, - | ^ the trait `From>` is not implemented for `&str`, which is required by `BoundRef<'_, '_, pyo3::types::PyModule>: Into<_>` + | ^ the trait `From>` is not implemented for `&str` | = help: the following other types implement trait `From`: `String` implements `From<&String>` diff --git a/tests/ui/invalid_pymethod_receiver.stderr b/tests/ui/invalid_pymethod_receiver.stderr index 9c998403194..7d81c0fae91 100644 --- a/tests/ui/invalid_pymethod_receiver.stderr +++ b/tests/ui/invalid_pymethod_receiver.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `i32: TryFrom>` is not s --> tests/ui/invalid_pymethod_receiver.rs:8:44 | 8 | fn method_with_invalid_self_type(_slf: i32, _py: Python<'_>, _index: u32) {} - | ^^^ the trait `From>` is not implemented for `i32`, which is required by `i32: TryFrom>` + | ^^^ the trait `From>` is not implemented for `i32` | = help: the following other types implement trait `From`: `i32` implements `From` diff --git a/tests/ui/invalid_pymethods.stderr b/tests/ui/invalid_pymethods.stderr index 845b79ed59a..eb8f429c937 100644 --- a/tests/ui/invalid_pymethods.stderr +++ b/tests/ui/invalid_pymethods.stderr @@ -183,7 +183,7 @@ error[E0277]: the trait bound `i32: From>` is not satis --> tests/ui/invalid_pymethods.rs:46:45 | 46 | fn classmethod_wrong_first_argument(_x: i32) -> Self { - | ^^^ the trait `From>` is not implemented for `i32`, which is required by `BoundRef<'_, '_, PyType>: Into<_>` + | ^^^ the trait `From>` is not implemented for `i32` | = help: the following other types implement trait `From`: `i32` implements `From` diff --git a/tests/ui/invalid_result_conversion.stderr b/tests/ui/invalid_result_conversion.stderr index 18667138954..f782e00828f 100644 --- a/tests/ui/invalid_result_conversion.stderr +++ b/tests/ui/invalid_result_conversion.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `PyErr: From` is not satisfied --> tests/ui/invalid_result_conversion.rs:22:25 | 22 | fn should_not_work() -> Result<(), MyError> { - | ^^^^^^ the trait `From` is not implemented for `PyErr`, which is required by `MyError: Into` + | ^^^^^^ the trait `From` is not implemented for `PyErr` | = help: the following other types implement trait `From`: `PyErr` implements `From` diff --git a/tests/ui/not_send.stderr b/tests/ui/not_send.stderr index 8007c2f4e54..5d05b3de059 100644 --- a/tests/ui/not_send.stderr +++ b/tests/ui/not_send.stderr @@ -6,7 +6,7 @@ error[E0277]: `*mut pyo3::Python<'static>` cannot be shared between threads safe | | | required by a bound introduced by this call | - = help: within `pyo3::Python<'_>`, the trait `Sync` is not implemented for `*mut pyo3::Python<'static>`, which is required by `{closure@$DIR/tests/ui/not_send.rs:4:22: 4:24}: Ungil` + = help: within `pyo3::Python<'_>`, the trait `Sync` is not implemented for `*mut pyo3::Python<'static>` note: required because it appears within the type `PhantomData<*mut pyo3::Python<'static>>` --> $RUST/core/src/marker.rs | diff --git a/tests/ui/not_send2.stderr b/tests/ui/not_send2.stderr index 52a4e6a7208..eec2b644e9a 100644 --- a/tests/ui/not_send2.stderr +++ b/tests/ui/not_send2.stderr @@ -9,7 +9,7 @@ error[E0277]: `*mut pyo3::Python<'static>` cannot be shared between threads safe 10 | | }); | |_________^ `*mut pyo3::Python<'static>` cannot be shared between threads safely | - = help: within `pyo3::Bound<'_, PyString>`, the trait `Sync` is not implemented for `*mut pyo3::Python<'static>`, which is required by `{closure@$DIR/tests/ui/not_send2.rs:8:26: 8:28}: Ungil` + = help: within `pyo3::Bound<'_, PyString>`, the trait `Sync` is not implemented for `*mut pyo3::Python<'static>` note: required because it appears within the type `PhantomData<*mut pyo3::Python<'static>>` --> $RUST/core/src/marker.rs | diff --git a/tests/ui/pyclass_send.stderr b/tests/ui/pyclass_send.stderr index 516df060b13..1623a5b2183 100644 --- a/tests/ui/pyclass_send.stderr +++ b/tests/ui/pyclass_send.stderr @@ -4,7 +4,7 @@ error[E0277]: `*mut c_void` cannot be shared between threads safely 5 | struct NotSyncNotSend(*mut c_void); | ^^^^^^^^^^^^^^ `*mut c_void` cannot be shared between threads safely | - = help: within `NotSyncNotSend`, the trait `Sync` is not implemented for `*mut c_void`, which is required by `NotSyncNotSend: Sync` + = help: within `NotSyncNotSend`, the trait `Sync` is not implemented for `*mut c_void` note: required because it appears within the type `NotSyncNotSend` --> tests/ui/pyclass_send.rs:5:8 | @@ -25,7 +25,7 @@ error[E0277]: `*mut c_void` cannot be sent between threads safely 4 | #[pyclass] | ^^^^^^^^^^ `*mut c_void` cannot be sent between threads safely | - = help: within `NotSyncNotSend`, the trait `Send` is not implemented for `*mut c_void`, which is required by `SendablePyClass: pyo3::impl_::pyclass::PyClassThreadChecker` + = help: within `NotSyncNotSend`, the trait `Send` is not implemented for `*mut c_void` = help: the trait `pyo3::impl_::pyclass::PyClassThreadChecker` is implemented for `SendablePyClass` note: required because it appears within the type `NotSyncNotSend` --> tests/ui/pyclass_send.rs:5:8 @@ -46,7 +46,7 @@ error[E0277]: `*mut c_void` cannot be shared between threads safely 8 | struct SendNotSync(*mut c_void); | ^^^^^^^^^^^ `*mut c_void` cannot be shared between threads safely | - = help: within `SendNotSync`, the trait `Sync` is not implemented for `*mut c_void`, which is required by `SendNotSync: Sync` + = help: within `SendNotSync`, the trait `Sync` is not implemented for `*mut c_void` note: required because it appears within the type `SendNotSync` --> tests/ui/pyclass_send.rs:8:8 | @@ -67,7 +67,7 @@ error[E0277]: `*mut c_void` cannot be sent between threads safely 11 | #[pyclass] | ^^^^^^^^^^ `*mut c_void` cannot be sent between threads safely | - = help: within `SyncNotSend`, the trait `Send` is not implemented for `*mut c_void`, which is required by `SendablePyClass: pyo3::impl_::pyclass::PyClassThreadChecker` + = help: within `SyncNotSend`, the trait `Send` is not implemented for `*mut c_void` = help: the trait `pyo3::impl_::pyclass::PyClassThreadChecker` is implemented for `SendablePyClass` note: required because it appears within the type `SyncNotSend` --> tests/ui/pyclass_send.rs:12:8 @@ -88,7 +88,7 @@ error[E0277]: `*mut c_void` cannot be sent between threads safely 4 | #[pyclass] | ^^^^^^^^^^ `*mut c_void` cannot be sent between threads safely | - = help: within `NotSyncNotSend`, the trait `Send` is not implemented for `*mut c_void`, which is required by `NotSyncNotSend: Send` + = help: within `NotSyncNotSend`, the trait `Send` is not implemented for `*mut c_void` note: required because it appears within the type `NotSyncNotSend` --> tests/ui/pyclass_send.rs:5:8 | @@ -107,7 +107,7 @@ error[E0277]: `*mut c_void` cannot be sent between threads safely 11 | #[pyclass] | ^^^^^^^^^^ `*mut c_void` cannot be sent between threads safely | - = help: within `SyncNotSend`, the trait `Send` is not implemented for `*mut c_void`, which is required by `SyncNotSend: Send` + = help: within `SyncNotSend`, the trait `Send` is not implemented for `*mut c_void` note: required because it appears within the type `SyncNotSend` --> tests/ui/pyclass_send.rs:12:8 |