From 028066d226271b43e53a7272994a6b6c1a7e1085 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Tue, 7 Nov 2023 07:51:59 -0500 Subject: [PATCH] fixes #3561 -- silence new clippy warning --- newsfragments/3564.fixed.md | 1 + pyo3-build-config/src/lib.rs | 4 ++++ pyo3-macros-backend/src/method.rs | 1 + 3 files changed, 6 insertions(+) create mode 100644 newsfragments/3564.fixed.md diff --git a/newsfragments/3564.fixed.md b/newsfragments/3564.fixed.md new file mode 100644 index 00000000000..83e4dba05bb --- /dev/null +++ b/newsfragments/3564.fixed.md @@ -0,0 +1 @@ +Silenced new `clippy::unnecessary_fallible_conversions` warning when using a `Py` `self` receiver diff --git a/pyo3-build-config/src/lib.rs b/pyo3-build-config/src/lib.rs index 576dd37024b..5b91a7283b8 100644 --- a/pyo3-build-config/src/lib.rs +++ b/pyo3-build-config/src/lib.rs @@ -153,6 +153,10 @@ pub fn print_feature_cfgs() { if rustc_minor_version >= 74 { println!("cargo:rustc-cfg=invalid_from_utf8_lint"); } + + if rustc_minor_version >= 75 { + println!("cargo:rustc-cfg=clippy_unnecessary_fallible_conversions_lint"); + } } /// Private exports used in PyO3's build.rs diff --git a/pyo3-macros-backend/src/method.rs b/pyo3-macros-backend/src/method.rs index d8d901bb59f..6e2fefe0f54 100644 --- a/pyo3-macros-backend/src/method.rs +++ b/pyo3-macros-backend/src/method.rs @@ -182,6 +182,7 @@ impl SelfType { .map_err(::std::convert::Into::<_pyo3::PyErr>::into) .and_then( #[allow(clippy::useless_conversion)] // In case slf is PyCell + #[allow(unknown_lints, clippy::unnecessary_fallible_conversions)] // In case slf is Py (unknown_lints can be removed when clippy_unnecessary_fallible_conversions_lint is always available; MSRV 1.75+) |cell| ::std::convert::TryFrom::try_from(cell).map_err(::std::convert::Into::into) )