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
Code
Current output
Desired output
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 thewritecall (fromimpl Write for &File).Other cases
Rust Version
Anything else?
No response