diff --git a/.cargo/config b/.cargo/config index 9d7fa21a471..dd778a9e4c1 100644 --- a/.cargo/config +++ b/.cargo/config @@ -3,6 +3,7 @@ xtask = "run --package xtask --" [target.'cfg(feature = "cargo-clippy")'] rustflags = [ + "-Aclippy::needless_borrow", # TODO: remove once msrv increased from 1.48 "-Dclippy::checked_conversions", "-Dclippy::dbg_macro", "-Dclippy::explicit_into_iter_loop", diff --git a/pyo3-build-config/src/impl_.rs b/pyo3-build-config/src/impl_.rs index c94770b1e6d..307565856e5 100644 --- a/pyo3-build-config/src/impl_.rs +++ b/pyo3-build-config/src/impl_.rs @@ -1182,7 +1182,7 @@ impl Sysconfigdata { /// [`from_sysconfigdata`](InterpreterConfig::from_sysconfigdata). pub fn parse_sysconfigdata(sysconfigdata_path: impl AsRef) -> Result { let sysconfigdata_path = sysconfigdata_path.as_ref(); - let mut script = fs::read_to_string(&sysconfigdata_path).with_context(|| { + let mut script = fs::read_to_string(sysconfigdata_path).with_context(|| { format!( "failed to read config from {}", sysconfigdata_path.display() diff --git a/pyo3-build-config/src/lib.rs b/pyo3-build-config/src/lib.rs index ef7d58d0ca8..8a6f11248db 100644 --- a/pyo3-build-config/src/lib.rs +++ b/pyo3-build-config/src/lib.rs @@ -200,7 +200,7 @@ pub mod pyo3_build_script_impl { path.display() ) })?; - std::fs::create_dir_all(&parent_dir).with_context(|| { + std::fs::create_dir_all(parent_dir).with_context(|| { format!( "failed to create config file directory {}", parent_dir.display() diff --git a/pyo3-ffi/src/cpython/unicodeobject.rs b/pyo3-ffi/src/cpython/unicodeobject.rs index 1fdbe521daa..9ec21bf6989 100644 --- a/pyo3-ffi/src/cpython/unicodeobject.rs +++ b/pyo3-ffi/src/cpython/unicodeobject.rs @@ -137,11 +137,7 @@ pub unsafe fn PyUnicode_IS_COMPACT(op: *mut PyObject) -> c_uint { #[inline] #[cfg(target_endian = "little")] pub unsafe fn PyUnicode_IS_COMPACT_ASCII(op: *mut PyObject) -> c_uint { - if (*(op as *mut PyASCIIObject)).ascii() != 0 && PyUnicode_IS_COMPACT(op) != 0 { - 1 - } else { - 0 - } + ((*(op as *mut PyASCIIObject)).ascii() != 0 && PyUnicode_IS_COMPACT(op) != 0).into() } #[cfg(not(Py_3_12))] diff --git a/tests/ui/missing_intopy.stderr b/tests/ui/missing_intopy.stderr index 493f3e61de8..f9a90788117 100644 --- a/tests/ui/missing_intopy.stderr +++ b/tests/ui/missing_intopy.stderr @@ -2,9 +2,9 @@ error[E0599]: the method `assert_into_py_result` exists for struct `Blah`, but i --> tests/ui/missing_intopy.rs:3:1 | 1 | struct Blah; - | ------------ + | ----------- | | - | method `assert_into_py_result` not found for this + | method `assert_into_py_result` not found for this struct | doesn't satisfy `Blah: IntoPy>` | doesn't satisfy `Blah: IntoPyResult` 2 | @@ -17,14 +17,8 @@ error[E0599]: the method `assert_into_py_result` exists for struct `Blah`, but i note: the following trait must be implemented --> src/conversion.rs | - | / pub trait IntoPy: Sized { - | | /// Performs the conversion. - | | fn into_py(self, py: Python<'_>) -> T; - | | -... | - | | } - | | } - | |_^ + | pub trait IntoPy: Sized { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: this error originates in the attribute macro `pyo3::pyfunction` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `Blah: IntoPyCallbackOutput<_>` is not satisfied diff --git a/tests/ui/not_send.stderr b/tests/ui/not_send.stderr index a287f26dcc1..6f7c41d3b00 100644 --- a/tests/ui/not_send.stderr +++ b/tests/ui/not_send.stderr @@ -15,8 +15,8 @@ note: required because it's used within this closure --> tests/ui/not_send.rs:4:22 | 4 | py.allow_threads(|| { drop(py); }); - | ^^^^^^^^^^^^^^^^ - = note: required because of the requirements on the impl of `Ungil` for `[closure@$DIR/tests/ui/not_send.rs:4:22: 4:38]` + | ^^ + = note: required because of the requirements on the impl of `Ungil` for `[closure@$DIR/tests/ui/not_send.rs:4:22: 4:24]` note: required by a bound in `pyo3::Python::<'py>::allow_threads` --> src/marker.rs | diff --git a/tests/ui/not_send2.stderr b/tests/ui/not_send2.stderr index d07352383f5..7d229d51dc8 100644 --- a/tests/ui/not_send2.stderr +++ b/tests/ui/not_send2.stderr @@ -12,12 +12,9 @@ error[E0277]: `UnsafeCell` cannot be shared between threads safely note: required because it's used within this closure --> tests/ui/not_send2.rs:8:26 | -8 | py.allow_threads(|| { - | __________________________^ -9 | | println!("{:?}", string); -10 | | }); - | |_________^ - = note: required because of the requirements on the impl of `Ungil` for `[closure@$DIR/tests/ui/not_send2.rs:8:26: 10:10]` +8 | py.allow_threads(|| { + | ^^ + = note: required because of the requirements on the impl of `Ungil` for `[closure@$DIR/tests/ui/not_send2.rs:8:26: 8:28]` note: required by a bound in `pyo3::Python::<'py>::allow_threads` --> src/marker.rs | diff --git a/tests/ui/not_send3.stderr b/tests/ui/not_send3.stderr index 0ea0fa483ca..0cd88e51612 100644 --- a/tests/ui/not_send3.stderr +++ b/tests/ui/not_send3.stderr @@ -9,12 +9,9 @@ error[E0277]: `Rc` cannot be shared between threads safely note: required because it's used within this closure --> tests/ui/not_send3.rs:8:26 | -8 | py.allow_threads(|| { - | __________________________^ -9 | | println!("{:?}", rc); -10 | | }); - | |_________^ - = note: required because of the requirements on the impl of `Ungil` for `[closure@$DIR/tests/ui/not_send3.rs:8:26: 10:10]` +8 | py.allow_threads(|| { + | ^^ + = note: required because of the requirements on the impl of `Ungil` for `[closure@$DIR/tests/ui/not_send3.rs:8:26: 8:28]` note: required by a bound in `pyo3::Python::<'py>::allow_threads` --> src/marker.rs | diff --git a/xtask/src/doc.rs b/xtask/src/doc.rs index efc35ee6618..6d05acf4fca 100644 --- a/xtask/src/doc.rs +++ b/xtask/src/doc.rs @@ -38,7 +38,7 @@ pub fn run(opts: DocOpts) -> anyhow::Result<()> { "unstable-options", "-Z", "rustdoc-scrape-examples=examples", - ] + ][..] }) .args(if opts.open { Some("--open") } else { None }), )?;