From ea92388054dd64c9ad452bea2e1e667ef8462b99 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Mon, 16 Sep 2024 08:35:07 -0700 Subject: [PATCH] Mark `terminal_size_using_fd` as unsafe. --- src/unix.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/unix.rs b/src/unix.rs index 095c3ed..a07b5e8 100644 --- a/src/unix.rs +++ b/src/unix.rs @@ -45,14 +45,14 @@ pub fn terminal_size_of(fd: Fd) -> Option<(Width, Height)> { /// The given file descriptor must be an open file descriptor. /// /// If the given file descriptor is not a tty, returns `None` +/// +/// # Safety +/// +/// `fd` must be a valid open file descriptor. #[deprecated(note = "Use `terminal_size_of` instead. Use `BorrowedFd::borrow_raw` to convert a raw fd into a `BorrowedFd` if needed.")] -pub fn terminal_size_using_fd(fd: RawFd) -> Option<(Width, Height)> { - // SAFETY: Under I/O safety, this function should be `unsafe`, but we can't - // remove it without breaking compatibility, so we instead deprecate it. - // This unsafe block has the same precondition that the function implicitly - // does: `fd` must be an open handle. - unsafe { terminal_size_of(BorrowedFd::borrow_raw(fd)) } +pub unsafe fn terminal_size_using_fd(fd: RawFd) -> Option<(Width, Height)> { + terminal_size_of(BorrowedFd::borrow_raw(fd)) } #[test]