Skip to content

Commit 363e0da

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 5f1173b commit 363e0da

File tree

21 files changed

+229
-245
lines changed

21 files changed

+229
-245
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_common::{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
@@ -185,7 +185,7 @@ impl OwnedHandle {
185185
/// Creates a new `OwnedHandle` instance that shares the same underlying
186186
/// object as the existing `OwnedHandle` instance.
187187
#[stable(feature = "io_safety", since = "1.63.0")]
188-
pub fn try_clone(&self) -> crate::io::Result<Self> {
188+
pub fn try_clone(&self) -> io::Result<Self> {
189189
self.as_handle().try_clone_to_owned()
190190
}
191191
}
@@ -194,7 +194,7 @@ impl BorrowedHandle<'_> {
194194
/// Creates a new `OwnedHandle` instance that shares the same underlying
195195
/// object as the existing `BorrowedHandle` instance.
196196
#[stable(feature = "io_safety", since = "1.63.0")]
197-
pub fn try_clone_to_owned(&self) -> crate::io::Result<OwnedHandle> {
197+
pub fn try_clone_to_owned(&self) -> io::Result<OwnedHandle> {
198198
self.duplicate(0, false, sys::c::DUPLICATE_SAME_ACCESS)
199199
}
200200

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

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

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

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

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

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

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

589589
#[stable(feature = "io_safety", since = "1.63.0")]
590-
impl<'a> AsHandle for crate::io::StderrLock<'a> {
590+
impl<'a> AsHandle for io::StderrLock<'a> {
591591
#[inline]
592592
fn as_handle(&self) -> BorrowedHandle<'_> {
593593
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;
@@ -27,15 +27,12 @@ pub mod os;
2727
pub mod pipe;
2828
pub mod time;
2929

30-
pub fn unsupported<T>() -> crate::io::Result<T> {
30+
pub fn unsupported<T>() -> io::Result<T> {
3131
Err(unsupported_err())
3232
}
3333

34-
pub fn unsupported_err() -> crate::io::Error {
35-
crate::io::const_error!(
36-
crate::io::ErrorKind::Unsupported,
37-
"operation not supported on HermitCore yet",
38-
)
34+
pub fn unsupported_err() -> io::Error {
35+
io::const_error!(io::ErrorKind::Unsupported, "operation not supported on HermitCore yet")
3936
}
4037

4138
pub fn abort_internal() -> ! {
@@ -85,24 +82,24 @@ pub(crate) fn is_interrupted(errno: i32) -> bool {
8582
errno == hermit_abi::errno::EINTR
8683
}
8784

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

@@ -135,16 +132,16 @@ impl IsNegative for i32 {
135132
}
136133
impl_is_negative! { i8 i16 i64 isize }
137134

138-
pub fn cvt<T: IsNegative>(t: T) -> crate::io::Result<T> {
135+
pub fn cvt<T: IsNegative>(t: T) -> io::Result<T> {
139136
if t.is_negative() {
140137
let e = decode_error_kind(t.negate());
141-
Err(crate::io::Error::from(e))
138+
Err(io::Error::from(e))
142139
} else {
143140
Ok(t)
144141
}
145142
}
146143

147-
pub fn cvt_r<T, F>(mut f: F) -> crate::io::Result<T>
144+
pub fn cvt_r<T, F>(mut f: F) -> io::Result<T>
148145
where
149146
T: IsNegative,
150147
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)