Skip to content

Commit a0d11a4

Browse files
committed
Rename ErrorKind::Unknown to Uncategorized.
1 parent 82d3ef1 commit a0d11a4

File tree

23 files changed

+72
-62
lines changed

23 files changed

+72
-62
lines changed

library/std/src/fs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2190,7 +2190,7 @@ impl DirBuilder {
21902190
Some(p) => self.create_dir_all(p)?,
21912191
None => {
21922192
return Err(io::Error::new_const(
2193-
io::ErrorKind::Unknown,
2193+
io::ErrorKind::Uncategorized,
21942194
&"failed to create whole tree",
21952195
));
21962196
}

library/std/src/fs/tests.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1329,7 +1329,8 @@ fn metadata_access_times() {
13291329
match (a.created(), b.created()) {
13301330
(Ok(t1), Ok(t2)) => assert!(t1 <= t2),
13311331
(Err(e1), Err(e2))
1332-
if e1.kind() == ErrorKind::Unknown && e2.kind() == ErrorKind::Unknown
1332+
if e1.kind() == ErrorKind::Uncategorized
1333+
&& e2.kind() == ErrorKind::Uncategorized
13331334
|| e1.kind() == ErrorKind::Unsupported
13341335
&& e2.kind() == ErrorKind::Unsupported => {}
13351336
(a, b) => {

library/std/src/io/error.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -198,12 +198,12 @@ pub enum ErrorKind {
198198

199199
/// Any I/O error from the standard library that's not part of this list.
200200
///
201-
/// Errors that are `Unknown` now may move to a different or a new
201+
/// Errors that are `Uncategorized` now may move to a different or a new
202202
/// [`ErrorKind`] variant in the future. It is not recommended to match
203-
/// an error against `Unknown`; use a wildcard match (`_`) instead.
204-
#[unstable(feature = "io_error_unknown", issue = "none")]
203+
/// an error against `Uncategorized`; use a wildcard match (`_`) instead.
204+
#[unstable(feature = "io_error_uncategorized", issue = "none")]
205205
#[doc(hidden)]
206-
Unknown,
206+
Uncategorized,
207207
}
208208

209209
impl ErrorKind {
@@ -229,7 +229,7 @@ impl ErrorKind {
229229
ErrorKind::Unsupported => "unsupported",
230230
ErrorKind::OutOfMemory => "out of memory",
231231
ErrorKind::Other => "other error",
232-
ErrorKind::Unknown => "other os error",
232+
ErrorKind::Uncategorized => "uncategorized error",
233233
}
234234
}
235235
}
@@ -552,7 +552,7 @@ impl Error {
552552
/// }
553553
///
554554
/// fn main() {
555-
/// // Will print "Unknown".
555+
/// // Will print "Uncategorized".
556556
/// print_error(Error::last_os_error());
557557
/// // Will print "AddrInUse".
558558
/// print_error(Error::new(ErrorKind::AddrInUse, "oh no!"));

library/std/src/io/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1592,7 +1592,7 @@ pub trait Write {
15921592
if output.error.is_err() {
15931593
output.error
15941594
} else {
1595-
Err(Error::new_const(ErrorKind::Unknown, &"formatter error"))
1595+
Err(Error::new_const(ErrorKind::Uncategorized, &"formatter error"))
15961596
}
15971597
}
15981598
}

library/std/src/net/tcp/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ fn double_bind() {
342342
Err(e) => {
343343
assert!(
344344
e.kind() == ErrorKind::ConnectionRefused
345-
|| e.kind() == ErrorKind::Unknown
345+
|| e.kind() == ErrorKind::Uncategorized
346346
|| e.kind() == ErrorKind::AddrInUse,
347347
"unknown error: {} {:?}",
348348
e,

library/std/src/os/wasi/fs.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -532,5 +532,6 @@ pub fn symlink_path<P: AsRef<Path>, U: AsRef<Path>>(old_path: P, new_path: U) ->
532532
}
533533

534534
fn osstr2str(f: &OsStr) -> io::Result<&str> {
535-
f.to_str().ok_or_else(|| io::Error::new_const(io::ErrorKind::Unknown, &"input must be utf-8"))
535+
f.to_str()
536+
.ok_or_else(|| io::Error::new_const(io::ErrorKind::Uncategorized, &"input must be utf-8"))
536537
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ pub fn decode_error_kind(errno: i32) -> ErrorKind {
149149
x if x == 1 as i32 => ErrorKind::PermissionDenied,
150150
x if x == 32 as i32 => ErrorKind::BrokenPipe,
151151
x if x == 110 as i32 => ErrorKind::TimedOut,
152-
_ => ErrorKind::Unknown,
152+
_ => ErrorKind::Uncategorized,
153153
}
154154
}
155155

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

+26-22
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::time::Duration;
1515
pub fn init() -> io::Result<()> {
1616
if abi::network_init() < 0 {
1717
return Err(io::Error::new_const(
18-
ErrorKind::Unknown,
18+
ErrorKind::Uncategorized,
1919
&"Unable to initialize network interface",
2020
));
2121
}
@@ -51,7 +51,7 @@ impl TcpStream {
5151
match abi::tcpstream::connect(addr.ip().to_string().as_bytes(), addr.port(), None) {
5252
Ok(handle) => Ok(TcpStream(Arc::new(Socket(handle)))),
5353
_ => Err(io::Error::new_const(
54-
ErrorKind::Unknown,
54+
ErrorKind::Uncategorized,
5555
&"Unable to initiate a connection on a socket",
5656
)),
5757
}
@@ -65,44 +65,46 @@ impl TcpStream {
6565
) {
6666
Ok(handle) => Ok(TcpStream(Arc::new(Socket(handle)))),
6767
_ => Err(io::Error::new_const(
68-
ErrorKind::Unknown,
68+
ErrorKind::Uncategorized,
6969
&"Unable to initiate a connection on a socket",
7070
)),
7171
}
7272
}
7373

7474
pub fn set_read_timeout(&self, duration: Option<Duration>) -> io::Result<()> {
7575
abi::tcpstream::set_read_timeout(*self.0.as_inner(), duration.map(|d| d.as_millis() as u64))
76-
.map_err(|_| io::Error::new_const(ErrorKind::Unknown, &"Unable to set timeout value"))
76+
.map_err(|_| {
77+
io::Error::new_const(ErrorKind::Uncategorized, &"Unable to set timeout value")
78+
})
7779
}
7880

7981
pub fn set_write_timeout(&self, duration: Option<Duration>) -> io::Result<()> {
8082
abi::tcpstream::set_write_timeout(
8183
*self.0.as_inner(),
8284
duration.map(|d| d.as_millis() as u64),
8385
)
84-
.map_err(|_| io::Error::new_const(ErrorKind::Unknown, &"Unable to set timeout value"))
86+
.map_err(|_| io::Error::new_const(ErrorKind::Uncategorized, &"Unable to set timeout value"))
8587
}
8688

8789
pub fn read_timeout(&self) -> io::Result<Option<Duration>> {
8890
let duration = abi::tcpstream::get_read_timeout(*self.0.as_inner()).map_err(|_| {
89-
io::Error::new_const(ErrorKind::Unknown, &"Unable to determine timeout value")
91+
io::Error::new_const(ErrorKind::Uncategorized, &"Unable to determine timeout value")
9092
})?;
9193

9294
Ok(duration.map(|d| Duration::from_millis(d)))
9395
}
9496

9597
pub fn write_timeout(&self) -> io::Result<Option<Duration>> {
9698
let duration = abi::tcpstream::get_write_timeout(*self.0.as_inner()).map_err(|_| {
97-
io::Error::new_const(ErrorKind::Unknown, &"Unable to determine timeout value")
99+
io::Error::new_const(ErrorKind::Uncategorized, &"Unable to determine timeout value")
98100
})?;
99101

100102
Ok(duration.map(|d| Duration::from_millis(d)))
101103
}
102104

103105
pub fn peek(&self, buf: &mut [u8]) -> io::Result<usize> {
104106
abi::tcpstream::peek(*self.0.as_inner(), buf)
105-
.map_err(|_| io::Error::new_const(ErrorKind::Unknown, &"peek failed"))
107+
.map_err(|_| io::Error::new_const(ErrorKind::Uncategorized, &"peek failed"))
106108
}
107109

108110
pub fn read(&self, buffer: &mut [u8]) -> io::Result<usize> {
@@ -114,7 +116,7 @@ impl TcpStream {
114116

115117
for i in ioslice.iter_mut() {
116118
let ret = abi::tcpstream::read(*self.0.as_inner(), &mut i[0..]).map_err(|_| {
117-
io::Error::new_const(ErrorKind::Unknown, &"Unable to read on socket")
119+
io::Error::new_const(ErrorKind::Uncategorized, &"Unable to read on socket")
118120
})?;
119121

120122
if ret != 0 {
@@ -139,7 +141,7 @@ impl TcpStream {
139141

140142
for i in ioslice.iter() {
141143
size += abi::tcpstream::write(*self.0.as_inner(), i).map_err(|_| {
142-
io::Error::new_const(ErrorKind::Unknown, &"Unable to write on socket")
144+
io::Error::new_const(ErrorKind::Uncategorized, &"Unable to write on socket")
143145
})?;
144146
}
145147

@@ -153,13 +155,13 @@ impl TcpStream {
153155

154156
pub fn peer_addr(&self) -> io::Result<SocketAddr> {
155157
let (ipaddr, port) = abi::tcpstream::peer_addr(*self.0.as_inner())
156-
.map_err(|_| io::Error::new_const(ErrorKind::Unknown, &"peer_addr failed"))?;
158+
.map_err(|_| io::Error::new_const(ErrorKind::Uncategorized, &"peer_addr failed"))?;
157159

158160
let saddr = match ipaddr {
159161
Ipv4(ref addr) => SocketAddr::new(IpAddr::V4(Ipv4Addr::from(addr.0)), port),
160162
Ipv6(ref addr) => SocketAddr::new(IpAddr::V6(Ipv6Addr::from(addr.0)), port),
161163
_ => {
162-
return Err(io::Error::new_const(ErrorKind::Unknown, &"peer_addr failed"));
164+
return Err(io::Error::new_const(ErrorKind::Uncategorized, &"peer_addr failed"));
163165
}
164166
};
165167

@@ -171,8 +173,9 @@ impl TcpStream {
171173
}
172174

173175
pub fn shutdown(&self, how: Shutdown) -> io::Result<()> {
174-
abi::tcpstream::shutdown(*self.0.as_inner(), how as i32)
175-
.map_err(|_| io::Error::new_const(ErrorKind::Unknown, &"unable to shutdown socket"))
176+
abi::tcpstream::shutdown(*self.0.as_inner(), how as i32).map_err(|_| {
177+
io::Error::new_const(ErrorKind::Uncategorized, &"unable to shutdown socket")
178+
})
176179
}
177180

178181
pub fn duplicate(&self) -> io::Result<TcpStream> {
@@ -181,31 +184,32 @@ impl TcpStream {
181184

182185
pub fn set_nodelay(&self, mode: bool) -> io::Result<()> {
183186
abi::tcpstream::set_nodelay(*self.0.as_inner(), mode)
184-
.map_err(|_| io::Error::new_const(ErrorKind::Unknown, &"set_nodelay failed"))
187+
.map_err(|_| io::Error::new_const(ErrorKind::Uncategorized, &"set_nodelay failed"))
185188
}
186189

187190
pub fn nodelay(&self) -> io::Result<bool> {
188191
abi::tcpstream::nodelay(*self.0.as_inner())
189-
.map_err(|_| io::Error::new_const(ErrorKind::Unknown, &"nodelay failed"))
192+
.map_err(|_| io::Error::new_const(ErrorKind::Uncategorized, &"nodelay failed"))
190193
}
191194

192195
pub fn set_ttl(&self, tll: u32) -> io::Result<()> {
193196
abi::tcpstream::set_tll(*self.0.as_inner(), tll)
194-
.map_err(|_| io::Error::new_const(ErrorKind::Unknown, &"unable to set TTL"))
197+
.map_err(|_| io::Error::new_const(ErrorKind::Uncategorized, &"unable to set TTL"))
195198
}
196199

197200
pub fn ttl(&self) -> io::Result<u32> {
198201
abi::tcpstream::get_tll(*self.0.as_inner())
199-
.map_err(|_| io::Error::new_const(ErrorKind::Unknown, &"unable to get TTL"))
202+
.map_err(|_| io::Error::new_const(ErrorKind::Uncategorized, &"unable to get TTL"))
200203
}
201204

202205
pub fn take_error(&self) -> io::Result<Option<io::Error>> {
203206
unsupported()
204207
}
205208

206209
pub fn set_nonblocking(&self, mode: bool) -> io::Result<()> {
207-
abi::tcpstream::set_nonblocking(*self.0.as_inner(), mode)
208-
.map_err(|_| io::Error::new_const(ErrorKind::Unknown, &"unable to set blocking mode"))
210+
abi::tcpstream::set_nonblocking(*self.0.as_inner(), mode).map_err(|_| {
211+
io::Error::new_const(ErrorKind::Uncategorized, &"unable to set blocking mode")
212+
})
209213
}
210214
}
211215

@@ -231,12 +235,12 @@ impl TcpListener {
231235

232236
pub fn accept(&self) -> io::Result<(TcpStream, SocketAddr)> {
233237
let (handle, ipaddr, port) = abi::tcplistener::accept(self.0.port())
234-
.map_err(|_| io::Error::new_const(ErrorKind::Unknown, &"accept failed"))?;
238+
.map_err(|_| io::Error::new_const(ErrorKind::Uncategorized, &"accept failed"))?;
235239
let saddr = match ipaddr {
236240
Ipv4(ref addr) => SocketAddr::new(IpAddr::V4(Ipv4Addr::from(addr.0)), port),
237241
Ipv6(ref addr) => SocketAddr::new(IpAddr::V6(Ipv6Addr::from(addr.0)), port),
238242
_ => {
239-
return Err(io::Error::new_const(ErrorKind::Unknown, &"accept failed"));
243+
return Err(io::Error::new_const(ErrorKind::Uncategorized, &"accept failed"));
240244
}
241245
};
242246

library/std/src/sys/hermit/stdio.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl io::Write for Stdout {
4040
unsafe { len = abi::write(1, data.as_ptr() as *const u8, data.len()) }
4141

4242
if len < 0 {
43-
Err(io::Error::new_const(io::ErrorKind::Unknown, &"Stdout is not able to print"))
43+
Err(io::Error::new_const(io::ErrorKind::Uncategorized, &"Stdout is not able to print"))
4444
} else {
4545
Ok(len as usize)
4646
}
@@ -52,7 +52,7 @@ impl io::Write for Stdout {
5252
unsafe { len = abi::write(1, data.as_ptr() as *const u8, data.len()) }
5353

5454
if len < 0 {
55-
Err(io::Error::new_const(io::ErrorKind::Unknown, &"Stdout is not able to print"))
55+
Err(io::Error::new_const(io::ErrorKind::Uncategorized, &"Stdout is not able to print"))
5656
} else {
5757
Ok(len as usize)
5858
}
@@ -81,7 +81,7 @@ impl io::Write for Stderr {
8181
unsafe { len = abi::write(2, data.as_ptr() as *const u8, data.len()) }
8282

8383
if len < 0 {
84-
Err(io::Error::new_const(io::ErrorKind::Unknown, &"Stderr is not able to print"))
84+
Err(io::Error::new_const(io::ErrorKind::Uncategorized, &"Stderr is not able to print"))
8585
} else {
8686
Ok(len as usize)
8787
}
@@ -93,7 +93,7 @@ impl io::Write for Stderr {
9393
unsafe { len = abi::write(2, data.as_ptr() as *const u8, data.len()) }
9494

9595
if len < 0 {
96-
Err(io::Error::new_const(io::ErrorKind::Unknown, &"Stderr is not able to print"))
96+
Err(io::Error::new_const(io::ErrorKind::Uncategorized, &"Stderr is not able to print"))
9797
} else {
9898
Ok(len as usize)
9999
}

library/std/src/sys/hermit/thread.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ impl Thread {
3737
// The thread failed to start and as a result p was not consumed. Therefore, it is
3838
// safe to reconstruct the box so that it gets deallocated.
3939
drop(Box::from_raw(p));
40-
Err(io::Error::new_const(io::ErrorKind::Unknown, &"Unable to create thread!"))
40+
Err(io::Error::new_const(io::ErrorKind::Uncategorized, &"Unable to create thread!"))
4141
} else {
4242
Ok(Thread { tid: tid })
4343
};

library/std/src/sys/sgx/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ pub fn sgx_ineffective<T>(v: T) -> crate::io::Result<T> {
7070
static SGX_INEFFECTIVE_ERROR: AtomicBool = AtomicBool::new(false);
7171
if SGX_INEFFECTIVE_ERROR.load(Ordering::Relaxed) {
7272
Err(crate::io::Error::new_const(
73-
ErrorKind::Unknown,
73+
ErrorKind::Uncategorized,
7474
&"operation can't be trusted to have any effect on SGX",
7575
))
7676
} else {
@@ -115,11 +115,11 @@ pub fn decode_error_kind(code: i32) -> ErrorKind {
115115
} else if code == Error::Interrupted as _ {
116116
ErrorKind::Interrupted
117117
} else if code == Error::Other as _ {
118-
ErrorKind::Unknown
118+
ErrorKind::Uncategorized
119119
} else if code == Error::UnexpectedEof as _ {
120120
ErrorKind::UnexpectedEof
121121
} else {
122-
ErrorKind::Unknown
122+
ErrorKind::Uncategorized
123123
}
124124
}
125125

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ pub struct LookupHost(!);
466466

467467
impl LookupHost {
468468
fn new(host: String) -> io::Result<LookupHost> {
469-
Err(io::Error::new(io::ErrorKind::Unknown, NonIpSockAddr { host }))
469+
Err(io::Error::new(io::ErrorKind::Uncategorized, NonIpSockAddr { host }))
470470
}
471471

472472
pub fn port(&self) -> u16 {

library/std/src/sys/sgx/stdio.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl io::Write for Stderr {
6565
pub const STDIN_BUF_SIZE: usize = crate::sys_common::io::DEFAULT_BUF_SIZE;
6666

6767
pub fn is_ebadf(err: &io::Error) -> bool {
68-
// FIXME: Rust normally maps Unix EBADF to `Unknown`
68+
// FIXME: Rust normally maps Unix EBADF to `Uncategorized`
6969
err.raw_os_error() == Some(abi::Error::BrokenPipe as _)
7070
}
7171

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ impl FileAttr {
358358
}))
359359
} else {
360360
Err(io::Error::new_const(
361-
io::ErrorKind::Unknown,
361+
io::ErrorKind::Uncategorized,
362362
&"creation time is not available for the filesystem",
363363
))
364364
};

library/std/src/sys/unix/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ pub fn decode_error_kind(errno: i32) -> ErrorKind {
155155
// clause
156156
x if x == libc::EAGAIN || x == libc::EWOULDBLOCK => ErrorKind::WouldBlock,
157157

158-
_ => ErrorKind::Unknown,
158+
_ => ErrorKind::Uncategorized,
159159
}
160160
}
161161

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub fn cvt_gai(err: c_int) -> io::Result<()> {
3838
str::from_utf8(CStr::from_ptr(libc::gai_strerror(err)).to_bytes()).unwrap().to_owned()
3939
};
4040
Err(io::Error::new(
41-
io::ErrorKind::Unknown,
41+
io::ErrorKind::Uncategorized,
4242
&format!("failed to lookup address information: {}", detail)[..],
4343
))
4444
}
@@ -178,7 +178,7 @@ impl Socket {
178178
if pollfd.revents & libc::POLLHUP != 0 {
179179
let e = self.take_error()?.unwrap_or_else(|| {
180180
io::Error::new_const(
181-
io::ErrorKind::Unknown,
181+
io::ErrorKind::Uncategorized,
182182
&"no error set after POLLHUP",
183183
)
184184
});

0 commit comments

Comments
 (0)