Summary
rust-clippy with 1.75 could emit false positive of unnecessary_fallible_conversions for pyo3:
warning: use of a fallible conversion when an infallible one could be used
--> bindings/python/src/file.rs:180:27
|
180 | pub fn __enter__(slf: Py<Self>) -> Py<Self> {
| ^^ help: use: `From::from`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_fallible_conversions
= note: `#[warn(clippy::unnecessary_fallible_conversions)]` on by default
warning: `opendal-python` (lib test) generated 1 warning
warning: `opendal-python` (lib) generated 1 warning (1 duplicate)
It's bit confused to raising unnecessary_fallible_conversions on API like this:
pub fn __enter__(slf: Py<Self>) -> Py<Self> {
slf
}
Py is a transparent struct expose by pyo3: https://docs.rs/pyo3/latest/pyo3/struct.Py.html
Lint Name
unnecessary_fallible_conversions
Reproducer
I tried this code:
pub fn __enter__(slf: Py<Self>) -> Py<Self> {
slf
}
I saw this happen:
warning: use of a fallible conversion when an infallible one could be used
--> bindings/python/src/file.rs:180:27
|
180 | pub fn __enter__(slf: Py<Self>) -> Py<Self> {
| ^^ help: use: `From::from`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_fallible_conversions
= note: `#[warn(clippy::unnecessary_fallible_conversions)]` on by default
warning: `opendal-python` (lib test) generated 1 warning
warning: `opendal-python` (lib) generated 1 warning (1 duplicate)
I expected to see this happen: no warning
Version
rustc 1.75.0 (82e1608df 2023-12-21)
binary: rustc
commit-hash: 82e1608dfa6e0b5569232559e3d385fea5a93112
commit-date: 2023-12-21
host: x86_64-unknown-linux-gnu
release: 1.75.0
LLVM version: 17.0.6
Additional Labels
No response
Summary
rust-clippy with 1.75 could emit false positive of
unnecessary_fallible_conversionsfor pyo3:It's bit confused to raising
unnecessary_fallible_conversionson API like this:Pyis a transparent struct expose by pyo3: https://docs.rs/pyo3/latest/pyo3/struct.Py.htmlLint Name
unnecessary_fallible_conversions
Reproducer
I tried this code:
I saw this happen:
I expected to see this happen: no warning
Version
Additional Labels
No response