Skip to content

Regression in checking for unneccessary mutable references #114405

Closed
@davidv1992

Description

@davidv1992

Code

Checking the github.com/pendulum-project/statime repository with cargo clippy on nightly-2023-08-02 finds two warnings for unneeded mutable references. One of these is genuine, but the other is a false alarm.

Output:

warning: this argument is a mutable reference, but not used mutably
  --> statime-linux/src/network/timestamped_udp_socket.rs:36:55
   |
36 |     pub async fn recv(&self, clock: &LinuxClock, buf: &mut [u8]) -> std::io::Result<RecvResult> {
   |                                                       ^^^^^^^^^ help: consider changing to: `&[u8]`
   |
   = 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

warning: `statime-linux` (lib) generated 1 warning
warning: this argument is a mutable reference, but not used mutably
   --> statime-linux/src/main.rs:341:18
    |
341 |     local_clock: &mut LinuxClock,
    |                  ^^^^^^^^^^^^^^^ help: consider changing to: `&LinuxClock`
    |
    = 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

warning: `statime-linux` (bin "statime-linux") generated 1 warning

of these, the warning on recv is the false alarm (the mut is very much needed on that function, as one would expect for a function called recv)

Version it worked on

rustc +nightly-2023-08-01 --version --verbose:

rustc 1.73.0-nightly (db7ff98a7 2023-07-31)
binary: rustc
commit-hash: db7ff98a72f3e742b641f9cb16d0e8c285e87e9b
commit-date: 2023-07-31
host: x86_64-unknown-linux-gnu
release: 1.73.0-nightly
LLVM version: 16.0.5

Version with regression

rustc +nightly-2023-08-02 --version --verbose:

rustc 1.73.0-nightly (d12c6e947 2023-08-01)
binary: rustc
commit-hash: d12c6e947ceacf3b22c154caf9532b390d8dc88a
commit-date: 2023-08-01
host: x86_64-unknown-linux-gnu
release: 1.73.0-nightly
LLVM version: 16.0.5

@rustbot modify labels: +regression-from-stable-to-nightly -regression-untriaged

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-clippyArea: ClippyC-bugCategory: This is a bug.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions