Skip to content

Commit 09e39c6

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 5bc3450 commit 09e39c6

File tree

13 files changed

+115
-123
lines changed

13 files changed

+115
-123
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/net/connection/socket/wasip2.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ macro_rules! impl_is_minus_one {
3131

3232
impl_is_minus_one! { i8 i16 i32 i64 isize }
3333

34-
pub fn cvt<T: IsMinusOne>(t: T) -> crate::io::Result<T> {
35-
if t.is_minus_one() { Err(crate::io::Error::last_os_error()) } else { Ok(t) }
34+
pub fn cvt<T: IsMinusOne>(t: T) -> io::Result<T> {
35+
if t.is_minus_one() { Err(io::Error::last_os_error()) } else { Ok(t) }
3636
}
3737

38-
pub fn cvt_r<T, F>(mut f: F) -> crate::io::Result<T>
38+
pub fn cvt_r<T, F>(mut f: F) -> io::Result<T>
3939
where
4040
T: IsMinusOne,
4141
F: FnMut() -> T,

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/sgx/mod.rs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#![deny(unsafe_op_in_unsafe_fn)]
66
#![allow(fuzzy_provenance_casts)] // FIXME: this entire module systematically confuses pointers and integers
77

8-
use crate::io::ErrorKind;
8+
use crate::io;
99
use crate::sync::atomic::{Atomic, AtomicBool, Ordering};
1010

1111
pub mod abi;
@@ -31,24 +31,24 @@ pub unsafe fn cleanup() {}
3131

3232
/// This function is used to implement functionality that simply doesn't exist.
3333
/// Programs relying on this functionality will need to deal with the error.
34-
pub fn unsupported<T>() -> crate::io::Result<T> {
34+
pub fn unsupported<T>() -> io::Result<T> {
3535
Err(unsupported_err())
3636
}
3737

38-
pub fn unsupported_err() -> crate::io::Error {
39-
crate::io::const_error!(ErrorKind::Unsupported, "operation not supported on SGX yet")
38+
pub fn unsupported_err() -> io::Error {
39+
io::const_error!(io::ErrorKind::Unsupported, "operation not supported on SGX yet")
4040
}
4141

4242
/// This function is used to implement various functions that doesn't exist,
4343
/// but the lack of which might not be reason for error. If no error is
4444
/// returned, the program might very well be able to function normally. This is
4545
/// what happens when `SGX_INEFFECTIVE_ERROR` is set to `true`. If it is
4646
/// `false`, the behavior is the same as `unsupported`.
47-
pub fn sgx_ineffective<T>(v: T) -> crate::io::Result<T> {
47+
pub fn sgx_ineffective<T>(v: T) -> io::Result<T> {
4848
static SGX_INEFFECTIVE_ERROR: Atomic<bool> = AtomicBool::new(false);
4949
if SGX_INEFFECTIVE_ERROR.load(Ordering::Relaxed) {
50-
Err(crate::io::const_error!(
51-
ErrorKind::Uncategorized,
50+
Err(io::const_error!(
51+
io::ErrorKind::Uncategorized,
5252
"operation can't be trusted to have any effect on SGX",
5353
))
5454
} else {
@@ -66,43 +66,43 @@ pub fn decode_error_kind(code: i32) -> ErrorKind {
6666

6767
// FIXME: not sure how to make sure all variants of Error are covered
6868
if code == Error::NotFound as _ {
69-
ErrorKind::NotFound
69+
io::ErrorKind::NotFound
7070
} else if code == Error::PermissionDenied as _ {
71-
ErrorKind::PermissionDenied
71+
io::ErrorKind::PermissionDenied
7272
} else if code == Error::ConnectionRefused as _ {
73-
ErrorKind::ConnectionRefused
73+
io::ErrorKind::ConnectionRefused
7474
} else if code == Error::ConnectionReset as _ {
75-
ErrorKind::ConnectionReset
75+
io::ErrorKind::ConnectionReset
7676
} else if code == Error::ConnectionAborted as _ {
77-
ErrorKind::ConnectionAborted
77+
io::ErrorKind::ConnectionAborted
7878
} else if code == Error::NotConnected as _ {
79-
ErrorKind::NotConnected
79+
io::ErrorKind::NotConnected
8080
} else if code == Error::AddrInUse as _ {
81-
ErrorKind::AddrInUse
81+
io::ErrorKind::AddrInUse
8282
} else if code == Error::AddrNotAvailable as _ {
83-
ErrorKind::AddrNotAvailable
83+
io::ErrorKind::AddrNotAvailable
8484
} else if code == Error::BrokenPipe as _ {
85-
ErrorKind::BrokenPipe
85+
io::ErrorKind::BrokenPipe
8686
} else if code == Error::AlreadyExists as _ {
87-
ErrorKind::AlreadyExists
87+
io::ErrorKind::AlreadyExists
8888
} else if code == Error::WouldBlock as _ {
89-
ErrorKind::WouldBlock
89+
io::ErrorKind::WouldBlock
9090
} else if code == Error::InvalidInput as _ {
91-
ErrorKind::InvalidInput
91+
io::ErrorKind::InvalidInput
9292
} else if code == Error::InvalidData as _ {
93-
ErrorKind::InvalidData
93+
io::ErrorKind::InvalidData
9494
} else if code == Error::TimedOut as _ {
95-
ErrorKind::TimedOut
95+
io::ErrorKind::TimedOut
9696
} else if code == Error::WriteZero as _ {
97-
ErrorKind::WriteZero
97+
io::ErrorKind::WriteZero
9898
} else if code == Error::Interrupted as _ {
99-
ErrorKind::Interrupted
99+
io::ErrorKind::Interrupted
100100
} else if code == Error::Other as _ {
101-
ErrorKind::Uncategorized
101+
io::ErrorKind::Uncategorized
102102
} else if code == Error::UnexpectedEof as _ {
103-
ErrorKind::UnexpectedEof
103+
io::ErrorKind::UnexpectedEof
104104
} else {
105-
ErrorKind::Uncategorized
105+
io::ErrorKind::Uncategorized
106106
}
107107
}
108108

0 commit comments

Comments
 (0)