From 6d65379e7a5da8f118803bab5618b6c68994ad37 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 22 Aug 2023 09:00:07 +0200 Subject: [PATCH] clarify what you cannot do --- library/std/src/io/mod.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/std/src/io/mod.rs b/library/std/src/io/mod.rs index 4c599cbc1aa4b..35f5855d7f940 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -255,9 +255,9 @@ //! The platform-specific parts of the Rust standard library expose types that reflect these //! concepts, see [`os::unix`] and [`os::windows`]. //! -//! To uphold I/O safety, it is crucial that no code acts on file descriptors it does not own. In -//! other words, a safe function that takes a regular integer, treats it as a file descriptor, and -//! acts on it, is *unsound*. +//! To uphold I/O safety, it is crucial that no code acts on file descriptors it does not own or +//! borrow, and no code closes file descriptors it does not own. In other words, a safe function +//! that takes a regular integer, treats it as a file descriptor, and acts on it, is *unsound*. //! //! Not upholding I/O safety and acting on a file descriptor without proof of ownership can lead to //! misbehavior and even Undefined Behavior in code that relies on ownership of its file