Skip to content

needless_borrow suggesting the same fix as exists in code #7590

Open
@dessalines

Description

@dessalines

Lint name: needless_borrow

I tried this code, which is getting a connection from a deadpool database pool:

let join = CommunityModerator::join(&&context.pool.get().await?, &community_moderator_form);

I expected to see this happen: No clippy warnings.

Instead, this happened:

error: this expression borrows a reference (`&deadpool_diesel::connection::Connection<diesel::pg::connection::PgConnection>`) that is immed
iately dereferenced by the compiler
   --> crates/api_crud/src/user/create.rs:195:43
    |
195 |       let join = CommunityModerator::join(&&context.pool.get().await?, &community_moderator_form);
    |                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: change this to: `&&context.pool.get().await?`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

Its suggesting a fix that's the same as the error

Meta

  • cargo clippy -V: clippy 0.1.56 (ae90dcf 2021-08-09)
  • rustc -Vv:
rustc 1.56.0-nightly (ae90dcf02 2021-08-09)
binary: rustc
commit-hash: ae90dcf0207c57c3034f00b07048d63f8b2363c8
commit-date: 2021-08-09
host: x86_64-unknown-linux-gnu
release: 1.56.0-nightly
LLVM version: 12.0.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingE-mediumCall for participation: Medium difficulty level problem and requires some initial experience.I-false-positiveIssue: The lint was triggered on code it shouldn't have

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions