Skip to content

Commit 622dfcc

Browse files
committed
Fix Windows compilation errors.
1 parent 18c14ad commit 622dfcc

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

library/std/src/os/windows/io/handle.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use crate::convert::TryFrom;
77
use crate::ffi::c_void;
88
use crate::fmt;
99
use crate::fs;
10+
use crate::io;
1011
use crate::marker::PhantomData;
1112
use crate::mem::forget;
1213
use crate::ptr::NonNull;
@@ -114,7 +115,7 @@ impl BorrowedHandle<'_> {
114115
impl OwnedHandle {
115116
/// Creates a new `OwnedHandle` instance that shares the same underlying file handle
116117
/// as the existing `OwnedHandle` instance.
117-
pub fn try_clone(&self) -> crate::io::Result<FileDesc> {
118+
pub fn try_clone(&self) -> crate::io::Result<Self> {
118119
let handle = self.duplicate(0, false, c::DUPLICATE_SAME_ACCESS)?;
119120

120121
Ok(unsafe { OwnedHandle::from_raw_handle(handle) })

library/std/src/os/windows/io/socket.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
use super::raw::{AsRawSocket, FromRawSocket, IntoRawSocket, RawSocket};
66
use crate::fmt;
7+
use crate::io;
78
use crate::marker::PhantomData;
9+
use crate::mem;
810
use crate::mem::forget;
911
use crate::sys::c;
1012
use crate::sys::cvt;
@@ -91,7 +93,7 @@ impl OwnedSocket {
9193
};
9294

9395
if socket != c::INVALID_SOCKET {
94-
unsafe { Ok(Self::from_inner(OwnedSocket::from_raw_socket(socket))) }
96+
unsafe { Ok(Self(OwnedSocket::from_raw_socket(socket))) }
9597
} else {
9698
let error = unsafe { c::WSAGetLastError() };
9799

@@ -115,14 +117,19 @@ impl OwnedSocket {
115117
}
116118

117119
unsafe {
118-
let socket = Self::from_inner(OwnedSocket::from_raw_socket(socket));
120+
let socket = Self(OwnedSocket::from_raw_socket(socket));
119121
socket.set_no_inherit()?;
120122
Ok(socket)
121123
}
122124
}
123125
}
124126
}
125127

128+
/// Returns the last error from the Windows socket interface.
129+
fn last_error() -> io::Error {
130+
io::Error::from_raw_os_error(unsafe { c::WSAGetLastError() })
131+
}
132+
126133
impl AsRawSocket for BorrowedSocket<'_> {
127134
#[inline]
128135
fn as_raw_socket(&self) -> RawSocket {

library/std/src/sys/windows/fs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ impl File {
455455
}
456456

457457
pub fn duplicate(&self) -> io::Result<File> {
458-
Ok(Self(self.0.try_clone()?))
458+
Ok(Self { handle: self.handle.try_clone()? })
459459
}
460460

461461
fn reparse_point<'a>(

library/std/src/sys/windows/net.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ impl Socket {
208208
}
209209

210210
pub fn duplicate(&self) -> io::Result<Socket> {
211-
Ok(Self(self.0.duplicate()?))
211+
Ok(Self(self.0.try_clone()?))
212212
}
213213

214214
fn recv_with_flags(&self, buf: &mut [u8], flags: c_int) -> io::Result<usize> {

0 commit comments

Comments
 (0)