From c4a2c6c912e850b453f3a6ba75745d726781aaae Mon Sep 17 00:00:00 2001 From: David Hewitt <1939362+davidhewitt@users.noreply.github.com> Date: Tue, 12 Jul 2022 23:01:38 +0100 Subject: [PATCH 1/3] clippy: fix some warnings from beta toolchain --- pyo3-build-config/src/impl_.rs | 8 ++++---- pyo3-macros-backend/src/attributes.rs | 4 ++-- pyo3-macros-backend/src/pyfunction.rs | 2 +- src/pycell.rs | 2 +- src/types/string.rs | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pyo3-build-config/src/impl_.rs b/pyo3-build-config/src/impl_.rs index 24e8a764..8fde0412 100644 --- a/pyo3-build-config/src/impl_.rs +++ b/pyo3-build-config/src/impl_.rs @@ -69,7 +69,7 @@ pub fn target_triple_from_env() -> Triple { /// /// When the `PYO3_NO_PYTHON` variable is set, or during cross compile situations, then alternative /// strategies are used to populate this type. -#[cfg_attr(test, derive(Debug, PartialEq))] +#[cfg_attr(test, derive(Debug, PartialEq, Eq))] pub struct InterpreterConfig { /// The Python implementation flavor. /// @@ -634,7 +634,7 @@ impl FromStr for PythonVersion { } } -#[derive(Debug, Copy, Clone, PartialEq)] +#[derive(Debug, Copy, Clone, PartialEq, Eq)] pub enum PythonImplementation { CPython, PyPy, @@ -742,7 +742,7 @@ fn require_libdir_for_target(target: &Triple) -> bool { /// /// Usually this is collected from the environment (i.e. `PYO3_CROSS_*` and `CARGO_CFG_TARGET_*`) /// when a cross-compilation configuration is detected. -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub struct CrossCompileConfig { /// The directory containing the Python library to link against. pub lib_dir: Option, @@ -1036,7 +1036,7 @@ impl FromStr for BuildFlag { /// is the equivalent of `#ifdef {varname}` in C. /// /// see Misc/SpecialBuilds.txt in the python source for what these mean. -#[cfg_attr(test, derive(Debug, PartialEq))] +#[cfg_attr(test, derive(Debug, PartialEq, Eq))] #[derive(Clone, Default)] pub struct BuildFlags(pub HashSet); diff --git a/pyo3-macros-backend/src/attributes.rs b/pyo3-macros-backend/src/attributes.rs index 42efade0..90192743 100644 --- a/pyo3-macros-backend/src/attributes.rs +++ b/pyo3-macros-backend/src/attributes.rs @@ -40,7 +40,7 @@ pub struct KeywordAttribute { /// A helper type which parses the inner type via a literal string /// e.g. LitStrValue -> parses "some::path" in quotes. -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct LitStrValue(pub T); impl Parse for LitStrValue { @@ -57,7 +57,7 @@ impl ToTokens for LitStrValue { } /// A helper type which parses a name via a literal string -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct NameLitStr(pub Ident); impl Parse for NameLitStr { diff --git a/pyo3-macros-backend/src/pyfunction.rs b/pyo3-macros-backend/src/pyfunction.rs index f3138e94..c97495b1 100644 --- a/pyo3-macros-backend/src/pyfunction.rs +++ b/pyo3-macros-backend/src/pyfunction.rs @@ -21,7 +21,7 @@ use syn::{ token::Comma, }; -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub enum Argument { PosOnlyArgsSeparator, VarArgsSeparator, diff --git a/src/pycell.rs b/src/pycell.rs index b42cbe37..11f05eb5 100644 --- a/src/pycell.rs +++ b/src/pycell.rs @@ -964,7 +964,7 @@ impl<'a, T: PyClass> std::convert::TryFrom<&'a PyCell> impl + fmt::Debug> fmt::Debug for PyRefMut<'_, T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - fmt::Debug::fmt(&*(self.deref()), f) + fmt::Debug::fmt(self.deref(), f) } } diff --git a/src/types/string.rs b/src/types/string.rs index d195f1d2..1cd7a149 100644 --- a/src/types/string.rs +++ b/src/types/string.rs @@ -16,7 +16,7 @@ use std::str; /// Python internally stores strings in various representations. This enumeration /// represents those variations. #[cfg(all(not(Py_LIMITED_API), target_endian = "little"))] -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum PyStringData<'a> { /// UCS1 representation. Ucs1(&'a [u8]), From dae23ea08db30394a3a343d218f7bd0d83ce2c9d Mon Sep 17 00:00:00 2001 From: David Hewitt <1939362+davidhewitt@users.noreply.github.com> Date: Wed, 13 Jul 2022 06:17:04 +0100 Subject: [PATCH 2/3] ci: fix build MSRV with hashbrown 0.12.2 release --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 565a9317..04988c89 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -181,7 +181,7 @@ jobs: run: | set -x cargo update -p indexmap --precise 1.6.2 - cargo update -p hashbrown:0.12.1 --precise 0.9.1 + cargo update -p hashbrown:0.12.2 --precise 0.9.1 PROJECTS=("." "examples/decorator" "examples/maturin-starter" "examples/setuptools-rust-starter" "examples/word-count") for PROJ in ${PROJECTS[@]}; do cargo update --manifest-path "$PROJ/Cargo.toml" -p parking_lot --precise 0.11.0 From 97ce1f6892e0366c59664c53d30f4648ca76bce0 Mon Sep 17 00:00:00 2001 From: David Hewitt <1939362+davidhewitt@users.noreply.github.com> Date: Wed, 13 Jul 2022 08:06:14 +0100 Subject: [PATCH 3/3] ci: fix nightly UI tests --- tests/ui/not_send_auto_trait.stderr | 8 ++++---- tests/ui/not_send_auto_trait2.stderr | 20 +++++++------------- tests/ui/send_wrapper.stderr | 22 +++++++--------------- 3 files changed, 18 insertions(+), 32 deletions(-) diff --git a/tests/ui/not_send_auto_trait.stderr b/tests/ui/not_send_auto_trait.stderr index b9818672..a769d7e8 100644 --- a/tests/ui/not_send_auto_trait.stderr +++ b/tests/ui/not_send_auto_trait.stderr @@ -1,17 +1,17 @@ -error[E0277]: the trait bound `pyo3::Python<'_>: Ungil` is not satisfied in `[closure@$DIR/tests/ui/not_send_auto_trait.rs:4:22: 4:38]` +error[E0277]: the trait bound `pyo3::Python<'_>: Ungil` is not satisfied in `[closure@$DIR/tests/ui/not_send_auto_trait.rs:4:22: 4:24]` --> tests/ui/not_send_auto_trait.rs:4:8 | 4 | py.allow_threads(|| { drop(py); }); - | ^^^^^^^^^^^^^ ---------------- within this `[closure@$DIR/tests/ui/not_send_auto_trait.rs:4:22: 4:38]` + | ^^^^^^^^^^^^^ -- within this `[closure@$DIR/tests/ui/not_send_auto_trait.rs:4:22: 4:24]` | | - | within `[closure@$DIR/tests/ui/not_send_auto_trait.rs:4:22: 4:38]`, the trait `Ungil` is not implemented for `pyo3::Python<'_>` + | within `[closure@$DIR/tests/ui/not_send_auto_trait.rs:4:22: 4:24]`, the trait `Ungil` is not implemented for `pyo3::Python<'_>` | = note: required because it appears within the type `&pyo3::Python<'_>` note: required because it's used within this closure --> tests/ui/not_send_auto_trait.rs:4:22 | 4 | py.allow_threads(|| { drop(py); }); - | ^^^^^^^^^^^^^^^^ + | ^^ note: required by a bound in `pyo3::Python::<'py>::allow_threads` --> src/marker.rs | diff --git a/tests/ui/not_send_auto_trait2.stderr b/tests/ui/not_send_auto_trait2.stderr index 1b721350..3aedb37c 100644 --- a/tests/ui/not_send_auto_trait2.stderr +++ b/tests/ui/not_send_auto_trait2.stderr @@ -1,13 +1,10 @@ -error[E0277]: the trait bound `PyAny: Ungil` is not satisfied in `[closure@$DIR/tests/ui/not_send_auto_trait2.rs:8:26: 10:10]` +error[E0277]: the trait bound `PyAny: Ungil` is not satisfied in `[closure@$DIR/tests/ui/not_send_auto_trait2.rs:8:26: 8:28]` --> tests/ui/not_send_auto_trait2.rs:8:12 | -8 | py.allow_threads(|| { - | ____________^^^^^^^^^^^^^_- - | | | - | | within `[closure@$DIR/tests/ui/not_send_auto_trait2.rs:8:26: 10:10]`, the trait `Ungil` is not implemented for `PyAny` -9 | | println!("{:?}", string); -10 | | }); - | |_________- within this `[closure@$DIR/tests/ui/not_send_auto_trait2.rs:8:26: 10:10]` +8 | py.allow_threads(|| { + | ^^^^^^^^^^^^^ -- within this `[closure@$DIR/tests/ui/not_send_auto_trait2.rs:8:26: 8:28]` + | | + | within `[closure@$DIR/tests/ui/not_send_auto_trait2.rs:8:26: 8:28]`, the trait `Ungil` is not implemented for `PyAny` | = note: required because it appears within the type `PyString` = note: required because it appears within the type `&PyString` @@ -15,11 +12,8 @@ error[E0277]: the trait bound `PyAny: Ungil` is not satisfied in `[closure@$DIR/ note: required because it's used within this closure --> tests/ui/not_send_auto_trait2.rs:8:26 | -8 | py.allow_threads(|| { - | __________________________^ -9 | | println!("{:?}", string); -10 | | }); - | |_________^ +8 | py.allow_threads(|| { + | ^^ note: required by a bound in `pyo3::Python::<'py>::allow_threads` --> src/marker.rs | diff --git a/tests/ui/send_wrapper.stderr b/tests/ui/send_wrapper.stderr index 23dceb2a..b24fb106 100644 --- a/tests/ui/send_wrapper.stderr +++ b/tests/ui/send_wrapper.stderr @@ -1,14 +1,10 @@ -error[E0277]: the trait bound `PyAny: Ungil` is not satisfied in `[closure@$DIR/tests/ui/send_wrapper.rs:11:26: 14:10]` +error[E0277]: the trait bound `PyAny: Ungil` is not satisfied in `[closure@$DIR/tests/ui/send_wrapper.rs:11:26: 11:28]` --> tests/ui/send_wrapper.rs:11:12 | -11 | py.allow_threads(|| { - | ____________^^^^^^^^^^^^^_- - | | | - | | within `[closure@$DIR/tests/ui/send_wrapper.rs:11:26: 14:10]`, the trait `Ungil` is not implemented for `PyAny` -12 | | let smuggled: &PyString = *wrapped; -13 | | println!("{:?}", smuggled); -14 | | }); - | |_________- within this `[closure@$DIR/tests/ui/send_wrapper.rs:11:26: 14:10]` +11 | py.allow_threads(|| { + | ^^^^^^^^^^^^^ -- within this `[closure@$DIR/tests/ui/send_wrapper.rs:11:26: 11:28]` + | | + | within `[closure@$DIR/tests/ui/send_wrapper.rs:11:26: 11:28]`, the trait `Ungil` is not implemented for `PyAny` | = note: required because it appears within the type `PyString` = note: required because it appears within the type `&PyString` @@ -18,12 +14,8 @@ error[E0277]: the trait bound `PyAny: Ungil` is not satisfied in `[closure@$DIR/ note: required because it's used within this closure --> tests/ui/send_wrapper.rs:11:26 | -11 | py.allow_threads(|| { - | __________________________^ -12 | | let smuggled: &PyString = *wrapped; -13 | | println!("{:?}", smuggled); -14 | | }); - | |_________^ +11 | py.allow_threads(|| { + | ^^ note: required by a bound in `pyo3::Python::<'py>::allow_threads` --> src/marker.rs |