rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
96.96k stars 12.53k forks source link

FromRawFd is missing a safety section #130647

Open lolbinarycat opened 4 hours ago

lolbinarycat commented 4 hours ago

Location

https://doc.rust-lang.org/std/os/fd/trait.FromRawFd.html#tymethod.from_raw_fd

Summary

the usage of unsafe implies there is some unchecked precondition(s) that must be true to prevent UB, but there is no documentation saying what this precondition might be.

this means there's basically no way to know if you are using this interface soundly.

PatchMixolydic commented 4 hours ago

There appears to be a safety section on my end:

Safety

The fd passed in must be an owned file descriptor; in particular, it must be open.