Skip to content

Docs enhancement: misleading try_clone docs #77520

Open
@rbtcollins

Description

@rbtcollins

try_clone says it "Creates a new File instance that shares the same underlying file handle as the existing File 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsA-ioArea: `std::io`, `std::fs`, `std::net` and `std::path`C-bugCategory: This is a bug.T-libs-apiRelevant to the library API 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