@@ -31,17 +31,22 @@ pub trait FromRawFd {
3131 /// Constructs a new instance of `Self` from the given raw file
3232 /// descriptor and metadata.
3333 ///
34- /// This function **consumes [ownership][io-safety]** of the specified file
35- /// descriptor. The returned object will take responsibility for closing
36- /// it when the object goes out of scope.
34+ /// This function is typically used to **consume ownership** of the
35+ /// specified file descriptor. When used in this way, the returned object
36+ /// will take responsibility for closing it when the object goes out of
37+ /// scope.
3738 ///
38- /// [io-safety]: crate::io#io-safety
39+ /// However, consuming ownership is not strictly required. Use a
40+ /// [`From<OwnedFd>::from`] implementation for an API which strictly
41+ /// consumes ownership.
3942 ///
40- /// This function is also unsafe as the primitives currently returned
41- /// have the contract that they are the sole owner of the file
42- /// descriptor they are wrapping. Usage of this function could
43- /// accidentally allow violating this contract which can cause memory
44- /// unsafety in code that relies on it being true.
43+ /// # Safety
44+ ///
45+ /// The `fd` passed in must be an [owned file descriptor][io-safety];
46+ /// in particular, it must be open.
47+ // FIXME: say something about `metadata`.
48+ ///
49+ /// [io-safety]: io#io-safety
4550 #[ unstable( feature = "sgx_platform" , issue = "56975" ) ]
4651 unsafe fn from_raw_fd ( fd : RawFd , metadata : Self :: Metadata ) -> Self ;
4752}
0 commit comments