Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 590386a

Browse files
Fix compilation errors with feature = io_safety.
Fix a typo of "io-safety" in place of "io_safety", and fix various compilation errors exposed by this fix.
1 parent 74dbd3a commit 590386a

File tree

10 files changed

+21
-15
lines changed

10 files changed

+21
-15
lines changed

‎src/fs/file.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ cfg_unix! {
461461

462462
impl From<File> for OwnedFd {
463463
fn from(val: File) -> OwnedFd {
464-
self.into_std_file().into()
464+
val.into_std_file().into()
465465
}
466466
}
467467
}

‎src/io/stderr.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,9 @@ cfg_unix! {
186186

187187
impl AsFd for Stderr {
188188
fn as_fd(&self) -> BorrowedFd<'_> {
189-
std::io::stderr().as_fd()
189+
unsafe {
190+
BorrowedFd::borrow_raw(std::io::stderr().as_raw_fd())
191+
}
190192
}
191193
}
192194
}

‎src/io/stdin.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,11 @@ cfg_unix! {
210210
cfg_io_safety! {
211211
use crate::os::unix::io::{AsFd, BorrowedFd};
212212

213-
impl AsFd for Stderr {
213+
impl AsFd for Stdin {
214214
fn as_fd(&self) -> BorrowedFd<'_> {
215-
std::io::stdin().as_fd()
215+
unsafe {
216+
BorrowedFd::borrow_raw(std::io::stdin().as_raw_fd())
217+
}
216218
}
217219
}
218220
}

‎src/io/stdout.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,9 @@ cfg_unix! {
186186

187187
impl AsFd for Stdout {
188188
fn as_fd(&self) -> BorrowedFd<'_> {
189-
std::io::stdout().as_fd()
189+
unsafe {
190+
BorrowedFd::borrow_raw(std::io::stdout().as_raw_fd())
191+
}
190192
}
191193
}
192194
}

‎src/net/tcp/stream.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ cfg_unix! {
434434

435435
impl From<TcpStream> for OwnedFd {
436436
fn from(stream: TcpStream) -> OwnedFd {
437-
stream.watcher.into_inner().unwrap().into()
437+
stream.watcher.get_ref().try_clone().unwrap().into()
438438
}
439439
}
440440
}

‎src/net/udp/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ cfg_unix! {
574574

575575
impl From<OwnedFd> for UdpSocket {
576576
fn from(fd: OwnedFd) -> UdpSocket {
577-
std::net::TcpStream::from(fd).into()
577+
std::net::UdpSocket::from(fd).into()
578578
}
579579
}
580580

‎src/os/unix/net/datagram.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ cfg_io_safety! {
352352

353353
impl From<OwnedFd> for UnixDatagram {
354354
fn from(fd: OwnedFd) -> UnixDatagram {
355-
std::net::TcpStream::from(fd).into()
355+
StdUnixDatagram::from(fd).into()
356356
}
357357
}
358358

@@ -361,4 +361,4 @@ cfg_io_safety! {
361361
stream.watcher.into_inner().unwrap().into()
362362
}
363363
}
364-
}
364+
}

‎src/os/unix/net/listener.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ cfg_io_safety! {
245245

246246
impl From<OwnedFd> for UnixListener {
247247
fn from(fd: OwnedFd) -> UnixListener {
248-
std::net::TcpStream::from(fd).into()
248+
std::os::unix::net::UnixListener::from(fd).into()
249249
}
250250
}
251251

@@ -254,4 +254,4 @@ cfg_io_safety! {
254254
stream.watcher.into_inner().unwrap().into()
255255
}
256256
}
257-
}
257+
}

‎src/os/unix/net/stream.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,13 +276,13 @@ cfg_io_safety! {
276276

277277
impl From<OwnedFd> for UnixStream {
278278
fn from(fd: OwnedFd) -> UnixStream {
279-
std::net::TcpStream::from(fd).into()
279+
std::os::unix::net::UnixStream::from(fd).into()
280280
}
281281
}
282282

283283
impl From<UnixStream> for OwnedFd {
284284
fn from(stream: UnixStream) -> OwnedFd {
285-
stream.watcher.into_inner().unwrap().into()
285+
stream.watcher.get_ref().try_clone().unwrap().into()
286286
}
287287
}
288-
}
288+
}

‎src/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ macro_rules! cfg_default {
246246
macro_rules! cfg_io_safety {
247247
($($item:item)*) => {
248248
$(
249-
#[cfg(feature = "io-safety")]
249+
#[cfg(feature = "io_safety")]
250250
$item
251251
)*
252252
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /