Skip to content

Useless conversion error when using PyResult<PyObject> in pyo3 #14272

Closed
@edlng

Description

@edlng

Summary

In rustc v1.84 we didn't have this issue but after upgrading to 1.85, we started getting this error. Downgrading back to 1.84 seemed to fix the issue.

Reproducer

For example I tried this dummy code:

  #[pyfunction]
  fn sum_as_string(py: Python) -> PyResult<PyObject> {
      let py_dict = PyDict::new_bound(py);

      Ok(py_dict.into_py(py))
  }

I expected to see no warnings or errors

Instead, this happened:

error: useless conversion to the same type: `pyo3::PyErr`
   --> src/lib.rs:160:45
    |
160 |     fn sum_as_string(py: Python) -> PyResult<PyObject> {
    |                                             ^ help: consider removing
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion

Version


Additional Labels

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions