Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clippy borrow_deref_ref for &PyAny arguments #2555

Closed
stuhood opened this issue Aug 16, 2022 · 2 comments · Fixed by #2575
Closed

Clippy borrow_deref_ref for &PyAny arguments #2555

stuhood opened this issue Aug 16, 2022 · 2 comments · Fixed by #2575
Labels

Comments

@stuhood
Copy link
Contributor

stuhood commented Aug 16, 2022

Bug Description

For code like this:
https://github.com/pantsbuild/pants/blob/c69a70c3837e5fdecdae5d3a0475a5e6fdfcf20f/src/rust/engine/src/externs/mod.rs#L298

... clippy under Rust 1.63.0 renders an error like the following:

error: deref on an immutable reference
   --> src/externs/mod.rs:298:17
    |
298 |     input_arg0: &PyAny,
    |                 ^ help: if you would like to reborrow, try removing `&*`: `&`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#borrow_deref_ref

Steps to Reproduce

  1. Check out pantsbuild/pants@main...stuhood:pants:stuhood/bump-to-rust-1.63.0-clippy-error
  2. Run ./cargo clippy (note the ./, which refers to a wrapper script to set up env vars)

Your operating system and version

macOS 11.6.8

Your Python version (python --version)

Python 3.7

Your Rust version (rustc --version)

1.63.0

Your PyO3 version

0.16.5

How did you install python? Did you use a virtualenv?

pyenv

Additional Info

No response

@davidhewitt
Copy link
Member

Ungh, yes, sorry about this. It's actually already fixed on main and I'm seeking to release 0.17 ASAP which will resolve (just working on a couple of other fixes to resolve at the same time). See #2493

@stuhood
Copy link
Contributor Author

stuhood commented Aug 16, 2022

Got it: thanks a lot! The workaround (skipping this clippy lint) is not onerous, so don't rush on our account.

thomaskrause added a commit to korpling/annatto that referenced this issue Jan 20, 2023
vlaci added a commit to onekey-sec/unblob that referenced this issue Apr 25, 2023
It tripped[^1] on clippy lints on Rustc 1.63:

    error: deref on an immutable reference
     --> rust/src/lib.rs:7:30
      |
    7 | pub fn shannon_entropy(data: &[u8]) -> PyResult<f64> {
      |                              ^ help: if you would like to reborrow, try removing `&*`: `&`
      |
      = note: `-D clippy::borrow-deref-ref` implied by `-D warnings`
      = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#borrow_deref_ref

    error: could not compile `unblob-rust` due to previous error

[^1]: PyO3/pyo3#2555
vlaci added a commit to onekey-sec/unblob that referenced this issue Apr 25, 2023
It tripped[^1] on clippy lints on Rustc 1.63:

    error: deref on an immutable reference
     --> rust/src/lib.rs:7:30
      |
    7 | pub fn shannon_entropy(data: &[u8]) -> PyResult<f64> {
      |                              ^ help: if you would like to reborrow, try removing `&*`: `&`
      |
      = note: `-D clippy::borrow-deref-ref` implied by `-D warnings`
      = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#borrow_deref_ref

    error: could not compile `unblob-rust` due to previous error

[^1]: PyO3/pyo3#2555
vlaci added a commit to onekey-sec/unblob that referenced this issue Apr 25, 2023
It tripped[^1] on clippy lints on Rustc 1.63:

    error: deref on an immutable reference
     --> rust/src/lib.rs:7:30
      |
    7 | pub fn shannon_entropy(data: &[u8]) -> PyResult<f64> {
      |                              ^ help: if you would like to reborrow, try removing `&*`: `&`
      |
      = note: `-D clippy::borrow-deref-ref` implied by `-D warnings`
      = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#borrow_deref_ref

    error: could not compile `unblob-rust` due to previous error

[^1]: PyO3/pyo3#2555
vlaci added a commit to onekey-sec/unblob that referenced this issue Apr 25, 2023
It tripped[^1] on clippy lints on Rustc 1.63:

    error: deref on an immutable reference
     --> rust/src/lib.rs:7:30
      |
    7 | pub fn shannon_entropy(data: &[u8]) -> PyResult<f64> {
      |                              ^ help: if you would like to reborrow, try removing `&*`: `&`
      |
      = note: `-D clippy::borrow-deref-ref` implied by `-D warnings`
      = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#borrow_deref_ref

    error: could not compile `unblob-rust` due to previous error

[^1]: PyO3/pyo3#2555
vlaci added a commit to onekey-sec/unblob that referenced this issue Apr 25, 2023
It tripped[^1] on clippy lints on Rustc 1.63:

    error: deref on an immutable reference
     --> rust/src/lib.rs:7:30
      |
    7 | pub fn shannon_entropy(data: &[u8]) -> PyResult<f64> {
      |                              ^ help: if you would like to reborrow, try removing `&*`: `&`
      |
      = note: `-D clippy::borrow-deref-ref` implied by `-D warnings`
      = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#borrow_deref_ref

    error: could not compile `unblob-rust` due to previous error

[^1]: PyO3/pyo3#2555
vlaci added a commit to onekey-sec/unblob that referenced this issue Apr 25, 2023
It tripped[^1] on clippy lints on Rustc 1.63:

    error: deref on an immutable reference
     --> rust/src/lib.rs:7:30
      |
    7 | pub fn shannon_entropy(data: &[u8]) -> PyResult<f64> {
      |                              ^ help: if you would like to reborrow, try removing `&*`: `&`
      |
      = note: `-D clippy::borrow-deref-ref` implied by `-D warnings`
      = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#borrow_deref_ref

    error: could not compile `unblob-rust` due to previous error

[^1]: PyO3/pyo3#2555
vlaci added a commit to onekey-sec/unblob that referenced this issue Apr 25, 2023
It tripped[^1] on clippy lints on Rustc 1.63:

    error: deref on an immutable reference
     --> rust/src/lib.rs:7:30
      |
    7 | pub fn shannon_entropy(data: &[u8]) -> PyResult<f64> {
      |                              ^ help: if you would like to reborrow, try removing `&*`: `&`
      |
      = note: `-D clippy::borrow-deref-ref` implied by `-D warnings`
      = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#borrow_deref_ref

    error: could not compile `unblob-rust` due to previous error

[^1]: PyO3/pyo3#2555
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants