Docs enhancement: misleading try_clone docs #77520
Labels
A-docs
Area: Documentation for any part of the project, including the compiler, standard library, and tools
A-io
Area: `std::io`, `std::fs`, `std::net` and `std::path`
C-bug
Category: This is a bug.
T-libs-api
Relevant to the library API team, which will review and decide on the PR/issue.
try_clone says it "Creates a new
File
instance that shares the same underlying file handle as the existingFile
instance."However, #45536 notes that it calls DuplicateHandle and fcntl F_DUPFD_CLOEXEC on Windows and other OSes respectively. Those calls create new handles, which point to the same operating system descriptor (file, socket etc).
The distinction is potentially important: file system behaviours that can cause IO latency may be hooked in on syscalls like close() - we've spent considerable time in rustup dealing with virus scanners and NFS for two examples.
I think the documentation should at a minimum say 'new operating system handle cloned from the existing one', or some such. Ideally it would, like other calls do, just say what calls are used: this is clear and unambiguous, and would also solve the problem raised in bug 45536 about documentation about when it may fail by letting folk go and read the underlying syscall documentation.
Meta
This is present still in git. https://doc.rust-lang.org/src/std/fs.rs.html#548
The text was updated successfully, but these errors were encountered: