From a50811a214b50d4a835ba1ad8eac546f9c7af9fa Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Thu, 30 Jul 2020 12:11:30 -0700 Subject: [PATCH] Add safety note to library/std/src/sys/unix/fd.rs Co-authored-by: Elichai Turkel --- library/std/src/sys/unix/fd.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/library/std/src/sys/unix/fd.rs b/library/std/src/sys/unix/fd.rs index 0eeaa68d55a7d..08c63444e2bb6 100644 --- a/library/std/src/sys/unix/fd.rs +++ b/library/std/src/sys/unix/fd.rs @@ -69,6 +69,7 @@ const fn max_iov() -> usize { impl FileDesc { pub fn new(fd: c_int) -> FileDesc { assert_ne!(fd, -1); + // SAFETY: we just asserted that the value is in the valid range and isn't `-1` (the only value bigger than `0xFF_FF_FF_FE` unsigned) unsafe { FileDesc { fd } } }