Skip to content

Commit 4a15bd8

Browse files
committed
Add and insta-stabilize std::io::ErrorKind::NotSupported
1 parent 9c3b66c commit 4a15bd8

File tree

6 files changed

+11
-6
lines changed

6 files changed

+11
-6
lines changed

library/std/src/io/error.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,10 @@ pub enum ErrorKind {
180180
/// read.
181181
#[stable(feature = "read_exact", since = "1.6.0")]
182182
UnexpectedEof,
183+
184+
/// This operation is not supported on this platform.
185+
#[stable(feature = "not_supported_error", since = "1.50.0")]
186+
NotSupported,
183187
}
184188

185189
impl ErrorKind {
@@ -203,6 +207,7 @@ impl ErrorKind {
203207
ErrorKind::Interrupted => "operation interrupted",
204208
ErrorKind::Other => "other os error",
205209
ErrorKind::UnexpectedEof => "unexpected end of file",
210+
ErrorKind::NotSupported => "not supported",
206211
}
207212
}
208213
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
macro_rules! unimpl {
22
() => {
3-
return Err(io::Error::new_const(io::ErrorKind::Other, &"No networking available on L4Re."));
3+
return Err(io::Error::new_const(io::ErrorKind::NotSupported, &"No networking available on L4Re."));
44
};
55
}
66

library/std/src/sys/unsupported/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub fn unsupported<T>() -> std_io::Result<T> {
1818
}
1919

2020
pub fn unsupported_err() -> std_io::Error {
21-
std_io::Error::new_const(std_io::ErrorKind::Other, &"operation not supported on this platform")
21+
std_io::Error::new_const(std_io::ErrorKind::NotSupported, &"operation not supported on this platform")
2222
}
2323

2424
pub fn decode_error_kind(_code: i32) -> crate::io::ErrorKind {

library/std/src/sys/unsupported/os.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,11 @@ pub fn getenv(_: &OsStr) -> io::Result<Option<OsString>> {
8080
}
8181

8282
pub fn setenv(_: &OsStr, _: &OsStr) -> io::Result<()> {
83-
Err(io::Error::new_const(io::ErrorKind::Other, &"cannot set env vars on this platform"))
83+
Err(io::Error::new_const(io::ErrorKind::NotSupported, &"cannot set env vars on this platform"))
8484
}
8585

8686
pub fn unsetenv(_: &OsStr) -> io::Result<()> {
87-
Err(io::Error::new_const(io::ErrorKind::Other, &"cannot unset env vars on this platform"))
87+
Err(io::Error::new_const(io::ErrorKind::NotSupported, &"cannot unset env vars on this platform"))
8888
}
8989

9090
pub fn temp_dir() -> PathBuf {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,7 @@ pub fn link(original: &Path, link: &Path) -> io::Result<()> {
802802

803803
#[cfg(target_vendor = "uwp")]
804804
pub fn link(_original: &Path, _link: &Path) -> io::Result<()> {
805-
return Err(io::Error::new_const(io::ErrorKind::Other, &"hard link are not supported on UWP"));
805+
return Err(io::Error::new_const(io::ErrorKind::NotSupported, &"hard link are not supported on UWP"));
806806
}
807807

808808
pub fn stat(path: &Path) -> io::Result<FileAttr> {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ impl Socket {
370370

371371
#[cfg(target_vendor = "uwp")]
372372
fn set_no_inherit(&self) -> io::Result<()> {
373-
Err(io::Error::new_const(io::ErrorKind::Other, &"Unavailable on UWP"))
373+
Err(io::Error::new_const(io::ErrorKind::NotSupported, &"Unavailable on UWP"))
374374
}
375375

376376
pub fn shutdown(&self, how: Shutdown) -> io::Result<()> {

0 commit comments

Comments
 (0)