Skip to content

Rollup of 5 pull requests #84302

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
e23b035
Reduce visual weight of attributes.
jsha Apr 18, 2021
18fbd36
rustdoc: get rid of CURRENT_DEPTH
notriddle Apr 18, 2021
4a15bd8
Add and insta-stabilize `std::io::ErrorKind::NotSupported`
CDirkx Nov 20, 2020
9f589b0
Update `decode_error_kind` to decode os errors to `NotSupported`
CDirkx Feb 12, 2021
86592b9
Bump since to 1.52.0
CDirkx Feb 23, 2021
1b5f117
Use `NotSupported` in more places
CDirkx Feb 25, 2021
af0dec2
Rename `NotSupported` to `Unsupported`
CDirkx Mar 19, 2021
0895a69
Fix test `metadata_access_times` to also check for `Unsupported`
CDirkx Mar 19, 2021
b42e52f
Bump to 1.53.0
CDirkx Mar 21, 2021
5b5afae
Fix clippy test using `ErrorKind`
CDirkx Mar 29, 2021
0c736e9
Add stability tags to ImportItem.
Apr 5, 2021
41f49aa
Added a test.
Apr 8, 2021
1e2ab99
Give import items their own CSS class.
Apr 13, 2021
fca088a
Now also displays portability tags.
Apr 14, 2021
e2a77b3
Test Deprecated, Portability, and Unstable.
Apr 14, 2021
3ecaf57
Slightly change wording and fix typo in vec/mod.rs
WaffleLapkin Apr 18, 2021
3541fd2
Rollup merge of #78880 - CDirkx:not_supported, r=joshtriplett
GuillaumeGomez Apr 18, 2021
40ccb63
Rollup merge of #83900 - torhovland:issue-83832, r=jyn514,GuillaumeGomez
GuillaumeGomez Apr 18, 2021
d20c74a
Rollup merge of #84283 - jsha:de-emphasize-attributes, r=GuillaumeGomez
GuillaumeGomez Apr 18, 2021
16b4792
Rollup merge of #84288 - notriddle:short-links, r=jyn514
GuillaumeGomez Apr 18, 2021
cc3d6e5
Rollup merge of #84294 - WaffleLapkin:patch-2, r=jonas-schievink
GuillaumeGomez Apr 18, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions library/alloc/src/vec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2041,7 +2041,7 @@ impl<T, A: Allocator> Vec<T, A> {

/// Safety: changing returned .2 (&mut usize) is considered the same as calling `.set_len(_)`.
///
/// This method is used to have unique access to all vec parts at once in `extend_from_within`.
/// This method provides unique access to all vec parts at once in `extend_from_within`.
unsafe fn split_at_spare_mut_with_len(
&mut self,
) -> (&mut [T], &mut [MaybeUninit<T>], &mut usize) {
Expand Down Expand Up @@ -2279,7 +2279,7 @@ impl<T: Clone, A: Allocator> ExtendFromWithinSpec for Vec<T, A> {
iter::zip(to_clone, spare)
.map(|(src, dst)| dst.write(src.clone()))
// Note:
// - Element was just initialized with `MaybeUninit::write`, so it's ok to increace len
// - Element was just initialized with `MaybeUninit::write`, so it's ok to increase len
// - len is increased after each element to prevent leaks (see issue #82533)
.for_each(|_| *len += 1);
}
Expand Down
4 changes: 3 additions & 1 deletion library/std/src/fs/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1329,7 +1329,9 @@ fn metadata_access_times() {
match (a.created(), b.created()) {
(Ok(t1), Ok(t2)) => assert!(t1 <= t2),
(Err(e1), Err(e2))
if e1.kind() == ErrorKind::Other && e2.kind() == ErrorKind::Other => {}
if e1.kind() == ErrorKind::Other && e2.kind() == ErrorKind::Other
|| e1.kind() == ErrorKind::Unsupported
&& e2.kind() == ErrorKind::Unsupported => {}
(a, b) => {
panic!("creation time must be always supported or not supported: {:?} {:?}", a, b,)
}
Expand Down
7 changes: 7 additions & 0 deletions library/std/src/io/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,12 @@ pub enum ErrorKind {
/// read.
#[stable(feature = "read_exact", since = "1.6.0")]
UnexpectedEof,

/// This operation is unsupported on this platform.
///
/// This means that the operation can never succeed.
#[stable(feature = "unsupported_error", since = "1.53.0")]
Unsupported,
}

impl ErrorKind {
Expand All @@ -203,6 +209,7 @@ impl ErrorKind {
ErrorKind::Interrupted => "operation interrupted",
ErrorKind::Other => "other os error",
ErrorKind::UnexpectedEof => "unexpected end of file",
ErrorKind::Unsupported => "unsupported",
}
}
}
Expand Down
9 changes: 5 additions & 4 deletions library/std/src/sys/hermit/fd.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#![unstable(reason = "not public", issue = "none", feature = "fd")]

use crate::io::{self, ErrorKind, Read};
use crate::io::{self, Read};
use crate::mem;
use crate::sys::cvt;
use crate::sys::hermit::abi;
use crate::sys::unsupported;
use crate::sys_common::AsInner;

#[derive(Debug)]
Expand Down Expand Up @@ -46,19 +47,19 @@ impl FileDesc {
self.duplicate_path(&[])
}
pub fn duplicate_path(&self, _path: &[u8]) -> io::Result<FileDesc> {
Err(io::Error::new_const(ErrorKind::Other, &"duplicate isn't supported"))
unsupported()
}

pub fn nonblocking(&self) -> io::Result<bool> {
Ok(false)
}

pub fn set_cloexec(&self) -> io::Result<()> {
Err(io::Error::new_const(ErrorKind::Other, &"cloexec isn't supported"))
unsupported()
}

pub fn set_nonblocking(&self, _nonblocking: bool) -> io::Result<()> {
Err(io::Error::new_const(ErrorKind::Other, &"nonblocking isn't supported"))
unsupported()
}
}

Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/hermit/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub fn unsupported<T>() -> crate::io::Result<T> {

pub fn unsupported_err() -> crate::io::Error {
crate::io::Error::new_const(
crate::io::ErrorKind::Other,
crate::io::ErrorKind::Unsupported,
&"operation not supported on HermitCore yet",
)
}
Expand Down
78 changes: 39 additions & 39 deletions library/std/src/sys/hermit/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ impl TcpStream {
}

pub fn socket_addr(&self) -> io::Result<SocketAddr> {
Err(io::Error::new_const(ErrorKind::Other, &"socket_addr isn't supported"))
unsupported()
}

pub fn shutdown(&self, how: Shutdown) -> io::Result<()> {
Expand Down Expand Up @@ -199,7 +199,7 @@ impl TcpStream {
}

pub fn take_error(&self) -> io::Result<Option<io::Error>> {
Err(io::Error::new_const(ErrorKind::Other, &"take_error isn't supported"))
unsupported()
}

pub fn set_nonblocking(&self, mode: bool) -> io::Result<()> {
Expand Down Expand Up @@ -247,27 +247,27 @@ impl TcpListener {
}

pub fn set_ttl(&self, _: u32) -> io::Result<()> {
Err(io::Error::new_const(ErrorKind::Other, &"not supported"))
unsupported()
}

pub fn ttl(&self) -> io::Result<u32> {
Err(io::Error::new_const(ErrorKind::Other, &"not supported"))
unsupported()
}

pub fn set_only_v6(&self, _: bool) -> io::Result<()> {
Err(io::Error::new_const(ErrorKind::Other, &"not supported"))
unsupported()
}

pub fn only_v6(&self) -> io::Result<bool> {
Err(io::Error::new_const(ErrorKind::Other, &"not supported"))
unsupported()
}

pub fn take_error(&self) -> io::Result<Option<io::Error>> {
Err(io::Error::new_const(ErrorKind::Other, &"not supported"))
unsupported()
}

pub fn set_nonblocking(&self, _: bool) -> io::Result<()> {
Err(io::Error::new_const(ErrorKind::Other, &"not supported"))
unsupported()
}
}

Expand All @@ -281,127 +281,127 @@ pub struct UdpSocket(abi::Handle);

impl UdpSocket {
pub fn bind(_: io::Result<&SocketAddr>) -> io::Result<UdpSocket> {
Err(io::Error::new_const(ErrorKind::Other, &"not supported"))
unsupported()
}

pub fn peer_addr(&self) -> io::Result<SocketAddr> {
Err(io::Error::new_const(ErrorKind::Other, &"not supported"))
unsupported()
}

pub fn socket_addr(&self) -> io::Result<SocketAddr> {
Err(io::Error::new_const(ErrorKind::Other, &"not supported"))
unsupported()
}

pub fn recv_from(&self, _: &mut [u8]) -> io::Result<(usize, SocketAddr)> {
Err(io::Error::new_const(ErrorKind::Other, &"not supported"))
unsupported()
}

pub fn peek_from(&self, _: &mut [u8]) -> io::Result<(usize, SocketAddr)> {
Err(io::Error::new_const(ErrorKind::Other, &"not supported"))
unsupported()
}

pub fn send_to(&self, _: &[u8], _: &SocketAddr) -> io::Result<usize> {
Err(io::Error::new_const(ErrorKind::Other, &"not supported"))
unsupported()
}

pub fn duplicate(&self) -> io::Result<UdpSocket> {
Err(io::Error::new_const(ErrorKind::Other, &"not supported"))
unsupported()
}

pub fn set_read_timeout(&self, _: Option<Duration>) -> io::Result<()> {
Err(io::Error::new_const(ErrorKind::Other, &"not supported"))
unsupported()
}

pub fn set_write_timeout(&self, _: Option<Duration>) -> io::Result<()> {
Err(io::Error::new_const(ErrorKind::Other, &"not supported"))
unsupported()
}

pub fn read_timeout(&self) -> io::Result<Option<Duration>> {
Err(io::Error::new_const(ErrorKind::Other, &"not supported"))
unsupported()
}

pub fn write_timeout(&self) -> io::Result<Option<Duration>> {
Err(io::Error::new_const(ErrorKind::Other, &"not supported"))
unsupported()
}

pub fn set_broadcast(&self, _: bool) -> io::Result<()> {
Err(io::Error::new_const(ErrorKind::Other, &"not supported"))
unsupported()
}

pub fn broadcast(&self) -> io::Result<bool> {
Err(io::Error::new_const(ErrorKind::Other, &"not supported"))
unsupported()
}

pub fn set_multicast_loop_v4(&self, _: bool) -> io::Result<()> {
Err(io::Error::new_const(ErrorKind::Other, &"not supported"))
unsupported()
}

pub fn multicast_loop_v4(&self) -> io::Result<bool> {
Err(io::Error::new_const(ErrorKind::Other, &"not supported"))
unsupported()
}

pub fn set_multicast_ttl_v4(&self, _: u32) -> io::Result<()> {
Err(io::Error::new_const(ErrorKind::Other, &"not supported"))
unsupported()
}

pub fn multicast_ttl_v4(&self) -> io::Result<u32> {
Err(io::Error::new_const(ErrorKind::Other, &"not supported"))
unsupported()
}

pub fn set_multicast_loop_v6(&self, _: bool) -> io::Result<()> {
Err(io::Error::new_const(ErrorKind::Other, &"not supported"))
unsupported()
}

pub fn multicast_loop_v6(&self) -> io::Result<bool> {
Err(io::Error::new_const(ErrorKind::Other, &"not supported"))
unsupported()
}

pub fn join_multicast_v4(&self, _: &Ipv4Addr, _: &Ipv4Addr) -> io::Result<()> {
Err(io::Error::new_const(ErrorKind::Other, &"not supported"))
unsupported()
}

pub fn join_multicast_v6(&self, _: &Ipv6Addr, _: u32) -> io::Result<()> {
Err(io::Error::new_const(ErrorKind::Other, &"not supported"))
unsupported()
}

pub fn leave_multicast_v4(&self, _: &Ipv4Addr, _: &Ipv4Addr) -> io::Result<()> {
Err(io::Error::new_const(ErrorKind::Other, &"not supported"))
unsupported()
}

pub fn leave_multicast_v6(&self, _: &Ipv6Addr, _: u32) -> io::Result<()> {
Err(io::Error::new_const(ErrorKind::Other, &"not supported"))
unsupported()
}

pub fn set_ttl(&self, _: u32) -> io::Result<()> {
Err(io::Error::new_const(ErrorKind::Other, &"not supported"))
unsupported()
}

pub fn ttl(&self) -> io::Result<u32> {
Err(io::Error::new_const(ErrorKind::Other, &"not supported"))
unsupported()
}

pub fn take_error(&self) -> io::Result<Option<io::Error>> {
Err(io::Error::new_const(ErrorKind::Other, &"not supported"))
unsupported()
}

pub fn set_nonblocking(&self, _: bool) -> io::Result<()> {
Err(io::Error::new_const(ErrorKind::Other, &"not supported"))
unsupported()
}

pub fn recv(&self, _: &mut [u8]) -> io::Result<usize> {
Err(io::Error::new_const(ErrorKind::Other, &"not supported"))
unsupported()
}

pub fn peek(&self, _: &mut [u8]) -> io::Result<usize> {
Err(io::Error::new_const(ErrorKind::Other, &"not supported"))
unsupported()
}

pub fn send(&self, _: &[u8]) -> io::Result<usize> {
Err(io::Error::new_const(ErrorKind::Other, &"not supported"))
unsupported()
}

pub fn connect(&self, _: io::Result<&SocketAddr>) -> io::Result<()> {
Err(io::Error::new_const(ErrorKind::Other, &"not supported"))
unsupported()
}
}

Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/sgx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub fn unsupported<T>() -> crate::io::Result<T> {
}

pub fn unsupported_err() -> crate::io::Error {
crate::io::Error::new_const(ErrorKind::Other, &"operation not supported on SGX yet")
crate::io::Error::new_const(ErrorKind::Unsupported, &"operation not supported on SGX yet")
}

/// This function is used to implement various functions that doesn't exist,
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/unix/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ impl FileAttr {
}

Err(io::Error::new_const(
io::ErrorKind::Other,
io::ErrorKind::Unsupported,
&"creation time is not available on this platform \
currently",
))
Expand Down
5 changes: 4 additions & 1 deletion library/std/src/sys/unix/l4re.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
macro_rules! unimpl {
() => {
return Err(io::Error::new_const(io::ErrorKind::Other, &"No networking available on L4Re."));
return Err(io::Error::new_const(
io::ErrorKind::Unsupported,
&"No networking available on L4Re.",
));
};
}

Expand Down
1 change: 1 addition & 0 deletions library/std/src/sys/unix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ pub fn decode_error_kind(errno: i32) -> ErrorKind {
libc::EINVAL => ErrorKind::InvalidInput,
libc::ETIMEDOUT => ErrorKind::TimedOut,
libc::EEXIST => ErrorKind::AlreadyExists,
libc::ENOSYS => ErrorKind::Unsupported,

// These two constants can have the same value on some systems,
// but different values on others, so we can't use a match
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/unix/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ pub fn current_exe() -> io::Result<PathBuf> {
#[cfg(any(target_os = "fuchsia", target_os = "l4re"))]
pub fn current_exe() -> io::Result<PathBuf> {
use crate::io::ErrorKind;
Err(io::Error::new_const(ErrorKind::Other, &"Not yet implemented!"))
Err(io::Error::new_const(ErrorKind::Unsupported, &"Not yet implemented!"))
}

#[cfg(target_os = "vxworks")]
Expand Down
5 changes: 4 additions & 1 deletion library/std/src/sys/unsupported/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ pub fn unsupported<T>() -> std_io::Result<T> {
}

pub fn unsupported_err() -> std_io::Error {
std_io::Error::new_const(std_io::ErrorKind::Other, &"operation not supported on this platform")
std_io::Error::new_const(
std_io::ErrorKind::Unsupported,
&"operation not supported on this platform",
)
}

pub fn decode_error_kind(_code: i32) -> crate::io::ErrorKind {
Expand Down
4 changes: 2 additions & 2 deletions library/std/src/sys/unsupported/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ pub fn getenv(_: &OsStr) -> io::Result<Option<OsString>> {
}

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

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

pub fn temp_dir() -> PathBuf {
Expand Down
1 change: 1 addition & 0 deletions library/std/src/sys/vxworks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ pub fn decode_error_kind(errno: i32) -> ErrorKind {
libc::EINVAL => ErrorKind::InvalidInput,
libc::ETIMEDOUT => ErrorKind::TimedOut,
libc::EEXIST => ErrorKind::AlreadyExists,
libc::ENOSYS => ErrorKind::Unsupported,

// These two constants can have the same value on some systems,
// but different values on others, so we can't use a match
Expand Down
1 change: 1 addition & 0 deletions library/std/src/sys/wasi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ pub fn decode_error_kind(errno: i32) -> std_io::ErrorKind {
wasi::ERRNO_TIMEDOUT => TimedOut,
wasi::ERRNO_EXIST => AlreadyExists,
wasi::ERRNO_AGAIN => WouldBlock,
wasi::ERRNO_NOSYS => Unsupported,
_ => Other,
}
}
Expand Down
Loading