-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Code
use std::io::Write;
pub fn f(file: &std::fs::File) {
_ = file.clone().write(&[]);
}
Current output
warning: using `.clone()` on a double reference, which returns `&mut &File` instead of cloning the inner type
--> src\lib.rs:4:13
|
4 | _ = file.clone().write(&[]);
| ^^^^^^^^
|
= note: `#[warn(suspicious_double_ref_op)]` on by default
Desired output
warning: using `.clone()` on a double reference, which returns `&File` instead of cloning the inner type
Rationale and extra context
The return type of file.clone()
is &File
, but the message strangely claims it is &mut &File
, which happens to be the the receiver type of the write
call (from impl Write for &File
).
Other cases
Rust Version
rustc 1.89.0 (29483883e 2025-08-04)
binary: rustc
commit-hash: 29483883eed69d5fb4db01964cdf2af4d86e9cb2
commit-date: 2025-08-04
host: x86_64-pc-windows-msvc
release: 1.89.0
LLVM version: 20.1.7
Anything else?
No response
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.