Skip to content

suspicious_double_ref_op doesn't give warning in generic context #112364

Closed
@safinaskar

Description

@safinaskar

Code

#![deny(suspicious_double_ref_op)]

fn f<T>(a: &T) {
    a.clone();
}

fn main() {
}

Current output

warning: function `f` is never used
 --> src/main.rs:3:4
  |
3 | fn f<T>(a: &T) {
  |    ^
  |
  = note: `#[warn(dead_code)]` on by default

warning: unused return value of `clone` that must be used
 --> src/main.rs:4:5
  |
4 |     a.clone();
  |     ^^^^^^^^^
  |
  = note: cloning is often expensive and is not expected to have side effects
  = note: `#[warn(unused_must_use)]` on by default
help: use `let _ = ...` to ignore the resulting value
  |
4 |     let _ = a.clone();
  |     +++++++

warning: `lii` (bin "lii") generated 2 warnings
    Finished dev [unoptimized + debuginfo] target(s) in 0.25s

Desired output

No response

Rationale and extra context

This is exactly situation where suspicious_double_ref_op should trigger. But it does not. CC @fee1-dead

rustc version: rustc 1.72.0-nightly (e6d4725c7 2023-06-05)

Other cases

No response

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions