Skip to content

suspicious_double_ref_op doesn't give warning in generic context #112364

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

Closed
safinaskar opened this issue Jun 6, 2023 · 3 comments
Closed

suspicious_double_ref_op doesn't give warning in generic context #112364

safinaskar opened this issue Jun 6, 2023 · 3 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@safinaskar
Copy link
Contributor

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

@safinaskar safinaskar added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 6, 2023
@safinaskar
Copy link
Contributor Author

@rustbot label +A-lint

@rustbot rustbot added the A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. label Jun 6, 2023
@QuineDot
Copy link

QuineDot commented Dec 3, 2023

The noop_method_call lint covers this scenario.

Playground.

@safinaskar
Copy link
Contributor Author

Yes, the bug is now fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants