Skip to content

needless_pass_by_ref_mut false positive in closure in async #11380

Closed
@mkroening

Description

@mkroening

Summary

Another variant of #11179 and #11299.

Found here: hermit-os/kernel/src/fd/socket/tcp.rs#L69-L94

Lint Name

needless_pass_by_ref_mut

Reproducer

I tried this code:

async fn foo(x: &mut i32) {
    (|| *x += 1)();
}

I saw this happen:

warning: this argument is a mutable reference, but not used mutably
 --> foo.rs:1:17
  |
1 | async fn foo(x: &mut i32) {
  |                 ^^^^^^^^ help: consider changing to: `&i32`
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut
  = note: `#[warn(clippy::needless_pass_by_ref_mut)]` on by default

I expected to see this happen:

No needless_pass_by_ref_mut.

Version

rustc 1.74.0-nightly (ef85656a1 2023-08-21)
binary: rustc
commit-hash: ef85656a10657ba5e4f7fe2931a4ca6293138d51
commit-date: 2023-08-21
host: aarch64-apple-darwin
release: 1.74.0-nightly
LLVM version: 17.0.0

Additional Labels

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-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