Skip to content

Commit 8dd8140

Browse files
committed
crate::io::Resultio::Result in most places
I don't know why many places refer to the type as `crate::io::Result` when `crate::io` is already imported.
1 parent 6e7dd2c commit 8dd8140

File tree

21 files changed

+230
-248
lines changed

21 files changed

+230
-248
lines changed

library/std/src/os/fd/owned.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ impl OwnedFd {
9191
/// Creates a new `OwnedFd` instance that shares the same underlying file
9292
/// description as the existing `OwnedFd` instance.
9393
#[stable(feature = "io_safety", since = "1.63.0")]
94-
pub fn try_clone(&self) -> crate::io::Result<Self> {
94+
pub fn try_clone(&self) -> io::Result<Self> {
9595
self.as_fd().try_clone_to_owned()
9696
}
9797
}
@@ -106,7 +106,7 @@ impl BorrowedFd<'_> {
106106
target_os = "motor"
107107
)))]
108108
#[stable(feature = "io_safety", since = "1.63.0")]
109-
pub fn try_clone_to_owned(&self) -> crate::io::Result<OwnedFd> {
109+
pub fn try_clone_to_owned(&self) -> io::Result<OwnedFd> {
110110
// We want to atomically duplicate this file descriptor and set the
111111
// CLOEXEC flag, and currently that's done via F_DUPFD_CLOEXEC. This
112112
// is a POSIX flag that was added to Linux in 2.6.24.
@@ -129,15 +129,15 @@ impl BorrowedFd<'_> {
129129
/// description as the existing `BorrowedFd` instance.
130130
#[cfg(any(target_arch = "wasm32", target_os = "hermit", target_os = "trusty"))]
131131
#[stable(feature = "io_safety", since = "1.63.0")]
132-
pub fn try_clone_to_owned(&self) -> crate::io::Result<OwnedFd> {
133-
Err(crate::io::Error::UNSUPPORTED_PLATFORM)
132+
pub fn try_clone_to_owned(&self) -> io::Result<OwnedFd> {
133+
Err(io::Error::UNSUPPORTED_PLATFORM)
134134
}
135135

136136
/// Creates a new `OwnedFd` instance that shares the same underlying file
137137
/// description as the existing `BorrowedFd` instance.
138138
#[cfg(target_os = "motor")]
139139
#[stable(feature = "io_safety", since = "1.63.0")]
140-
pub fn try_clone_to_owned(&self) -> crate::io::Result<OwnedFd> {
140+
pub fn try_clone_to_owned(&self) -> io::Result<OwnedFd> {
141141
let fd = moto_rt::fs::duplicate(self.as_raw_fd()).map_err(crate::sys::map_motor_error)?;
142142
Ok(unsafe { OwnedFd::from_raw_fd(fd) })
143143
}
@@ -233,7 +233,7 @@ macro_rules! impl_is_terminal {
233233
impl crate::sealed::Sealed for $t {}
234234

235235
#[stable(feature = "is_terminal", since = "1.70.0")]
236-
impl crate::io::IsTerminal for $t {
236+
impl io::IsTerminal for $t {
237237
#[inline]
238238
fn is_terminal(&self) -> bool {
239239
crate::sys::io::is_terminal(self)

library/std/src/os/solid/io.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
use crate::marker::PhantomData;
5050
use crate::mem::ManuallyDrop;
5151
use crate::sys::{AsInner, FromInner, IntoInner};
52-
use crate::{fmt, net, sys};
52+
use crate::{fmt, io, net, sys};
5353

5454
/// Raw file descriptors.
5555
pub type RawFd = i32;
@@ -110,15 +110,15 @@ impl BorrowedFd<'_> {
110110
impl OwnedFd {
111111
/// Creates a new `OwnedFd` instance that shares the same underlying file
112112
/// description as the existing `OwnedFd` instance.
113-
pub fn try_clone(&self) -> crate::io::Result<Self> {
113+
pub fn try_clone(&self) -> io::Result<Self> {
114114
self.as_fd().try_clone_to_owned()
115115
}
116116
}
117117

118118
impl BorrowedFd<'_> {
119119
/// Creates a new `OwnedFd` instance that shares the same underlying file
120120
/// description as the existing `BorrowedFd` instance.
121-
pub fn try_clone_to_owned(&self) -> crate::io::Result<OwnedFd> {
121+
pub fn try_clone_to_owned(&self) -> io::Result<OwnedFd> {
122122
let fd = sys::net::cvt(unsafe { crate::sys::abi::sockets::dup(self.as_raw_fd()) })?;
123123
Ok(unsafe { OwnedFd::from_raw_fd(fd) })
124124
}
@@ -184,7 +184,7 @@ macro_rules! impl_is_terminal {
184184
impl crate::sealed::Sealed for $t {}
185185

186186
#[stable(feature = "is_terminal", since = "1.70.0")]
187-
impl crate::io::IsTerminal for $t {
187+
impl io::IsTerminal for $t {
188188
#[inline]
189189
fn is_terminal(&self) -> bool {
190190
crate::sys::io::is_terminal(self)

library/std/src/os/unix/net/addr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ impl linux_ext::addr::SocketAddrExt for SocketAddr {
264264
if let AddressKind::Abstract(name) = self.address() { Some(name.as_bytes()) } else { None }
265265
}
266266

267-
fn from_abstract_name<N>(name: N) -> crate::io::Result<Self>
267+
fn from_abstract_name<N>(name: N) -> io::Result<Self>
268268
where
269269
N: AsRef<[u8]>,
270270
{

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ impl OwnedHandle {
184184
/// Creates a new `OwnedHandle` instance that shares the same underlying
185185
/// object as the existing `OwnedHandle` instance.
186186
#[stable(feature = "io_safety", since = "1.63.0")]
187-
pub fn try_clone(&self) -> crate::io::Result<Self> {
187+
pub fn try_clone(&self) -> io::Result<Self> {
188188
self.as_handle().try_clone_to_owned()
189189
}
190190
}
@@ -193,7 +193,7 @@ impl BorrowedHandle<'_> {
193193
/// Creates a new `OwnedHandle` instance that shares the same underlying
194194
/// object as the existing `BorrowedHandle` instance.
195195
#[stable(feature = "io_safety", since = "1.63.0")]
196-
pub fn try_clone_to_owned(&self) -> crate::io::Result<OwnedHandle> {
196+
pub fn try_clone_to_owned(&self) -> io::Result<OwnedHandle> {
197197
self.duplicate(0, false, sys::c::DUPLICATE_SAME_ACCESS)
198198
}
199199

@@ -409,7 +409,7 @@ macro_rules! impl_is_terminal {
409409
impl crate::sealed::Sealed for $t {}
410410

411411
#[stable(feature = "is_terminal", since = "1.70.0")]
412-
impl crate::io::IsTerminal for $t {
412+
impl io::IsTerminal for $t {
413413
#[inline]
414414
fn is_terminal(&self) -> bool {
415415
crate::sys::io::is_terminal(self)
@@ -546,47 +546,47 @@ impl From<OwnedHandle> for fs::File {
546546
}
547547

548548
#[stable(feature = "io_safety", since = "1.63.0")]
549-
impl AsHandle for crate::io::Stdin {
549+
impl AsHandle for io::Stdin {
550550
#[inline]
551551
fn as_handle(&self) -> BorrowedHandle<'_> {
552552
unsafe { BorrowedHandle::borrow_raw(self.as_raw_handle()) }
553553
}
554554
}
555555

556556
#[stable(feature = "io_safety", since = "1.63.0")]
557-
impl<'a> AsHandle for crate::io::StdinLock<'a> {
557+
impl<'a> AsHandle for io::StdinLock<'a> {
558558
#[inline]
559559
fn as_handle(&self) -> BorrowedHandle<'_> {
560560
unsafe { BorrowedHandle::borrow_raw(self.as_raw_handle()) }
561561
}
562562
}
563563

564564
#[stable(feature = "io_safety", since = "1.63.0")]
565-
impl AsHandle for crate::io::Stdout {
565+
impl AsHandle for io::Stdout {
566566
#[inline]
567567
fn as_handle(&self) -> BorrowedHandle<'_> {
568568
unsafe { BorrowedHandle::borrow_raw(self.as_raw_handle()) }
569569
}
570570
}
571571

572572
#[stable(feature = "io_safety", since = "1.63.0")]
573-
impl<'a> AsHandle for crate::io::StdoutLock<'a> {
573+
impl<'a> AsHandle for io::StdoutLock<'a> {
574574
#[inline]
575575
fn as_handle(&self) -> BorrowedHandle<'_> {
576576
unsafe { BorrowedHandle::borrow_raw(self.as_raw_handle()) }
577577
}
578578
}
579579

580580
#[stable(feature = "io_safety", since = "1.63.0")]
581-
impl AsHandle for crate::io::Stderr {
581+
impl AsHandle for io::Stderr {
582582
#[inline]
583583
fn as_handle(&self) -> BorrowedHandle<'_> {
584584
unsafe { BorrowedHandle::borrow_raw(self.as_raw_handle()) }
585585
}
586586
}
587587

588588
#[stable(feature = "io_safety", since = "1.63.0")]
589-
impl<'a> AsHandle for crate::io::StderrLock<'a> {
589+
impl<'a> AsHandle for io::StderrLock<'a> {
590590
#[inline]
591591
fn as_handle(&self) -> BorrowedHandle<'_> {
592592
unsafe { BorrowedHandle::borrow_raw(self.as_raw_handle()) }

library/std/src/sys/pal/hermit/mod.rs

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#![deny(unsafe_op_in_unsafe_fn)]
1717
#![allow(missing_docs, nonstandard_style)]
1818

19-
use crate::io::ErrorKind;
19+
use crate::io;
2020
use crate::os::hermit::hermit_abi;
2121
use crate::os::raw::c_char;
2222
use crate::sys::env;
@@ -25,15 +25,12 @@ pub mod futex;
2525
pub mod os;
2626
pub mod time;
2727

28-
pub fn unsupported<T>() -> crate::io::Result<T> {
28+
pub fn unsupported<T>() -> io::Result<T> {
2929
Err(unsupported_err())
3030
}
3131

32-
pub fn unsupported_err() -> crate::io::Error {
33-
crate::io::const_error!(
34-
crate::io::ErrorKind::Unsupported,
35-
"operation not supported on HermitCore yet",
36-
)
32+
pub fn unsupported_err() -> io::Error {
33+
io::const_error!(io::ErrorKind::Unsupported, "operation not supported on HermitCore yet")
3734
}
3835

3936
pub fn abort_internal() -> ! {
@@ -83,24 +80,24 @@ pub(crate) fn is_interrupted(errno: i32) -> bool {
8380
errno == hermit_abi::errno::EINTR
8481
}
8582

86-
pub fn decode_error_kind(errno: i32) -> ErrorKind {
83+
pub fn decode_error_kind(errno: i32) -> io::ErrorKind {
8784
match errno {
88-
hermit_abi::errno::EACCES => ErrorKind::PermissionDenied,
89-
hermit_abi::errno::EADDRINUSE => ErrorKind::AddrInUse,
90-
hermit_abi::errno::EADDRNOTAVAIL => ErrorKind::AddrNotAvailable,
91-
hermit_abi::errno::EAGAIN => ErrorKind::WouldBlock,
92-
hermit_abi::errno::ECONNABORTED => ErrorKind::ConnectionAborted,
93-
hermit_abi::errno::ECONNREFUSED => ErrorKind::ConnectionRefused,
94-
hermit_abi::errno::ECONNRESET => ErrorKind::ConnectionReset,
95-
hermit_abi::errno::EEXIST => ErrorKind::AlreadyExists,
96-
hermit_abi::errno::EINTR => ErrorKind::Interrupted,
97-
hermit_abi::errno::EINVAL => ErrorKind::InvalidInput,
98-
hermit_abi::errno::ENOENT => ErrorKind::NotFound,
99-
hermit_abi::errno::ENOTCONN => ErrorKind::NotConnected,
100-
hermit_abi::errno::EPERM => ErrorKind::PermissionDenied,
101-
hermit_abi::errno::EPIPE => ErrorKind::BrokenPipe,
102-
hermit_abi::errno::ETIMEDOUT => ErrorKind::TimedOut,
103-
_ => ErrorKind::Uncategorized,
85+
hermit_abi::errno::EACCES => io::ErrorKind::PermissionDenied,
86+
hermit_abi::errno::EADDRINUSE => io::ErrorKind::AddrInUse,
87+
hermit_abi::errno::EADDRNOTAVAIL => io::ErrorKind::AddrNotAvailable,
88+
hermit_abi::errno::EAGAIN => io::ErrorKind::WouldBlock,
89+
hermit_abi::errno::ECONNABORTED => io::ErrorKind::ConnectionAborted,
90+
hermit_abi::errno::ECONNREFUSED => io::ErrorKind::ConnectionRefused,
91+
hermit_abi::errno::ECONNRESET => io::ErrorKind::ConnectionReset,
92+
hermit_abi::errno::EEXIST => io::ErrorKind::AlreadyExists,
93+
hermit_abi::errno::EINTR => io::ErrorKind::Interrupted,
94+
hermit_abi::errno::EINVAL => io::ErrorKind::InvalidInput,
95+
hermit_abi::errno::ENOENT => io::ErrorKind::NotFound,
96+
hermit_abi::errno::ENOTCONN => io::ErrorKind::NotConnected,
97+
hermit_abi::errno::EPERM => io::ErrorKind::PermissionDenied,
98+
hermit_abi::errno::EPIPE => io::ErrorKind::BrokenPipe,
99+
hermit_abi::errno::ETIMEDOUT => io::ErrorKind::TimedOut,
100+
_ => io::ErrorKind::Uncategorized,
104101
}
105102
}
106103

@@ -133,16 +130,16 @@ impl IsNegative for i32 {
133130
}
134131
impl_is_negative! { i8 i16 i64 isize }
135132

136-
pub fn cvt<T: IsNegative>(t: T) -> crate::io::Result<T> {
133+
pub fn cvt<T: IsNegative>(t: T) -> io::Result<T> {
137134
if t.is_negative() {
138135
let e = decode_error_kind(t.negate());
139-
Err(crate::io::Error::from(e))
136+
Err(io::Error::from(e))
140137
} else {
141138
Ok(t)
142139
}
143140
}
144141

145-
pub fn cvt_r<T, F>(mut f: F) -> crate::io::Result<T>
142+
pub fn cvt_r<T, F>(mut f: F) -> io::Result<T>
146143
where
147144
T: IsNegative,
148145
F: FnMut() -> T,

library/std/src/sys/pal/itron/error.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::abi;
22
use crate::fmt;
3-
use crate::io::ErrorKind;
3+
use crate::io;
44

55
/// Wraps a μITRON error code.
66
#[derive(Debug, Copy, Clone)]
@@ -84,39 +84,39 @@ pub fn is_interrupted(er: abi::ER) -> bool {
8484
er == abi::E_RLWAI
8585
}
8686

87-
pub fn decode_error_kind(er: abi::ER) -> ErrorKind {
87+
pub fn decode_error_kind(er: abi::ER) -> io::ErrorKind {
8888
match er {
8989
// Success
90-
er if er >= 0 => ErrorKind::Uncategorized,
90+
er if er >= 0 => io::ErrorKind::Uncategorized,
9191

9292
// μITRON 4.0
9393
// abi::E_SYS
94-
abi::E_NOSPT => ErrorKind::Unsupported, // Some("unsupported function"),
95-
abi::E_RSFN => ErrorKind::InvalidInput, // Some("reserved function code"),
96-
abi::E_RSATR => ErrorKind::InvalidInput, // Some("reserved attribute"),
97-
abi::E_PAR => ErrorKind::InvalidInput, // Some("parameter error"),
98-
abi::E_ID => ErrorKind::NotFound, // Some("invalid ID number"),
94+
abi::E_NOSPT => io::ErrorKind::Unsupported, // Some("unsupported function"),
95+
abi::E_RSFN => io::ErrorKind::InvalidInput, // Some("reserved function code"),
96+
abi::E_RSATR => io::ErrorKind::InvalidInput, // Some("reserved attribute"),
97+
abi::E_PAR => io::ErrorKind::InvalidInput, // Some("parameter error"),
98+
abi::E_ID => io::ErrorKind::NotFound, // Some("invalid ID number"),
9999
// abi::E_CTX
100-
abi::E_MACV => ErrorKind::PermissionDenied, // Some("memory access violation"),
101-
abi::E_OACV => ErrorKind::PermissionDenied, // Some("object access violation"),
100+
abi::E_MACV => io::ErrorKind::PermissionDenied, // Some("memory access violation"),
101+
abi::E_OACV => io::ErrorKind::PermissionDenied, // Some("object access violation"),
102102
// abi::E_ILUSE
103-
abi::E_NOMEM => ErrorKind::OutOfMemory, // Some("insufficient memory"),
104-
abi::E_NOID => ErrorKind::OutOfMemory, // Some("no ID number available"),
103+
abi::E_NOMEM => io::ErrorKind::OutOfMemory, // Some("insufficient memory"),
104+
abi::E_NOID => io::ErrorKind::OutOfMemory, // Some("no ID number available"),
105105
// abi::E_OBJ
106-
abi::E_NOEXS => ErrorKind::NotFound, // Some("non-existent object"),
106+
abi::E_NOEXS => io::ErrorKind::NotFound, // Some("non-existent object"),
107107
// abi::E_QOVR
108-
abi::E_RLWAI => ErrorKind::Interrupted, // Some("forced release from waiting"),
109-
abi::E_TMOUT => ErrorKind::TimedOut, // Some("polling failure or timeout"),
108+
abi::E_RLWAI => io::ErrorKind::Interrupted, // Some("forced release from waiting"),
109+
abi::E_TMOUT => io::ErrorKind::TimedOut, // Some("polling failure or timeout"),
110110
// abi::E_DLT
111111
// abi::E_CLS
112112
// abi::E_WBLK
113113
// abi::E_BOVR
114114

115115
// The TOPPERS third generation kernels
116-
abi::E_NORES => ErrorKind::OutOfMemory, // Some("insufficient system resources"),
116+
abi::E_NORES => io::ErrorKind::OutOfMemory, // Some("insufficient system resources"),
117117
// abi::E_RASTER
118118
// abi::E_COMM
119-
_ => ErrorKind::Uncategorized,
119+
_ => io::ErrorKind::Uncategorized,
120120
}
121121
}
122122

0 commit comments

Comments
 (0)