Skip to content

Commit 0cb69de

Browse files
committed
Rename OwnedFd's private field to match it's debug output.
1 parent 45b5de3 commit 0cb69de

File tree

4 files changed

+86
-85
lines changed

4 files changed

+86
-85
lines changed

library/std/src/os/unix/io/fd.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use crate::sys_common::{AsInner, FromInner, IntoInner};
3232
#[rustc_layout_scalar_valid_range_end(0xFF_FF_FF_FE)]
3333
#[unstable(feature = "io_safety", issue = "87074")]
3434
pub struct BorrowedFd<'fd> {
35-
raw: RawFd,
35+
fd: RawFd,
3636
_phantom: PhantomData<&'fd OwnedFd>,
3737
}
3838

@@ -52,47 +52,47 @@ pub struct BorrowedFd<'fd> {
5252
#[rustc_layout_scalar_valid_range_end(0xFF_FF_FF_FE)]
5353
#[unstable(feature = "io_safety", issue = "87074")]
5454
pub struct OwnedFd {
55-
raw: RawFd,
55+
fd: RawFd,
5656
}
5757

5858
impl BorrowedFd<'_> {
5959
/// Return a `BorrowedFd` holding the given raw file descriptor.
6060
///
6161
/// # Safety
6262
///
63-
/// The resource pointed to by `raw` must remain open for the duration of
63+
/// The resource pointed to by `fd` must remain open for the duration of
6464
/// the returned `BorrowedFd`, and it must not have the value `-1`.
6565
#[inline]
6666
#[unstable(feature = "io_safety", issue = "87074")]
67-
pub unsafe fn borrow_raw_fd(raw: RawFd) -> Self {
68-
assert_ne!(raw, -1_i32 as RawFd);
69-
Self { raw, _phantom: PhantomData }
67+
pub unsafe fn borrow_raw_fd(fd: RawFd) -> Self {
68+
assert_ne!(fd, -1_i32 as RawFd);
69+
Self { fd, _phantom: PhantomData }
7070
}
7171
}
7272

7373
#[unstable(feature = "io_safety", issue = "87074")]
7474
impl AsRawFd for BorrowedFd<'_> {
7575
#[inline]
7676
fn as_raw_fd(&self) -> RawFd {
77-
self.raw
77+
self.fd
7878
}
7979
}
8080

8181
#[unstable(feature = "io_safety", issue = "87074")]
8282
impl AsRawFd for OwnedFd {
8383
#[inline]
8484
fn as_raw_fd(&self) -> RawFd {
85-
self.raw
85+
self.fd
8686
}
8787
}
8888

8989
#[unstable(feature = "io_safety", issue = "87074")]
9090
impl IntoRawFd for OwnedFd {
9191
#[inline]
9292
fn into_raw_fd(self) -> RawFd {
93-
let raw = self.raw;
93+
let fd = self.fd;
9494
forget(self);
95-
raw
95+
fd
9696
}
9797
}
9898

@@ -102,13 +102,13 @@ impl FromRawFd for OwnedFd {
102102
///
103103
/// # Safety
104104
///
105-
/// The resource pointed to by `raw` must be open and suitable for assuming
105+
/// The resource pointed to by `fd` must be open and suitable for assuming
106106
/// ownership. The resource must not require any cleanup other than `close`.
107107
#[inline]
108-
unsafe fn from_raw_fd(raw: RawFd) -> Self {
109-
assert_ne!(raw, -1i32);
108+
unsafe fn from_raw_fd(fd: RawFd) -> Self {
109+
assert_ne!(fd, -1i32);
110110
// 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)
111-
Self { raw }
111+
Self { fd }
112112
}
113113
}
114114

@@ -122,22 +122,22 @@ impl Drop for OwnedFd {
122122
// the file descriptor was closed or not, and if we retried (for
123123
// something like EINTR), we might close another valid file descriptor
124124
// opened after we closed ours.
125-
let _ = libc::close(self.raw as raw::c_int);
125+
let _ = libc::close(self.fd as raw::c_int);
126126
}
127127
}
128128
}
129129

130130
#[unstable(feature = "io_safety", issue = "87074")]
131131
impl fmt::Debug for BorrowedFd<'_> {
132132
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
133-
f.debug_struct("BorrowedFd").field("fd", &self.raw).finish()
133+
f.debug_struct("BorrowedFd").field("fd", &self.fd).finish()
134134
}
135135
}
136136

137137
#[unstable(feature = "io_safety", issue = "87074")]
138138
impl fmt::Debug for OwnedFd {
139139
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
140-
f.debug_struct("OwnedFd").field("fd", &self.raw).finish()
140+
f.debug_struct("OwnedFd").field("fd", &self.fd).finish()
141141
}
142142
}
143143

library/std/src/os/wasi/io/fd.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use crate::sys_common::{AsInner, FromInner, IntoInner};
3232
#[rustc_layout_scalar_valid_range_end(0xFF_FF_FF_FE)]
3333
#[unstable(feature = "io_safety", issue = "87074")]
3434
pub struct BorrowedFd<'fd> {
35-
raw: RawFd,
35+
fd: RawFd,
3636
_phantom: PhantomData<&'fd OwnedFd>,
3737
}
3838

@@ -52,47 +52,47 @@ pub struct BorrowedFd<'fd> {
5252
#[rustc_layout_scalar_valid_range_end(0xFF_FF_FF_FE)]
5353
#[unstable(feature = "io_safety", issue = "87074")]
5454
pub struct OwnedFd {
55-
raw: RawFd,
55+
fd: RawFd,
5656
}
5757

5858
impl BorrowedFd<'_> {
5959
/// Return a `BorrowedFd` holding the given raw file descriptor.
6060
///
6161
/// # Safety
6262
///
63-
/// The resource pointed to by `raw` must remain open for the duration of
63+
/// The resource pointed to by `fd` must remain open for the duration of
6464
/// the returned `BorrowedFd`, and it must not have the value `-1`.
6565
#[inline]
6666
#[unstable(feature = "io_safety", issue = "87074")]
67-
pub unsafe fn borrow_raw_fd(raw: RawFd) -> Self {
68-
assert_ne!(raw, -1_i32 as RawFd);
69-
unsafe { Self { raw, _phantom: PhantomData } }
67+
pub unsafe fn borrow_raw_fd(fd: RawFd) -> Self {
68+
assert_ne!(fd, -1_i32 as RawFd);
69+
unsafe { Self { fd, _phantom: PhantomData } }
7070
}
7171
}
7272

7373
#[unstable(feature = "io_safety", issue = "87074")]
7474
impl AsRawFd for BorrowedFd<'_> {
7575
#[inline]
7676
fn as_raw_fd(&self) -> RawFd {
77-
self.raw
77+
self.fd
7878
}
7979
}
8080

8181
#[unstable(feature = "io_safety", issue = "87074")]
8282
impl AsRawFd for OwnedFd {
8383
#[inline]
8484
fn as_raw_fd(&self) -> RawFd {
85-
self.raw
85+
self.fd
8686
}
8787
}
8888

8989
#[unstable(feature = "io_safety", issue = "87074")]
9090
impl IntoRawFd for OwnedFd {
9191
#[inline]
9292
fn into_raw_fd(self) -> RawFd {
93-
let raw = self.raw;
93+
let fd = self.fd;
9494
forget(self);
95-
raw
95+
fd
9696
}
9797
}
9898

@@ -102,13 +102,13 @@ impl FromRawFd for OwnedFd {
102102
///
103103
/// # Safety
104104
///
105-
/// The resource pointed to by `raw` must be open and suitable for assuming
105+
/// The resource pointed to by `fd` must be open and suitable for assuming
106106
/// ownership.
107107
#[inline]
108-
unsafe fn from_raw_fd(raw: RawFd) -> Self {
109-
assert_ne!(raw, RawFd::MAX);
108+
unsafe fn from_raw_fd(fd: RawFd) -> Self {
109+
assert_ne!(fd, RawFd::MAX);
110110
// 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)
111-
unsafe { Self { raw } }
111+
unsafe { Self { fd } }
112112
}
113113
}
114114

@@ -122,22 +122,22 @@ impl Drop for OwnedFd {
122122
// the file descriptor was closed or not, and if we retried (for
123123
// something like EINTR), we might close another valid file descriptor
124124
// opened after we closed ours.
125-
let _ = libc::close(self.raw as raw::c_int);
125+
let _ = libc::close(self.fd as raw::c_int);
126126
}
127127
}
128128
}
129129

130130
#[unstable(feature = "io_safety", issue = "87074")]
131131
impl fmt::Debug for BorrowedFd<'_> {
132132
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
133-
f.debug_struct("BorrowedFd").field("fd", &self.raw).finish()
133+
f.debug_struct("BorrowedFd").field("fd", &self.fd).finish()
134134
}
135135
}
136136

137137
#[unstable(feature = "io_safety", issue = "87074")]
138138
impl fmt::Debug for OwnedFd {
139139
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
140-
f.debug_struct("OwnedFd").field("fd", &self.raw).finish()
140+
f.debug_struct("OwnedFd").field("fd", &self.fd).finish()
141141
}
142142
}
143143

0 commit comments

Comments
 (0)