From 9aa6c1e0c9ec1b24862ac061118a539706fbd7dc Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 16 Apr 2021 20:35:14 +0200 Subject: [PATCH 01/28] fix 'const-stable since' for NonZeroU*::new_unchecked --- library/core/src/num/nonzero.rs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/library/core/src/num/nonzero.rs b/library/core/src/num/nonzero.rs index 81262a2f91839..6b9b435d47fe9 100644 --- a/library/core/src/num/nonzero.rs +++ b/library/core/src/num/nonzero.rs @@ -23,7 +23,7 @@ macro_rules! impl_nonzero_fmt { } macro_rules! nonzero_integers { - ( $( #[$stability: meta] $Ty: ident($Int: ty); )+ ) => { + ( $( #[$stability: meta] #[$const_new_unchecked_stability: meta] $Ty: ident($Int: ty); )+ ) => { $( /// An integer that is known not to equal zero. /// @@ -48,7 +48,7 @@ macro_rules! nonzero_integers { /// /// The value must not be zero. #[$stability] - #[rustc_const_stable(feature = "nonzero", since = "1.34.0")] + #[$const_new_unchecked_stability] #[inline] pub const unsafe fn new_unchecked(n: $Int) -> Self { // SAFETY: this is guaranteed to be safe by the caller. @@ -146,18 +146,18 @@ macro_rules! nonzero_integers { } nonzero_integers! { - #[stable(feature = "nonzero", since = "1.28.0")] NonZeroU8(u8); - #[stable(feature = "nonzero", since = "1.28.0")] NonZeroU16(u16); - #[stable(feature = "nonzero", since = "1.28.0")] NonZeroU32(u32); - #[stable(feature = "nonzero", since = "1.28.0")] NonZeroU64(u64); - #[stable(feature = "nonzero", since = "1.28.0")] NonZeroU128(u128); - #[stable(feature = "nonzero", since = "1.28.0")] NonZeroUsize(usize); - #[stable(feature = "signed_nonzero", since = "1.34.0")] NonZeroI8(i8); - #[stable(feature = "signed_nonzero", since = "1.34.0")] NonZeroI16(i16); - #[stable(feature = "signed_nonzero", since = "1.34.0")] NonZeroI32(i32); - #[stable(feature = "signed_nonzero", since = "1.34.0")] NonZeroI64(i64); - #[stable(feature = "signed_nonzero", since = "1.34.0")] NonZeroI128(i128); - #[stable(feature = "signed_nonzero", since = "1.34.0")] NonZeroIsize(isize); + #[stable(feature = "nonzero", since = "1.28.0")] #[rustc_const_stable(feature = "nonzero", since = "1.28.0")] NonZeroU8(u8); + #[stable(feature = "nonzero", since = "1.28.0")] #[rustc_const_stable(feature = "nonzero", since = "1.28.0")] NonZeroU16(u16); + #[stable(feature = "nonzero", since = "1.28.0")] #[rustc_const_stable(feature = "nonzero", since = "1.28.0")] NonZeroU32(u32); + #[stable(feature = "nonzero", since = "1.28.0")] #[rustc_const_stable(feature = "nonzero", since = "1.28.0")] NonZeroU64(u64); + #[stable(feature = "nonzero", since = "1.28.0")] #[rustc_const_stable(feature = "nonzero", since = "1.28.0")] NonZeroU128(u128); + #[stable(feature = "nonzero", since = "1.28.0")] #[rustc_const_stable(feature = "nonzero", since = "1.28.0")] NonZeroUsize(usize); + #[stable(feature = "signed_nonzero", since = "1.34.0")] #[rustc_const_stable(feature = "signed_nonzero", since = "1.34.0")] NonZeroI8(i8); + #[stable(feature = "signed_nonzero", since = "1.34.0")] #[rustc_const_stable(feature = "signed_nonzero", since = "1.34.0")] NonZeroI16(i16); + #[stable(feature = "signed_nonzero", since = "1.34.0")] #[rustc_const_stable(feature = "signed_nonzero", since = "1.34.0")] NonZeroI32(i32); + #[stable(feature = "signed_nonzero", since = "1.34.0")] #[rustc_const_stable(feature = "signed_nonzero", since = "1.34.0")] NonZeroI64(i64); + #[stable(feature = "signed_nonzero", since = "1.34.0")] #[rustc_const_stable(feature = "signed_nonzero", since = "1.34.0")] NonZeroI128(i128); + #[stable(feature = "signed_nonzero", since = "1.34.0")] #[rustc_const_stable(feature = "signed_nonzero", since = "1.34.0")] NonZeroIsize(isize); } macro_rules! from_str_radix_nzint_impl { From df01b3a67b33ef0ff7ab1f27f41056093f5b2574 Mon Sep 17 00:00:00 2001 From: r00ster Date: Sun, 18 Apr 2021 15:51:16 +0200 Subject: [PATCH 02/28] Document that `index` and `index_mut` can panic --- library/core/src/ops/index.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/library/core/src/ops/index.rs b/library/core/src/ops/index.rs index a8dea4e9b4ea8..515ccd6aa2389 100644 --- a/library/core/src/ops/index.rs +++ b/library/core/src/ops/index.rs @@ -61,6 +61,10 @@ pub trait Index { type Output: ?Sized; /// Performs the indexing (`container[index]`) operation. + /// + /// # Panics + /// + /// Panics if the index is out of bounds. #[stable(feature = "rust1", since = "1.0.0")] #[track_caller] fn index(&self, index: Idx) -> &Self::Output; @@ -161,6 +165,10 @@ see chapter in The Book : Index { /// Performs the mutable indexing (`container[index]`) operation. + /// + /// # Panics + /// + /// Panics if the index is out of bounds. #[stable(feature = "rust1", since = "1.0.0")] #[track_caller] fn index_mut(&mut self, index: Idx) -> &mut Self::Output; From c86ffe9e8910cb1bac1737878a524e146b54375e Mon Sep 17 00:00:00 2001 From: r00ster Date: Sun, 18 Apr 2021 18:16:10 +0200 Subject: [PATCH 03/28] Say that it "may panic" --- library/core/src/ops/index.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/core/src/ops/index.rs b/library/core/src/ops/index.rs index 515ccd6aa2389..964378cc9c3c6 100644 --- a/library/core/src/ops/index.rs +++ b/library/core/src/ops/index.rs @@ -64,7 +64,7 @@ pub trait Index { /// /// # Panics /// - /// Panics if the index is out of bounds. + /// May panic if the index is out of bounds. #[stable(feature = "rust1", since = "1.0.0")] #[track_caller] fn index(&self, index: Idx) -> &Self::Output; @@ -168,7 +168,7 @@ pub trait IndexMut: Index { /// /// # Panics /// - /// Panics if the index is out of bounds. + /// May panic if the index is out of bounds. #[stable(feature = "rust1", since = "1.0.0")] #[track_caller] fn index_mut(&mut self, index: Idx) -> &mut Self::Output; From 12120409d56ecfb5bd8ddd06bfecd0443b043834 Mon Sep 17 00:00:00 2001 From: Christiaan Dirkx Date: Mon, 12 Apr 2021 05:58:30 +0200 Subject: [PATCH 04/28] Move `sys::vxworks` code to `sys::unix` --- library/std/src/sys/mod.rs | 5 +- library/std/src/sys/unix/env.rs | 11 ++ library/std/src/sys/unix/ext/mod.rs | 2 + library/std/src/sys/unix/mod.rs | 1 + library/std/src/sys/unix/process/mod.rs | 22 ++- .../process/process_vxworks.rs | 2 +- library/std/src/sys/unix/rand.rs | 29 +++- library/std/src/sys/unix/thread_local_dtor.rs | 6 + library/std/src/sys/vxworks/env.rs | 9 -- library/std/src/sys/vxworks/mod.rs | 138 ------------------ library/std/src/sys/vxworks/process/mod.rs | 9 -- library/std/src/sys/vxworks/rand.rs | 36 ----- .../std/src/sys/vxworks/thread_local_dtor.rs | 7 - 13 files changed, 64 insertions(+), 213 deletions(-) rename library/std/src/sys/{vxworks => unix}/process/process_vxworks.rs (99%) delete mode 100644 library/std/src/sys/vxworks/env.rs delete mode 100644 library/std/src/sys/vxworks/mod.rs delete mode 100644 library/std/src/sys/vxworks/process/mod.rs delete mode 100644 library/std/src/sys/vxworks/rand.rs delete mode 100644 library/std/src/sys/vxworks/thread_local_dtor.rs diff --git a/library/std/src/sys/mod.rs b/library/std/src/sys/mod.rs index 50c2660ebcf1f..2450a7aac5ede 100644 --- a/library/std/src/sys/mod.rs +++ b/library/std/src/sys/mod.rs @@ -25,10 +25,7 @@ mod common; cfg_if::cfg_if! { - if #[cfg(target_os = "vxworks")] { - mod vxworks; - pub use self::vxworks::*; - } else if #[cfg(unix)] { + if #[cfg(unix)] { mod unix; pub use self::unix::*; } else if #[cfg(windows)] { diff --git a/library/std/src/sys/unix/env.rs b/library/std/src/sys/unix/env.rs index 7f5e9b04dba4b..3a88dc083b06c 100644 --- a/library/std/src/sys/unix/env.rs +++ b/library/std/src/sys/unix/env.rs @@ -173,3 +173,14 @@ pub mod os { pub const EXE_SUFFIX: &str = ""; pub const EXE_EXTENSION: &str = ""; } + +#[cfg(target_os = "vxworks")] +pub mod os { + pub const FAMILY: &str = "unix"; + pub const OS: &str = "vxworks"; + pub const DLL_PREFIX: &str = "lib"; + pub const DLL_SUFFIX: &str = ".so"; + pub const DLL_EXTENSION: &str = "so"; + pub const EXE_SUFFIX: &str = ""; + pub const EXE_EXTENSION: &str = ""; +} diff --git a/library/std/src/sys/unix/ext/mod.rs b/library/std/src/sys/unix/ext/mod.rs index e5048f7e545e0..735bf35a3ced6 100644 --- a/library/std/src/sys/unix/ext/mod.rs +++ b/library/std/src/sys/unix/ext/mod.rs @@ -62,6 +62,8 @@ cfg_if::cfg_if! { use crate::os::redox as platform; #[cfg(target_os = "solaris")] use crate::os::solaris as platform; + #[cfg(target_os = "vxworks")] + use crate::os::vxworks as platform; } } diff --git a/library/std/src/sys/unix/mod.rs b/library/std/src/sys/unix/mod.rs index 6e44ac19c7b2c..1316835a89d12 100644 --- a/library/std/src/sys/unix/mod.rs +++ b/library/std/src/sys/unix/mod.rs @@ -71,6 +71,7 @@ pub fn init() { } else if #[cfg(not(any( target_os = "emscripten", target_os = "fuchsia", + target_os = "vxworks", // The poll on Darwin doesn't set POLLNVAL for closed fds. target_os = "macos", target_os = "ios", diff --git a/library/std/src/sys/unix/process/mod.rs b/library/std/src/sys/unix/process/mod.rs index 1b7b93f9d4a5f..f67c70c01772f 100644 --- a/library/std/src/sys/unix/process/mod.rs +++ b/library/std/src/sys/unix/process/mod.rs @@ -4,11 +4,17 @@ pub use crate::ffi::OsString as EnvKey; pub use crate::sys_common::process::CommandEnvs; mod process_common; -#[cfg(not(target_os = "fuchsia"))] -#[path = "process_unix.rs"] -mod process_inner; -#[cfg(target_os = "fuchsia")] -#[path = "process_fuchsia.rs"] -mod process_inner; -#[cfg(target_os = "fuchsia")] -mod zircon; + +cfg_if::cfg_if! { + if #[cfg(target_os = "fuchsia")] { + #[path = "process_fuchsia.rs"] + mod process_inner; + mod zircon; + } else if #[cfg(target_os = "vxworks")] { + #[path = "process_vxworks.rs"] + mod process_inner; + } else { + #[path = "process_unix.rs"] + mod process_inner; + } +} diff --git a/library/std/src/sys/vxworks/process/process_vxworks.rs b/library/std/src/sys/unix/process/process_vxworks.rs similarity index 99% rename from library/std/src/sys/vxworks/process/process_vxworks.rs rename to library/std/src/sys/unix/process/process_vxworks.rs index 295452327eb70..68605c2dfeebd 100644 --- a/library/std/src/sys/vxworks/process/process_vxworks.rs +++ b/library/std/src/sys/unix/process/process_vxworks.rs @@ -68,7 +68,7 @@ impl Command { let stack_size = thread::min_stack(); // ensure that access to the environment is synchronized - let _lock = sys::os::env_lock(); + let _lock = sys::os::env_read_lock(); let ret = libc::rtpSpawn( self.get_program_cstr().as_ptr(), diff --git a/library/std/src/sys/unix/rand.rs b/library/std/src/sys/unix/rand.rs index 38ddb41700c4b..44f9eabc319a0 100644 --- a/library/std/src/sys/unix/rand.rs +++ b/library/std/src/sys/unix/rand.rs @@ -18,7 +18,8 @@ pub fn hashmap_random_keys() -> (u64, u64) { not(target_os = "freebsd"), not(target_os = "netbsd"), not(target_os = "fuchsia"), - not(target_os = "redox") + not(target_os = "redox"), + not(target_os = "vxworks") ))] mod imp { use crate::fs::File; @@ -237,3 +238,29 @@ mod imp { file.read_exact(v).expect("failed to read rand:") } } + +#[cfg(target_os = "vxworks")] +mod imp { + use crate::io; + use core::sync::atomic::{AtomicBool, Ordering::Relaxed}; + + pub fn fill_bytes(v: &mut [u8]) { + static RNG_INIT: AtomicBool = AtomicBool::new(false); + while !RNG_INIT.load(Relaxed) { + let ret = unsafe { libc::randSecure() }; + if ret < 0 { + panic!("couldn't generate random bytes: {}", io::Error::last_os_error()); + } else if ret > 0 { + RNG_INIT.store(true, Relaxed); + break; + } + unsafe { libc::usleep(10) }; + } + let ret = unsafe { + libc::randABytes(v.as_mut_ptr() as *mut libc::c_uchar, v.len() as libc::c_int) + }; + if ret < 0 { + panic!("couldn't generate random bytes: {}", io::Error::last_os_error()); + } + } +} diff --git a/library/std/src/sys/unix/thread_local_dtor.rs b/library/std/src/sys/unix/thread_local_dtor.rs index c3275eb6f0e50..c3f410353b915 100644 --- a/library/std/src/sys/unix/thread_local_dtor.rs +++ b/library/std/src/sys/unix/thread_local_dtor.rs @@ -92,3 +92,9 @@ pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern "C" fn(*mut u8)) { } } } + +#[cfg(target_os = "vxworks")] +pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern "C" fn(*mut u8)) { + use crate::sys_common::thread_local_dtor::register_dtor_fallback; + register_dtor_fallback(t, dtor); +} diff --git a/library/std/src/sys/vxworks/env.rs b/library/std/src/sys/vxworks/env.rs deleted file mode 100644 index fe1aedd58590b..0000000000000 --- a/library/std/src/sys/vxworks/env.rs +++ /dev/null @@ -1,9 +0,0 @@ -pub mod os { - pub const FAMILY: &str = "vxworks"; - pub const OS: &str = "vxworks"; - pub const DLL_PREFIX: &str = "lib"; - pub const DLL_SUFFIX: &str = ".so"; - pub const DLL_EXTENSION: &str = "so"; - pub const EXE_SUFFIX: &str = ""; - pub const EXE_EXTENSION: &str = ""; -} diff --git a/library/std/src/sys/vxworks/mod.rs b/library/std/src/sys/vxworks/mod.rs deleted file mode 100644 index 12d0147a12981..0000000000000 --- a/library/std/src/sys/vxworks/mod.rs +++ /dev/null @@ -1,138 +0,0 @@ -#![allow(dead_code)] -#![allow(missing_docs, nonstandard_style)] - -use crate::io::ErrorKind; - -pub use self::rand::hashmap_random_keys; -pub use crate::os::vxworks as platform; -pub use libc::strlen; - -#[macro_use] -#[path = "../unix/weak.rs"] -pub mod weak; - -#[path = "../unix/alloc.rs"] -pub mod alloc; -#[path = "../unix/args.rs"] -pub mod args; -#[path = "../unix/cmath.rs"] -pub mod cmath; -#[path = "../unix/condvar.rs"] -pub mod condvar; -pub mod env; -#[path = "../unix/ext/mod.rs"] -pub mod ext; -#[path = "../unix/fd.rs"] -pub mod fd; -#[path = "../unix/fs.rs"] -pub mod fs; -#[path = "../unix/io.rs"] -pub mod io; -#[path = "../unix/memchr.rs"] -pub mod memchr; -#[path = "../unix/mutex.rs"] -pub mod mutex; -#[path = "../unix/net.rs"] -pub mod net; -#[path = "../unix/os.rs"] -pub mod os; -#[path = "../unix/path.rs"] -pub mod path; -#[path = "../unix/pipe.rs"] -pub mod pipe; -pub mod process; -pub mod rand; -#[path = "../unix/rwlock.rs"] -pub mod rwlock; -#[path = "../unix/stack_overflow.rs"] -pub mod stack_overflow; -#[path = "../unix/stdio.rs"] -pub mod stdio; -#[path = "../unix/thread.rs"] -pub mod thread; -pub mod thread_local_dtor; -#[path = "../unix/thread_local_key.rs"] -pub mod thread_local_key; -#[path = "../unix/time.rs"] -pub mod time; - -pub use crate::sys_common::os_str_bytes as os_str; - -#[cfg(not(test))] -pub fn init() { - // ignore SIGPIPE - unsafe { - assert!(signal(libc::SIGPIPE, libc::SIG_IGN) != libc::SIG_ERR); - } -} - -pub use libc::signal; - -pub fn decode_error_kind(errno: i32) -> ErrorKind { - match errno as libc::c_int { - libc::ECONNREFUSED => ErrorKind::ConnectionRefused, - libc::ECONNRESET => ErrorKind::ConnectionReset, - libc::EPERM | libc::EACCES => ErrorKind::PermissionDenied, - libc::EPIPE => ErrorKind::BrokenPipe, - libc::ENOTCONN => ErrorKind::NotConnected, - libc::ECONNABORTED => ErrorKind::ConnectionAborted, - libc::EADDRNOTAVAIL => ErrorKind::AddrNotAvailable, - libc::EADDRINUSE => ErrorKind::AddrInUse, - libc::ENOENT => ErrorKind::NotFound, - libc::EINTR => ErrorKind::Interrupted, - 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 - // clause - x if x == libc::EAGAIN || x == libc::EWOULDBLOCK => ErrorKind::WouldBlock, - - _ => ErrorKind::Other, - } -} - -#[doc(hidden)] -pub trait IsMinusOne { - fn is_minus_one(&self) -> bool; -} - -macro_rules! impl_is_minus_one { - ($($t:ident)*) => ($(impl IsMinusOne for $t { - fn is_minus_one(&self) -> bool { - *self == -1 - } - })*) -} - -impl_is_minus_one! { i8 i16 i32 i64 isize } - -pub fn cvt(t: T) -> crate::io::Result { - if t.is_minus_one() { Err(crate::io::Error::last_os_error()) } else { Ok(t) } -} - -pub fn cvt_r(mut f: F) -> crate::io::Result -where - T: IsMinusOne, - F: FnMut() -> T, -{ - loop { - match cvt(f()) { - Err(ref e) if e.kind() == ErrorKind::Interrupted => {} - other => return other, - } - } -} - -// On Unix-like platforms, libc::abort will unregister signal handlers -// including the SIGABRT handler, preventing the abort from being blocked, and -// fclose streams, with the side effect of flushing them so libc buffered -// output will be printed. Additionally the shell will generally print a more -// understandable error message like "Abort trap" rather than "Illegal -// instruction" that intrinsics::abort would cause, as intrinsics::abort is -// implemented as an illegal instruction. -pub fn abort_internal() -> ! { - unsafe { libc::abort() } -} diff --git a/library/std/src/sys/vxworks/process/mod.rs b/library/std/src/sys/vxworks/process/mod.rs deleted file mode 100644 index dc6130eaa24a8..0000000000000 --- a/library/std/src/sys/vxworks/process/mod.rs +++ /dev/null @@ -1,9 +0,0 @@ -pub use self::process_common::{Command, CommandArgs, ExitCode, Stdio, StdioPipes}; -pub use self::process_inner::{ExitStatus, Process}; -pub use crate::ffi::OsString as EnvKey; -pub use crate::sys_common::process::CommandEnvs; - -#[path = "../../unix/process/process_common.rs"] -mod process_common; -#[path = "process_vxworks.rs"] -mod process_inner; diff --git a/library/std/src/sys/vxworks/rand.rs b/library/std/src/sys/vxworks/rand.rs deleted file mode 100644 index 3a1ff5fd3b9c6..0000000000000 --- a/library/std/src/sys/vxworks/rand.rs +++ /dev/null @@ -1,36 +0,0 @@ -use crate::mem; -use crate::slice; - -pub fn hashmap_random_keys() -> (u64, u64) { - let mut v = (0, 0); - unsafe { - let view = slice::from_raw_parts_mut(&mut v as *mut _ as *mut u8, mem::size_of_val(&v)); - imp::fill_bytes(view); - } - return v; -} - -mod imp { - use crate::io; - use core::sync::atomic::{AtomicBool, Ordering::Relaxed}; - - pub fn fill_bytes(v: &mut [u8]) { - static RNG_INIT: AtomicBool = AtomicBool::new(false); - while !RNG_INIT.load(Relaxed) { - let ret = unsafe { libc::randSecure() }; - if ret < 0 { - panic!("couldn't generate random bytes: {}", io::Error::last_os_error()); - } else if ret > 0 { - RNG_INIT.store(true, Relaxed); - break; - } - unsafe { libc::usleep(10) }; - } - let ret = unsafe { - libc::randABytes(v.as_mut_ptr() as *mut libc::c_uchar, v.len() as libc::c_int) - }; - if ret < 0 { - panic!("couldn't generate random bytes: {}", io::Error::last_os_error()); - } - } -} diff --git a/library/std/src/sys/vxworks/thread_local_dtor.rs b/library/std/src/sys/vxworks/thread_local_dtor.rs deleted file mode 100644 index 5391ed83ebc36..0000000000000 --- a/library/std/src/sys/vxworks/thread_local_dtor.rs +++ /dev/null @@ -1,7 +0,0 @@ -#![cfg(target_thread_local)] -#![unstable(feature = "thread_local_internals", issue = "none")] - -pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern "C" fn(*mut u8)) { - use crate::sys_common::thread_local_dtor::register_dtor_fallback; - register_dtor_fallback(t, dtor); -} From 9bd9cbb28e6fafdc5835fe0c5d496bbaea8504e8 Mon Sep 17 00:00:00 2001 From: Christiaan Dirkx Date: Wed, 14 Apr 2021 20:35:20 +0200 Subject: [PATCH 05/28] Fix `vxworks` compilation errors --- library/std/src/sys/unix/os.rs | 11 +++------- .../src/sys/unix/process/process_common.rs | 2 +- .../src/sys/unix/process/process_vxworks.rs | 20 ++++++++++++++++++- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/library/std/src/sys/unix/os.rs b/library/std/src/sys/unix/os.rs index 98e578c5255c7..bf649f6d76f81 100644 --- a/library/std/src/sys/unix/os.rs +++ b/library/std/src/sys/unix/os.rs @@ -85,11 +85,6 @@ pub fn errno() -> i32 { unsafe { libc::errnoGet() } } -#[cfg(target_os = "vxworks")] -pub fn set_errno(e: i32) { - unsafe { libc::errnoSet(e as c_int) }; -} - #[cfg(target_os = "dragonfly")] pub fn errno() -> i32 { extern "C" { @@ -642,7 +637,7 @@ pub fn getppid() -> u32 { unsafe { libc::getppid() as u32 } } -#[cfg(target_env = "gnu")] +#[cfg(all(target_env = "gnu", not(target_os = "vxworks")))] pub fn glibc_version() -> Option<(usize, usize)> { if let Some(Ok(version_str)) = glibc_version_cstr().map(CStr::to_str) { parse_glibc_version(version_str) @@ -651,7 +646,7 @@ pub fn glibc_version() -> Option<(usize, usize)> { } } -#[cfg(target_env = "gnu")] +#[cfg(all(target_env = "gnu", not(target_os = "vxworks")))] fn glibc_version_cstr() -> Option<&'static CStr> { weak! { fn gnu_get_libc_version() -> *const libc::c_char @@ -665,7 +660,7 @@ fn glibc_version_cstr() -> Option<&'static CStr> { // Returns Some((major, minor)) if the string is a valid "x.y" version, // ignoring any extra dot-separated parts. Otherwise return None. -#[cfg(target_env = "gnu")] +#[cfg(all(target_env = "gnu", not(target_os = "vxworks")))] fn parse_glibc_version(version: &str) -> Option<(usize, usize)> { let mut parsed_ints = version.split('.').map(str::parse::).fuse(); match (parsed_ints.next(), parsed_ints.next()) { diff --git a/library/std/src/sys/unix/process/process_common.rs b/library/std/src/sys/unix/process/process_common.rs index b9dcc4e4b9e38..1ef6df0fe95c6 100644 --- a/library/std/src/sys/unix/process/process_common.rs +++ b/library/std/src/sys/unix/process/process_common.rs @@ -223,7 +223,7 @@ impl Command { pub fn get_groups(&self) -> Option<&[gid_t]> { self.groups.as_deref() } - + #[allow(dead_code)] pub fn get_closures(&mut self) -> &mut Vec io::Result<()> + Send + Sync>> { &mut self.closures } diff --git a/library/std/src/sys/unix/process/process_vxworks.rs b/library/std/src/sys/unix/process/process_vxworks.rs index 68605c2dfeebd..68467da284f23 100644 --- a/library/std/src/sys/unix/process/process_vxworks.rs +++ b/library/std/src/sys/unix/process/process_vxworks.rs @@ -18,7 +18,7 @@ impl Command { needs_stdin: bool, ) -> io::Result<(Process, StdioPipes)> { use crate::sys::cvt_r; - const CLOEXEC_MSG_FOOTER: &'static [u8] = b"NOEX"; + // const CLOEXEC_MSG_FOOTER: &'static [u8] = b"NOEX"; let envp = self.capture_env(); if self.saw_nul() { @@ -196,6 +196,24 @@ impl ExitStatus { pub fn signal(&self) -> Option { if !self.exited() { Some(libc::WTERMSIG(self.0)) } else { None } } + + pub fn core_dumped(&self) -> bool { + // This method is not yet properly implemented on VxWorks + false + } + + pub fn stopped_signal(&self) -> Option { + if libc::WIFSTOPPED(self.0) { Some(libc::WSTOPSIG(self.0)) } else { None } + } + + pub fn continued(&self) -> bool { + // This method is not yet properly implemented on VxWorks + false + } + + pub fn into_raw(&self) -> c_int { + self.0 + } } /// Converts a raw `c_int` to a type-safe `ExitStatus` by wrapping it without copying. From 8cc918a3dca757c6ea649f7d5d2aed963668bb38 Mon Sep 17 00:00:00 2001 From: Edd Barrett Date: Tue, 20 Apr 2021 10:19:25 +0100 Subject: [PATCH 06/28] Improve the docstrings of the `Lto` struct. --- compiler/rustc_session/src/config.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index b6b349e4a803d..b683626bbd64d 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -75,19 +75,21 @@ impl_stable_hash_via_hash!(OptLevel); /// This is what the `LtoCli` values get mapped to after resolving defaults and /// and taking other command line options into account. +/// +/// Note that linker plugin-based LTO is a different mechanism entirely. #[derive(Clone, PartialEq)] pub enum Lto { - /// Don't do any LTO whatsoever + /// Don't do any LTO whatsoever. No, - /// Do a full crate graph LTO with ThinLTO + /// Do a full-crate-graph (inter-crate) LTO with ThinLTO. Thin, - /// Do a local graph LTO with ThinLTO (only relevant for multiple codegen - /// units). + /// Do a local ThinLTO (intra-crate, over the CodeGen Units of the local crate only). This is + /// only relevant if multiple CGUs are used. ThinLocal, - /// Do a full crate graph LTO with "fat" LTO + /// Do a full-crate-graph (inter-crate) LTO with "fat" LTO. Fat, } From 389fef3b304bd4f196a337797591d9f8db998a62 Mon Sep 17 00:00:00 2001 From: Christiaan Dirkx Date: Wed, 14 Apr 2021 02:37:36 +0200 Subject: [PATCH 07/28] Replace `Void` with never type --- library/std/src/sys/hermit/fs.rs | 12 ++++++------ library/std/src/sys/hermit/mod.rs | 5 ----- library/std/src/sys/hermit/net.rs | 4 ++-- library/std/src/sys/hermit/os.rs | 4 ++-- library/std/src/sys/sgx/mod.rs | 5 ----- library/std/src/sys/sgx/net.rs | 6 +++--- library/std/src/sys/sgx/os.rs | 4 ++-- library/std/src/sys/unsupported/common.rs | 5 ----- library/std/src/sys/unsupported/fs.rs | 14 +++++++------- library/std/src/sys/unsupported/net.rs | 10 +++++----- library/std/src/sys/unsupported/os.rs | 6 +++--- library/std/src/sys/unsupported/pipe.rs | 3 +-- library/std/src/sys/unsupported/process.rs | 6 +++--- library/std/src/sys/unsupported/thread.rs | 4 ++-- library/std/src/sys/wasi/net.rs | 4 ++-- library/std/src/sys/wasi/os.rs | 4 ++-- library/std/src/sys/wasi/thread.rs | 4 ++-- library/std/src/sys/wasm/thread.rs | 4 ++-- 18 files changed, 44 insertions(+), 60 deletions(-) diff --git a/library/std/src/sys/hermit/fs.rs b/library/std/src/sys/hermit/fs.rs index 0f33282fa8370..fb6b4a8b54eab 100644 --- a/library/std/src/sys/hermit/fs.rs +++ b/library/std/src/sys/hermit/fs.rs @@ -9,7 +9,7 @@ use crate::sys::hermit::abi; use crate::sys::hermit::abi::{O_APPEND, O_CREAT, O_EXCL, O_RDONLY, O_RDWR, O_TRUNC, O_WRONLY}; use crate::sys::hermit::fd::FileDesc; use crate::sys::time::SystemTime; -use crate::sys::{unsupported, Void}; +use crate::sys::unsupported; use crate::sys_common::os_str_bytes::OsStrExt; pub use crate::sys_common::fs::copy; @@ -22,11 +22,11 @@ fn cstr(path: &Path) -> io::Result { #[derive(Debug)] pub struct File(FileDesc); -pub struct FileAttr(Void); +pub struct FileAttr(!); -pub struct ReadDir(Void); +pub struct ReadDir(!); -pub struct DirEntry(Void); +pub struct DirEntry(!); #[derive(Clone, Debug)] pub struct OpenOptions { @@ -41,9 +41,9 @@ pub struct OpenOptions { mode: i32, } -pub struct FilePermissions(Void); +pub struct FilePermissions(!); -pub struct FileType(Void); +pub struct FileType(!); #[derive(Debug)] pub struct DirBuilder {} diff --git a/library/std/src/sys/hermit/mod.rs b/library/std/src/sys/hermit/mod.rs index f8c1612d1ca03..56497162c0333 100644 --- a/library/std/src/sys/hermit/mod.rs +++ b/library/std/src/sys/hermit/mod.rs @@ -61,11 +61,6 @@ pub fn unsupported_err() -> crate::io::Error { ) } -// This enum is used as the storage for a bunch of types which can't actually -// exist. -#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)] -pub enum Void {} - pub unsafe fn strlen(start: *const c_char) -> usize { let mut str = start; diff --git a/library/std/src/sys/hermit/net.rs b/library/std/src/sys/hermit/net.rs index a9c09b6ceefae..bdb7b81fdc049 100644 --- a/library/std/src/sys/hermit/net.rs +++ b/library/std/src/sys/hermit/net.rs @@ -6,7 +6,7 @@ use crate::str; use crate::sync::Arc; use crate::sys::hermit::abi; use crate::sys::hermit::abi::IpAddress::{Ipv4, Ipv6}; -use crate::sys::{unsupported, Void}; +use crate::sys::unsupported; use crate::sys_common::AsInner; use crate::time::Duration; @@ -411,7 +411,7 @@ impl fmt::Debug for UdpSocket { } } -pub struct LookupHost(Void); +pub struct LookupHost(!); impl LookupHost { pub fn port(&self) -> u16 { diff --git a/library/std/src/sys/hermit/os.rs b/library/std/src/sys/hermit/os.rs index 78eabf8f81e98..ab5e0ea0bc4ff 100644 --- a/library/std/src/sys/hermit/os.rs +++ b/library/std/src/sys/hermit/os.rs @@ -9,7 +9,7 @@ use crate::path::{self, PathBuf}; use crate::str; use crate::sync::Mutex; use crate::sys::hermit::abi; -use crate::sys::{unsupported, Void}; +use crate::sys::unsupported; use crate::sys_common::os_str_bytes::*; use crate::vec; @@ -29,7 +29,7 @@ pub fn chdir(_: &path::Path) -> io::Result<()> { unsupported() } -pub struct SplitPaths<'a>(&'a Void); +pub struct SplitPaths<'a>(&'a !); pub fn split_paths(_unparsed: &OsStr) -> SplitPaths<'_> { panic!("unsupported") diff --git a/library/std/src/sys/sgx/mod.rs b/library/std/src/sys/sgx/mod.rs index da37d1aeb7e74..d6a5683073309 100644 --- a/library/std/src/sys/sgx/mod.rs +++ b/library/std/src/sys/sgx/mod.rs @@ -115,11 +115,6 @@ pub fn decode_error_kind(code: i32) -> ErrorKind { } } -// This enum is used as the storage for a bunch of types which can't actually -// exist. -#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)] -pub enum Void {} - pub unsafe fn strlen(mut s: *const c_char) -> usize { let mut n = 0; while unsafe { *s } != 0 { diff --git a/library/std/src/sys/sgx/net.rs b/library/std/src/sys/sgx/net.rs index c0c5d55548c5f..9ddd17303db57 100644 --- a/library/std/src/sys/sgx/net.rs +++ b/library/std/src/sys/sgx/net.rs @@ -5,7 +5,7 @@ use crate::io::{self, IoSlice, IoSliceMut}; use crate::net::{Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr, ToSocketAddrs}; use crate::sync::Arc; use crate::sys::fd::FileDesc; -use crate::sys::{sgx_ineffective, unsupported, AsInner, FromInner, IntoInner, TryIntoInner, Void}; +use crate::sys::{sgx_ineffective, unsupported, AsInner, FromInner, IntoInner, TryIntoInner}; use crate::time::Duration; use super::abi::usercalls; @@ -310,7 +310,7 @@ impl FromInner for TcpListener { } } -pub struct UdpSocket(Void); +pub struct UdpSocket(!); impl UdpSocket { pub fn bind(_: io::Result<&SocketAddr>) -> io::Result { @@ -462,7 +462,7 @@ impl fmt::Display for NonIpSockAddr { } } -pub struct LookupHost(Void); +pub struct LookupHost(!); impl LookupHost { fn new(host: String) -> io::Result { diff --git a/library/std/src/sys/sgx/os.rs b/library/std/src/sys/sgx/os.rs index 56fc84b4a3fca..ff1f9c368a31e 100644 --- a/library/std/src/sys/sgx/os.rs +++ b/library/std/src/sys/sgx/os.rs @@ -10,7 +10,7 @@ use crate::str; use crate::sync::atomic::{AtomicUsize, Ordering}; use crate::sync::Mutex; use crate::sync::Once; -use crate::sys::{decode_error_kind, sgx_ineffective, unsupported, Void}; +use crate::sys::{decode_error_kind, sgx_ineffective, unsupported}; use crate::vec; pub fn errno() -> i32 { @@ -35,7 +35,7 @@ pub fn chdir(_: &path::Path) -> io::Result<()> { sgx_ineffective(()) } -pub struct SplitPaths<'a>(&'a Void); +pub struct SplitPaths<'a>(&'a !); pub fn split_paths(_unparsed: &OsStr) -> SplitPaths<'_> { panic!("unsupported") diff --git a/library/std/src/sys/unsupported/common.rs b/library/std/src/sys/unsupported/common.rs index 64ec50fa9ec00..0ef84c84ee877 100644 --- a/library/std/src/sys/unsupported/common.rs +++ b/library/std/src/sys/unsupported/common.rs @@ -36,11 +36,6 @@ pub fn hashmap_random_keys() -> (u64, u64) { (1, 2) } -// This enum is used as the storage for a bunch of types which can't actually -// exist. -#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)] -pub enum Void {} - pub unsafe fn strlen(mut s: *const c_char) -> usize { // SAFETY: The caller must guarantee `s` points to a valid 0-terminated string. unsafe { diff --git a/library/std/src/sys/unsupported/fs.rs b/library/std/src/sys/unsupported/fs.rs index 4271d9b334588..f5a0c89fe107b 100644 --- a/library/std/src/sys/unsupported/fs.rs +++ b/library/std/src/sys/unsupported/fs.rs @@ -4,22 +4,22 @@ use crate::hash::{Hash, Hasher}; use crate::io::{self, IoSlice, IoSliceMut, SeekFrom}; use crate::path::{Path, PathBuf}; use crate::sys::time::SystemTime; -use crate::sys::{unsupported, Void}; +use crate::sys::unsupported; -pub struct File(Void); +pub struct File(!); -pub struct FileAttr(Void); +pub struct FileAttr(!); -pub struct ReadDir(Void); +pub struct ReadDir(!); -pub struct DirEntry(Void); +pub struct DirEntry(!); #[derive(Clone, Debug)] pub struct OpenOptions {} -pub struct FilePermissions(Void); +pub struct FilePermissions(!); -pub struct FileType(Void); +pub struct FileType(!); #[derive(Debug)] pub struct DirBuilder {} diff --git a/library/std/src/sys/unsupported/net.rs b/library/std/src/sys/unsupported/net.rs index 5c9f1098f9b7f..204a24cfc71cd 100644 --- a/library/std/src/sys/unsupported/net.rs +++ b/library/std/src/sys/unsupported/net.rs @@ -2,10 +2,10 @@ use crate::convert::TryFrom; use crate::fmt; use crate::io::{self, IoSlice, IoSliceMut}; use crate::net::{Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr}; -use crate::sys::{unsupported, Void}; +use crate::sys::unsupported; use crate::time::Duration; -pub struct TcpStream(Void); +pub struct TcpStream(!); impl TcpStream { pub fn connect(_: io::Result<&SocketAddr>) -> io::Result { @@ -107,7 +107,7 @@ impl fmt::Debug for TcpStream { } } -pub struct TcpListener(Void); +pub struct TcpListener(!); impl TcpListener { pub fn bind(_: io::Result<&SocketAddr>) -> io::Result { @@ -157,7 +157,7 @@ impl fmt::Debug for TcpListener { } } -pub struct UdpSocket(Void); +pub struct UdpSocket(!); impl UdpSocket { pub fn bind(_: io::Result<&SocketAddr>) -> io::Result { @@ -291,7 +291,7 @@ impl fmt::Debug for UdpSocket { } } -pub struct LookupHost(Void); +pub struct LookupHost(!); impl LookupHost { pub fn port(&self) -> u16 { diff --git a/library/std/src/sys/unsupported/os.rs b/library/std/src/sys/unsupported/os.rs index 3754aebf45581..11583ae99d6d0 100644 --- a/library/std/src/sys/unsupported/os.rs +++ b/library/std/src/sys/unsupported/os.rs @@ -1,4 +1,4 @@ -use super::{unsupported, Void}; +use super::unsupported; use crate::error::Error as StdError; use crate::ffi::{OsStr, OsString}; use crate::fmt; @@ -21,7 +21,7 @@ pub fn chdir(_: &path::Path) -> io::Result<()> { unsupported() } -pub struct SplitPaths<'a>(&'a Void); +pub struct SplitPaths<'a>(&'a !); pub fn split_paths(_unparsed: &OsStr) -> SplitPaths<'_> { panic!("unsupported") @@ -62,7 +62,7 @@ pub fn current_exe() -> io::Result { unsupported() } -pub struct Env(Void); +pub struct Env(!); impl Iterator for Env { type Item = (OsString, OsString); diff --git a/library/std/src/sys/unsupported/pipe.rs b/library/std/src/sys/unsupported/pipe.rs index 10d0925823eb9..7ea46990d77c8 100644 --- a/library/std/src/sys/unsupported/pipe.rs +++ b/library/std/src/sys/unsupported/pipe.rs @@ -1,7 +1,6 @@ use crate::io::{self, IoSlice, IoSliceMut}; -use crate::sys::Void; -pub struct AnonPipe(Void); +pub struct AnonPipe(!); impl AnonPipe { pub fn read(&self, _buf: &mut [u8]) -> io::Result { diff --git a/library/std/src/sys/unsupported/process.rs b/library/std/src/sys/unsupported/process.rs index 3ede2291d5a91..f777e40873fb4 100644 --- a/library/std/src/sys/unsupported/process.rs +++ b/library/std/src/sys/unsupported/process.rs @@ -5,7 +5,7 @@ use crate::marker::PhantomData; use crate::path::Path; use crate::sys::fs::File; use crate::sys::pipe::AnonPipe; -use crate::sys::{unsupported, Void}; +use crate::sys::unsupported; use crate::sys_common::process::{CommandEnv, CommandEnvs}; pub use crate::ffi::OsString as EnvKey; @@ -94,7 +94,7 @@ impl fmt::Debug for Command { } } -pub struct ExitStatus(Void); +pub struct ExitStatus(!); impl ExitStatus { pub fn success(&self) -> bool { @@ -146,7 +146,7 @@ impl ExitCode { } } -pub struct Process(Void); +pub struct Process(!); impl Process { pub fn id(&self) -> u32 { diff --git a/library/std/src/sys/unsupported/thread.rs b/library/std/src/sys/unsupported/thread.rs index 20ae309db30d7..7d5d2c6115757 100644 --- a/library/std/src/sys/unsupported/thread.rs +++ b/library/std/src/sys/unsupported/thread.rs @@ -1,9 +1,9 @@ -use super::{unsupported, Void}; +use super::unsupported; use crate::ffi::CStr; use crate::io; use crate::time::Duration; -pub struct Thread(Void); +pub struct Thread(!); pub const DEFAULT_MIN_STACK_SIZE: usize = 4096; diff --git a/library/std/src/sys/wasi/net.rs b/library/std/src/sys/wasi/net.rs index 3f294e7df418e..30c21a05a3274 100644 --- a/library/std/src/sys/wasi/net.rs +++ b/library/std/src/sys/wasi/net.rs @@ -5,7 +5,7 @@ use crate::convert::TryFrom; use crate::fmt; use crate::io::{self, IoSlice, IoSliceMut}; use crate::net::{Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr}; -use crate::sys::{unsupported, Void}; +use crate::sys::unsupported; use crate::sys_common::FromInner; use crate::time::Duration; @@ -343,7 +343,7 @@ impl fmt::Debug for UdpSocket { } } -pub struct LookupHost(Void); +pub struct LookupHost(!); impl LookupHost { pub fn port(&self) -> u16 { diff --git a/library/std/src/sys/wasi/os.rs b/library/std/src/sys/wasi/os.rs index 185d6109cb93e..a349c149249f4 100644 --- a/library/std/src/sys/wasi/os.rs +++ b/library/std/src/sys/wasi/os.rs @@ -10,7 +10,7 @@ use crate::os::wasi::prelude::*; use crate::path::{self, PathBuf}; use crate::str; use crate::sys::memchr; -use crate::sys::{unsupported, Void}; +use crate::sys::unsupported; use crate::vec; // Add a few symbols not in upstream `libc` just yet. @@ -87,7 +87,7 @@ pub fn chdir(p: &path::Path) -> io::Result<()> { } } -pub struct SplitPaths<'a>(&'a Void); +pub struct SplitPaths<'a>(&'a !); pub fn split_paths(_unparsed: &OsStr) -> SplitPaths<'_> { panic!("unsupported") diff --git a/library/std/src/sys/wasi/thread.rs b/library/std/src/sys/wasi/thread.rs index 8eaa5f09cb656..2efa91f8b7011 100644 --- a/library/std/src/sys/wasi/thread.rs +++ b/library/std/src/sys/wasi/thread.rs @@ -3,10 +3,10 @@ use crate::ffi::CStr; use crate::io; use crate::mem; -use crate::sys::{unsupported, Void}; +use crate::sys::unsupported; use crate::time::Duration; -pub struct Thread(Void); +pub struct Thread(!); pub const DEFAULT_MIN_STACK_SIZE: usize = 4096; diff --git a/library/std/src/sys/wasm/thread.rs b/library/std/src/sys/wasm/thread.rs index 5eafb77da1dcd..77f8c79ced929 100644 --- a/library/std/src/sys/wasm/thread.rs +++ b/library/std/src/sys/wasm/thread.rs @@ -1,9 +1,9 @@ use crate::ffi::CStr; use crate::io; -use crate::sys::{unsupported, Void}; +use crate::sys::unsupported; use crate::time::Duration; -pub struct Thread(Void); +pub struct Thread(!); pub const DEFAULT_MIN_STACK_SIZE: usize = 4096; From d45e1314f36ac249e8fb7d9564362ac8f94e49be Mon Sep 17 00:00:00 2001 From: Christiaan Dirkx Date: Wed, 14 Apr 2021 03:19:01 +0200 Subject: [PATCH 08/28] Change uses of never type --- library/std/src/sys/hermit/fs.rs | 50 ++++---- library/std/src/sys/hermit/net.rs | 4 +- library/std/src/sys/hermit/os.rs | 4 +- library/std/src/sys/sgx/net.rs | 66 +++++------ library/std/src/sys/sgx/os.rs | 5 +- library/std/src/sys/unsupported/fs.rs | 80 ++++++------- library/std/src/sys/unsupported/net.rs | 130 ++++++++++----------- library/std/src/sys/unsupported/os.rs | 7 +- library/std/src/sys/unsupported/pipe.rs | 14 +-- library/std/src/sys/unsupported/process.rs | 20 ++-- library/std/src/sys/unsupported/thread.rs | 2 +- library/std/src/sys/wasi/net.rs | 4 +- library/std/src/sys/wasi/os.rs | 4 +- library/std/src/sys/wasi/thread.rs | 2 +- library/std/src/sys/wasm/thread.rs | 2 +- 15 files changed, 198 insertions(+), 196 deletions(-) diff --git a/library/std/src/sys/hermit/fs.rs b/library/std/src/sys/hermit/fs.rs index fb6b4a8b54eab..5b3f2fa4e8275 100644 --- a/library/std/src/sys/hermit/fs.rs +++ b/library/std/src/sys/hermit/fs.rs @@ -50,55 +50,55 @@ pub struct DirBuilder {} impl FileAttr { pub fn size(&self) -> u64 { - match self.0 {} + self.0 } pub fn perm(&self) -> FilePermissions { - match self.0 {} + self.0 } pub fn file_type(&self) -> FileType { - match self.0 {} + self.0 } pub fn modified(&self) -> io::Result { - match self.0 {} + self.0 } pub fn accessed(&self) -> io::Result { - match self.0 {} + self.0 } pub fn created(&self) -> io::Result { - match self.0 {} + self.0 } } impl Clone for FileAttr { fn clone(&self) -> FileAttr { - match self.0 {} + self.0 } } impl FilePermissions { pub fn readonly(&self) -> bool { - match self.0 {} + self.0 } pub fn set_readonly(&mut self, _readonly: bool) { - match self.0 {} + self.0 } } impl Clone for FilePermissions { fn clone(&self) -> FilePermissions { - match self.0 {} + self.0 } } impl PartialEq for FilePermissions { fn eq(&self, _other: &FilePermissions) -> bool { - match self.0 {} + self.0 } } @@ -106,27 +106,27 @@ impl Eq for FilePermissions {} impl fmt::Debug for FilePermissions { fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self.0 {} + self.0 } } impl FileType { pub fn is_dir(&self) -> bool { - match self.0 {} + self.0 } pub fn is_file(&self) -> bool { - match self.0 {} + self.0 } pub fn is_symlink(&self) -> bool { - match self.0 {} + self.0 } } impl Clone for FileType { fn clone(&self) -> FileType { - match self.0 {} + self.0 } } @@ -134,7 +134,7 @@ impl Copy for FileType {} impl PartialEq for FileType { fn eq(&self, _other: &FileType) -> bool { - match self.0 {} + self.0 } } @@ -142,19 +142,19 @@ impl Eq for FileType {} impl Hash for FileType { fn hash(&self, _h: &mut H) { - match self.0 {} + self.0 } } impl fmt::Debug for FileType { fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self.0 {} + self.0 } } impl fmt::Debug for ReadDir { fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self.0 {} + self.0 } } @@ -162,25 +162,25 @@ impl Iterator for ReadDir { type Item = io::Result; fn next(&mut self) -> Option> { - match self.0 {} + self.0 } } impl DirEntry { pub fn path(&self) -> PathBuf { - match self.0 {} + self.0 } pub fn file_name(&self) -> OsString { - match self.0 {} + self.0 } pub fn metadata(&self) -> io::Result { - match self.0 {} + self.0 } pub fn file_type(&self) -> io::Result { - match self.0 {} + self.0 } } diff --git a/library/std/src/sys/hermit/net.rs b/library/std/src/sys/hermit/net.rs index bdb7b81fdc049..5f8839157eafc 100644 --- a/library/std/src/sys/hermit/net.rs +++ b/library/std/src/sys/hermit/net.rs @@ -415,14 +415,14 @@ pub struct LookupHost(!); impl LookupHost { pub fn port(&self) -> u16 { - match self.0 {} + self.0 } } impl Iterator for LookupHost { type Item = SocketAddr; fn next(&mut self) -> Option { - match self.0 {} + self.0 } } diff --git a/library/std/src/sys/hermit/os.rs b/library/std/src/sys/hermit/os.rs index ab5e0ea0bc4ff..4487e9d636cb0 100644 --- a/library/std/src/sys/hermit/os.rs +++ b/library/std/src/sys/hermit/os.rs @@ -29,7 +29,7 @@ pub fn chdir(_: &path::Path) -> io::Result<()> { unsupported() } -pub struct SplitPaths<'a>(&'a !); +pub struct SplitPaths<'a>(!, PhantomData<&'a ()>); pub fn split_paths(_unparsed: &OsStr) -> SplitPaths<'_> { panic!("unsupported") @@ -38,7 +38,7 @@ pub fn split_paths(_unparsed: &OsStr) -> SplitPaths<'_> { impl<'a> Iterator for SplitPaths<'a> { type Item = PathBuf; fn next(&mut self) -> Option { - match *self.0 {} + self.0 } } diff --git a/library/std/src/sys/sgx/net.rs b/library/std/src/sys/sgx/net.rs index 9ddd17303db57..5ccedece0f84b 100644 --- a/library/std/src/sys/sgx/net.rs +++ b/library/std/src/sys/sgx/net.rs @@ -318,129 +318,129 @@ impl UdpSocket { } pub fn peer_addr(&self) -> io::Result { - match self.0 {} + self.0 } pub fn socket_addr(&self) -> io::Result { - match self.0 {} + self.0 } pub fn recv_from(&self, _: &mut [u8]) -> io::Result<(usize, SocketAddr)> { - match self.0 {} + self.0 } pub fn peek_from(&self, _: &mut [u8]) -> io::Result<(usize, SocketAddr)> { - match self.0 {} + self.0 } pub fn send_to(&self, _: &[u8], _: &SocketAddr) -> io::Result { - match self.0 {} + self.0 } pub fn duplicate(&self) -> io::Result { - match self.0 {} + self.0 } pub fn set_read_timeout(&self, _: Option) -> io::Result<()> { - match self.0 {} + self.0 } pub fn set_write_timeout(&self, _: Option) -> io::Result<()> { - match self.0 {} + self.0 } pub fn read_timeout(&self) -> io::Result> { - match self.0 {} + self.0 } pub fn write_timeout(&self) -> io::Result> { - match self.0 {} + self.0 } pub fn set_broadcast(&self, _: bool) -> io::Result<()> { - match self.0 {} + self.0 } pub fn broadcast(&self) -> io::Result { - match self.0 {} + self.0 } pub fn set_multicast_loop_v4(&self, _: bool) -> io::Result<()> { - match self.0 {} + self.0 } pub fn multicast_loop_v4(&self) -> io::Result { - match self.0 {} + self.0 } pub fn set_multicast_ttl_v4(&self, _: u32) -> io::Result<()> { - match self.0 {} + self.0 } pub fn multicast_ttl_v4(&self) -> io::Result { - match self.0 {} + self.0 } pub fn set_multicast_loop_v6(&self, _: bool) -> io::Result<()> { - match self.0 {} + self.0 } pub fn multicast_loop_v6(&self) -> io::Result { - match self.0 {} + self.0 } pub fn join_multicast_v4(&self, _: &Ipv4Addr, _: &Ipv4Addr) -> io::Result<()> { - match self.0 {} + self.0 } pub fn join_multicast_v6(&self, _: &Ipv6Addr, _: u32) -> io::Result<()> { - match self.0 {} + self.0 } pub fn leave_multicast_v4(&self, _: &Ipv4Addr, _: &Ipv4Addr) -> io::Result<()> { - match self.0 {} + self.0 } pub fn leave_multicast_v6(&self, _: &Ipv6Addr, _: u32) -> io::Result<()> { - match self.0 {} + self.0 } pub fn set_ttl(&self, _: u32) -> io::Result<()> { - match self.0 {} + self.0 } pub fn ttl(&self) -> io::Result { - match self.0 {} + self.0 } pub fn take_error(&self) -> io::Result> { - match self.0 {} + self.0 } pub fn set_nonblocking(&self, _: bool) -> io::Result<()> { - match self.0 {} + self.0 } pub fn recv(&self, _: &mut [u8]) -> io::Result { - match self.0 {} + self.0 } pub fn peek(&self, _: &mut [u8]) -> io::Result { - match self.0 {} + self.0 } pub fn send(&self, _: &[u8]) -> io::Result { - match self.0 {} + self.0 } pub fn connect(&self, _: io::Result<&SocketAddr>) -> io::Result<()> { - match self.0 {} + self.0 } } impl fmt::Debug for UdpSocket { fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self.0 {} + self.0 } } @@ -470,14 +470,14 @@ impl LookupHost { } pub fn port(&self) -> u16 { - match self.0 {} + self.0 } } impl Iterator for LookupHost { type Item = SocketAddr; fn next(&mut self) -> Option { - match self.0 {} + self.0 } } diff --git a/library/std/src/sys/sgx/os.rs b/library/std/src/sys/sgx/os.rs index ff1f9c368a31e..144248d60c9cf 100644 --- a/library/std/src/sys/sgx/os.rs +++ b/library/std/src/sys/sgx/os.rs @@ -5,6 +5,7 @@ use crate::error::Error as StdError; use crate::ffi::{OsStr, OsString}; use crate::fmt; use crate::io; +use crate::marker::PhantomData; use crate::path::{self, PathBuf}; use crate::str; use crate::sync::atomic::{AtomicUsize, Ordering}; @@ -35,7 +36,7 @@ pub fn chdir(_: &path::Path) -> io::Result<()> { sgx_ineffective(()) } -pub struct SplitPaths<'a>(&'a !); +pub struct SplitPaths<'a>(!, PhantomData<&'a ()>); pub fn split_paths(_unparsed: &OsStr) -> SplitPaths<'_> { panic!("unsupported") @@ -44,7 +45,7 @@ pub fn split_paths(_unparsed: &OsStr) -> SplitPaths<'_> { impl<'a> Iterator for SplitPaths<'a> { type Item = PathBuf; fn next(&mut self) -> Option { - match *self.0 {} + self.0 } } diff --git a/library/std/src/sys/unsupported/fs.rs b/library/std/src/sys/unsupported/fs.rs index f5a0c89fe107b..cd533761e3732 100644 --- a/library/std/src/sys/unsupported/fs.rs +++ b/library/std/src/sys/unsupported/fs.rs @@ -26,55 +26,55 @@ pub struct DirBuilder {} impl FileAttr { pub fn size(&self) -> u64 { - match self.0 {} + self.0 } pub fn perm(&self) -> FilePermissions { - match self.0 {} + self.0 } pub fn file_type(&self) -> FileType { - match self.0 {} + self.0 } pub fn modified(&self) -> io::Result { - match self.0 {} + self.0 } pub fn accessed(&self) -> io::Result { - match self.0 {} + self.0 } pub fn created(&self) -> io::Result { - match self.0 {} + self.0 } } impl Clone for FileAttr { fn clone(&self) -> FileAttr { - match self.0 {} + self.0 } } impl FilePermissions { pub fn readonly(&self) -> bool { - match self.0 {} + self.0 } pub fn set_readonly(&mut self, _readonly: bool) { - match self.0 {} + self.0 } } impl Clone for FilePermissions { fn clone(&self) -> FilePermissions { - match self.0 {} + self.0 } } impl PartialEq for FilePermissions { fn eq(&self, _other: &FilePermissions) -> bool { - match self.0 {} + self.0 } } @@ -82,27 +82,27 @@ impl Eq for FilePermissions {} impl fmt::Debug for FilePermissions { fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self.0 {} + self.0 } } impl FileType { pub fn is_dir(&self) -> bool { - match self.0 {} + self.0 } pub fn is_file(&self) -> bool { - match self.0 {} + self.0 } pub fn is_symlink(&self) -> bool { - match self.0 {} + self.0 } } impl Clone for FileType { fn clone(&self) -> FileType { - match self.0 {} + self.0 } } @@ -110,7 +110,7 @@ impl Copy for FileType {} impl PartialEq for FileType { fn eq(&self, _other: &FileType) -> bool { - match self.0 {} + self.0 } } @@ -118,19 +118,19 @@ impl Eq for FileType {} impl Hash for FileType { fn hash(&self, _h: &mut H) { - match self.0 {} + self.0 } } impl fmt::Debug for FileType { fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self.0 {} + self.0 } } impl fmt::Debug for ReadDir { fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self.0 {} + self.0 } } @@ -138,25 +138,25 @@ impl Iterator for ReadDir { type Item = io::Result; fn next(&mut self) -> Option> { - match self.0 {} + self.0 } } impl DirEntry { pub fn path(&self) -> PathBuf { - match self.0 {} + self.0 } pub fn file_name(&self) -> OsString { - match self.0 {} + self.0 } pub fn metadata(&self) -> io::Result { - match self.0 {} + self.0 } pub fn file_type(&self) -> io::Result { - match self.0 {} + self.0 } } @@ -179,59 +179,59 @@ impl File { } pub fn file_attr(&self) -> io::Result { - match self.0 {} + self.0 } pub fn fsync(&self) -> io::Result<()> { - match self.0 {} + self.0 } pub fn datasync(&self) -> io::Result<()> { - match self.0 {} + self.0 } pub fn truncate(&self, _size: u64) -> io::Result<()> { - match self.0 {} + self.0 } pub fn read(&self, _buf: &mut [u8]) -> io::Result { - match self.0 {} + self.0 } pub fn read_vectored(&self, _bufs: &mut [IoSliceMut<'_>]) -> io::Result { - match self.0 {} + self.0 } pub fn is_read_vectored(&self) -> bool { - match self.0 {} + self.0 } pub fn write(&self, _buf: &[u8]) -> io::Result { - match self.0 {} + self.0 } pub fn write_vectored(&self, _bufs: &[IoSlice<'_>]) -> io::Result { - match self.0 {} + self.0 } pub fn is_write_vectored(&self) -> bool { - match self.0 {} + self.0 } pub fn flush(&self) -> io::Result<()> { - match self.0 {} + self.0 } pub fn seek(&self, _pos: SeekFrom) -> io::Result { - match self.0 {} + self.0 } pub fn duplicate(&self) -> io::Result { - match self.0 {} + self.0 } pub fn set_permissions(&self, _perm: FilePermissions) -> io::Result<()> { - match self.0 {} + self.0 } } @@ -247,7 +247,7 @@ impl DirBuilder { impl fmt::Debug for File { fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self.0 {} + self.0 } } diff --git a/library/std/src/sys/unsupported/net.rs b/library/std/src/sys/unsupported/net.rs index 204a24cfc71cd..96203c74b576c 100644 --- a/library/std/src/sys/unsupported/net.rs +++ b/library/std/src/sys/unsupported/net.rs @@ -17,93 +17,93 @@ impl TcpStream { } pub fn set_read_timeout(&self, _: Option) -> io::Result<()> { - match self.0 {} + self.0 } pub fn set_write_timeout(&self, _: Option) -> io::Result<()> { - match self.0 {} + self.0 } pub fn read_timeout(&self) -> io::Result> { - match self.0 {} + self.0 } pub fn write_timeout(&self) -> io::Result> { - match self.0 {} + self.0 } pub fn peek(&self, _: &mut [u8]) -> io::Result { - match self.0 {} + self.0 } pub fn read(&self, _: &mut [u8]) -> io::Result { - match self.0 {} + self.0 } pub fn read_vectored(&self, _: &mut [IoSliceMut<'_>]) -> io::Result { - match self.0 {} + self.0 } pub fn is_read_vectored(&self) -> bool { - match self.0 {} + self.0 } pub fn write(&self, _: &[u8]) -> io::Result { - match self.0 {} + self.0 } pub fn write_vectored(&self, _: &[IoSlice<'_>]) -> io::Result { - match self.0 {} + self.0 } pub fn is_write_vectored(&self) -> bool { - match self.0 {} + self.0 } pub fn peer_addr(&self) -> io::Result { - match self.0 {} + self.0 } pub fn socket_addr(&self) -> io::Result { - match self.0 {} + self.0 } pub fn shutdown(&self, _: Shutdown) -> io::Result<()> { - match self.0 {} + self.0 } pub fn duplicate(&self) -> io::Result { - match self.0 {} + self.0 } pub fn set_nodelay(&self, _: bool) -> io::Result<()> { - match self.0 {} + self.0 } pub fn nodelay(&self) -> io::Result { - match self.0 {} + self.0 } pub fn set_ttl(&self, _: u32) -> io::Result<()> { - match self.0 {} + self.0 } pub fn ttl(&self) -> io::Result { - match self.0 {} + self.0 } pub fn take_error(&self) -> io::Result> { - match self.0 {} + self.0 } pub fn set_nonblocking(&self, _: bool) -> io::Result<()> { - match self.0 {} + self.0 } } impl fmt::Debug for TcpStream { fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self.0 {} + self.0 } } @@ -115,45 +115,45 @@ impl TcpListener { } pub fn socket_addr(&self) -> io::Result { - match self.0 {} + self.0 } pub fn accept(&self) -> io::Result<(TcpStream, SocketAddr)> { - match self.0 {} + self.0 } pub fn duplicate(&self) -> io::Result { - match self.0 {} + self.0 } pub fn set_ttl(&self, _: u32) -> io::Result<()> { - match self.0 {} + self.0 } pub fn ttl(&self) -> io::Result { - match self.0 {} + self.0 } pub fn set_only_v6(&self, _: bool) -> io::Result<()> { - match self.0 {} + self.0 } pub fn only_v6(&self) -> io::Result { - match self.0 {} + self.0 } pub fn take_error(&self) -> io::Result> { - match self.0 {} + self.0 } pub fn set_nonblocking(&self, _: bool) -> io::Result<()> { - match self.0 {} + self.0 } } impl fmt::Debug for TcpListener { fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self.0 {} + self.0 } } @@ -165,129 +165,129 @@ impl UdpSocket { } pub fn peer_addr(&self) -> io::Result { - match self.0 {} + self.0 } pub fn socket_addr(&self) -> io::Result { - match self.0 {} + self.0 } pub fn recv_from(&self, _: &mut [u8]) -> io::Result<(usize, SocketAddr)> { - match self.0 {} + self.0 } pub fn peek_from(&self, _: &mut [u8]) -> io::Result<(usize, SocketAddr)> { - match self.0 {} + self.0 } pub fn send_to(&self, _: &[u8], _: &SocketAddr) -> io::Result { - match self.0 {} + self.0 } pub fn duplicate(&self) -> io::Result { - match self.0 {} + self.0 } pub fn set_read_timeout(&self, _: Option) -> io::Result<()> { - match self.0 {} + self.0 } pub fn set_write_timeout(&self, _: Option) -> io::Result<()> { - match self.0 {} + self.0 } pub fn read_timeout(&self) -> io::Result> { - match self.0 {} + self.0 } pub fn write_timeout(&self) -> io::Result> { - match self.0 {} + self.0 } pub fn set_broadcast(&self, _: bool) -> io::Result<()> { - match self.0 {} + self.0 } pub fn broadcast(&self) -> io::Result { - match self.0 {} + self.0 } pub fn set_multicast_loop_v4(&self, _: bool) -> io::Result<()> { - match self.0 {} + self.0 } pub fn multicast_loop_v4(&self) -> io::Result { - match self.0 {} + self.0 } pub fn set_multicast_ttl_v4(&self, _: u32) -> io::Result<()> { - match self.0 {} + self.0 } pub fn multicast_ttl_v4(&self) -> io::Result { - match self.0 {} + self.0 } pub fn set_multicast_loop_v6(&self, _: bool) -> io::Result<()> { - match self.0 {} + self.0 } pub fn multicast_loop_v6(&self) -> io::Result { - match self.0 {} + self.0 } pub fn join_multicast_v4(&self, _: &Ipv4Addr, _: &Ipv4Addr) -> io::Result<()> { - match self.0 {} + self.0 } pub fn join_multicast_v6(&self, _: &Ipv6Addr, _: u32) -> io::Result<()> { - match self.0 {} + self.0 } pub fn leave_multicast_v4(&self, _: &Ipv4Addr, _: &Ipv4Addr) -> io::Result<()> { - match self.0 {} + self.0 } pub fn leave_multicast_v6(&self, _: &Ipv6Addr, _: u32) -> io::Result<()> { - match self.0 {} + self.0 } pub fn set_ttl(&self, _: u32) -> io::Result<()> { - match self.0 {} + self.0 } pub fn ttl(&self) -> io::Result { - match self.0 {} + self.0 } pub fn take_error(&self) -> io::Result> { - match self.0 {} + self.0 } pub fn set_nonblocking(&self, _: bool) -> io::Result<()> { - match self.0 {} + self.0 } pub fn recv(&self, _: &mut [u8]) -> io::Result { - match self.0 {} + self.0 } pub fn peek(&self, _: &mut [u8]) -> io::Result { - match self.0 {} + self.0 } pub fn send(&self, _: &[u8]) -> io::Result { - match self.0 {} + self.0 } pub fn connect(&self, _: io::Result<&SocketAddr>) -> io::Result<()> { - match self.0 {} + self.0 } } impl fmt::Debug for UdpSocket { fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self.0 {} + self.0 } } @@ -295,14 +295,14 @@ pub struct LookupHost(!); impl LookupHost { pub fn port(&self) -> u16 { - match self.0 {} + self.0 } } impl Iterator for LookupHost { type Item = SocketAddr; fn next(&mut self) -> Option { - match self.0 {} + self.0 } } diff --git a/library/std/src/sys/unsupported/os.rs b/library/std/src/sys/unsupported/os.rs index 11583ae99d6d0..e30395a0b1d92 100644 --- a/library/std/src/sys/unsupported/os.rs +++ b/library/std/src/sys/unsupported/os.rs @@ -3,6 +3,7 @@ use crate::error::Error as StdError; use crate::ffi::{OsStr, OsString}; use crate::fmt; use crate::io; +use crate::marker::PhantomData; use crate::path::{self, PathBuf}; pub fn errno() -> i32 { @@ -21,7 +22,7 @@ pub fn chdir(_: &path::Path) -> io::Result<()> { unsupported() } -pub struct SplitPaths<'a>(&'a !); +pub struct SplitPaths<'a>(!, PhantomData<&'a ()>); pub fn split_paths(_unparsed: &OsStr) -> SplitPaths<'_> { panic!("unsupported") @@ -30,7 +31,7 @@ pub fn split_paths(_unparsed: &OsStr) -> SplitPaths<'_> { impl<'a> Iterator for SplitPaths<'a> { type Item = PathBuf; fn next(&mut self) -> Option { - match *self.0 {} + self.0 } } @@ -67,7 +68,7 @@ pub struct Env(!); impl Iterator for Env { type Item = (OsString, OsString); fn next(&mut self) -> Option<(OsString, OsString)> { - match self.0 {} + self.0 } } diff --git a/library/std/src/sys/unsupported/pipe.rs b/library/std/src/sys/unsupported/pipe.rs index 7ea46990d77c8..25514c2322fa4 100644 --- a/library/std/src/sys/unsupported/pipe.rs +++ b/library/std/src/sys/unsupported/pipe.rs @@ -4,31 +4,31 @@ pub struct AnonPipe(!); impl AnonPipe { pub fn read(&self, _buf: &mut [u8]) -> io::Result { - match self.0 {} + self.0 } pub fn read_vectored(&self, _bufs: &mut [IoSliceMut<'_>]) -> io::Result { - match self.0 {} + self.0 } pub fn is_read_vectored(&self) -> bool { - match self.0 {} + self.0 } pub fn write(&self, _buf: &[u8]) -> io::Result { - match self.0 {} + self.0 } pub fn write_vectored(&self, _bufs: &[IoSlice<'_>]) -> io::Result { - match self.0 {} + self.0 } pub fn is_write_vectored(&self) -> bool { - match self.0 {} + self.0 } pub fn diverge(&self) -> ! { - match self.0 {} + self.0 } } diff --git a/library/std/src/sys/unsupported/process.rs b/library/std/src/sys/unsupported/process.rs index f777e40873fb4..38ac0a1ddd5f9 100644 --- a/library/std/src/sys/unsupported/process.rs +++ b/library/std/src/sys/unsupported/process.rs @@ -98,17 +98,17 @@ pub struct ExitStatus(!); impl ExitStatus { pub fn success(&self) -> bool { - match self.0 {} + self.0 } pub fn code(&self) -> Option { - match self.0 {} + self.0 } } impl Clone for ExitStatus { fn clone(&self) -> ExitStatus { - match self.0 {} + self.0 } } @@ -116,7 +116,7 @@ impl Copy for ExitStatus {} impl PartialEq for ExitStatus { fn eq(&self, _other: &ExitStatus) -> bool { - match self.0 {} + self.0 } } @@ -124,13 +124,13 @@ impl Eq for ExitStatus {} impl fmt::Debug for ExitStatus { fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self.0 {} + self.0 } } impl fmt::Display for ExitStatus { fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self.0 {} + self.0 } } @@ -150,19 +150,19 @@ pub struct Process(!); impl Process { pub fn id(&self) -> u32 { - match self.0 {} + self.0 } pub fn kill(&mut self) -> io::Result<()> { - match self.0 {} + self.0 } pub fn wait(&mut self) -> io::Result { - match self.0 {} + self.0 } pub fn try_wait(&mut self) -> io::Result> { - match self.0 {} + self.0 } } diff --git a/library/std/src/sys/unsupported/thread.rs b/library/std/src/sys/unsupported/thread.rs index 7d5d2c6115757..cda8510e1baeb 100644 --- a/library/std/src/sys/unsupported/thread.rs +++ b/library/std/src/sys/unsupported/thread.rs @@ -26,7 +26,7 @@ impl Thread { } pub fn join(self) { - match self.0 {} + self.0 } } diff --git a/library/std/src/sys/wasi/net.rs b/library/std/src/sys/wasi/net.rs index 30c21a05a3274..06860673d90e0 100644 --- a/library/std/src/sys/wasi/net.rs +++ b/library/std/src/sys/wasi/net.rs @@ -347,14 +347,14 @@ pub struct LookupHost(!); impl LookupHost { pub fn port(&self) -> u16 { - match self.0 {} + self.0 } } impl Iterator for LookupHost { type Item = SocketAddr; fn next(&mut self) -> Option { - match self.0 {} + self.0 } } diff --git a/library/std/src/sys/wasi/os.rs b/library/std/src/sys/wasi/os.rs index a349c149249f4..cf17ac0ba5f2b 100644 --- a/library/std/src/sys/wasi/os.rs +++ b/library/std/src/sys/wasi/os.rs @@ -87,7 +87,7 @@ pub fn chdir(p: &path::Path) -> io::Result<()> { } } -pub struct SplitPaths<'a>(&'a !); +pub struct SplitPaths<'a>(!, PhantomData<&'a ()>); pub fn split_paths(_unparsed: &OsStr) -> SplitPaths<'_> { panic!("unsupported") @@ -96,7 +96,7 @@ pub fn split_paths(_unparsed: &OsStr) -> SplitPaths<'_> { impl<'a> Iterator for SplitPaths<'a> { type Item = PathBuf; fn next(&mut self) -> Option { - match *self.0 {} + self.0 } } diff --git a/library/std/src/sys/wasi/thread.rs b/library/std/src/sys/wasi/thread.rs index 2efa91f8b7011..74515553a8218 100644 --- a/library/std/src/sys/wasi/thread.rs +++ b/library/std/src/sys/wasi/thread.rs @@ -59,7 +59,7 @@ impl Thread { } pub fn join(self) { - match self.0 {} + self.0 } } diff --git a/library/std/src/sys/wasm/thread.rs b/library/std/src/sys/wasm/thread.rs index 77f8c79ced929..b7bf95c89b482 100644 --- a/library/std/src/sys/wasm/thread.rs +++ b/library/std/src/sys/wasm/thread.rs @@ -47,7 +47,7 @@ impl Thread { } pub fn join(self) { - match self.0 {} + self.0 } } From c968594456fa9b32bb6ddcdf245b2f05a9fcf1af Mon Sep 17 00:00:00 2001 From: Stephen Albert-Moore Date: Tue, 20 Apr 2021 17:10:20 -0400 Subject: [PATCH 09/28] Fix broken doc link --- src/doc/unstable-book/src/language-features/lang-items.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/unstable-book/src/language-features/lang-items.md b/src/doc/unstable-book/src/language-features/lang-items.md index 22780804610b6..86bedb51538b5 100644 --- a/src/doc/unstable-book/src/language-features/lang-items.md +++ b/src/doc/unstable-book/src/language-features/lang-items.md @@ -191,7 +191,7 @@ mechanisms of the compiler. This is often mapped to GCC's personality function which do not trigger a panic can be assured that this function is never called. The language item's name is `eh_personality`. -[unwind]: https://github.com/rust-lang/rust/blob/master/src/libpanic_unwind/gcc.rs +[unwind]: https://github.com/rust-lang/rust/blob/master/library/panic_unwind/src/gcc.rs The second function, `rust_begin_panic`, is also used by the failure mechanisms of the compiler. When a panic happens, this controls the message that's displayed on From 0c193f82e7525cba88d67320fc3d706683a9cb9b Mon Sep 17 00:00:00 2001 From: Smitty Date: Tue, 20 Apr 2021 17:31:18 -0400 Subject: [PATCH 10/28] Write Rustdoc titles like "x in crate::mod - Rust" This makes Rustdoc titles for items read like "x in cratename::blah::foo - Rust". Title for modules and other non-items are unchanged, and still read like "doccratenameconst::blah::foo - Rust". This makes managing several open Rustdoc tabs easier. Closes #84371. --- src/librustdoc/html/render/context.rs | 17 +++++++------- src/test/rustdoc/crate-title.rs | 3 +++ src/test/rustdoc/item-title.rs | 33 +++++++++++++++++++++++++++ src/test/rustdoc/mod-title.rs | 12 ++++++++++ 4 files changed, 56 insertions(+), 9 deletions(-) create mode 100644 src/test/rustdoc/crate-title.rs create mode 100644 src/test/rustdoc/item-title.rs create mode 100644 src/test/rustdoc/mod-title.rs diff --git a/src/librustdoc/html/render/context.rs b/src/librustdoc/html/render/context.rs index 05d2001385929..3fcf972a5b887 100644 --- a/src/librustdoc/html/render/context.rs +++ b/src/librustdoc/html/render/context.rs @@ -168,18 +168,17 @@ impl<'tcx> Context<'tcx> { } fn render_item(&self, it: &clean::Item, pushname: bool) -> String { - let mut title = if it.is_primitive() || it.is_keyword() { - // No need to include the namespace for primitive types and keywords - String::new() - } else { - self.current.join("::") - }; + let mut title = String::new(); if pushname { - if !title.is_empty() { - title.push_str("::"); - } title.push_str(&it.name.unwrap().as_str()); } + if !it.is_primitive() && !it.is_keyword() { + if pushname { + title.push_str(" in "); + } + // No need to include the namespace for primitive types and keywords + title.push_str(&self.current.join("::")); + }; title.push_str(" - Rust"); let tyname = it.type_(); let desc = it.doc_value().as_ref().map(|doc| plain_text_summary(&doc)); diff --git a/src/test/rustdoc/crate-title.rs b/src/test/rustdoc/crate-title.rs new file mode 100644 index 0000000000000..6f96f98e7074f --- /dev/null +++ b/src/test/rustdoc/crate-title.rs @@ -0,0 +1,3 @@ +#![crate_name = "foo"] + +// @has foo/index.html '//head/title' 'foo - Rust' diff --git a/src/test/rustdoc/item-title.rs b/src/test/rustdoc/item-title.rs new file mode 100644 index 0000000000000..d0fbdf95ddce1 --- /dev/null +++ b/src/test/rustdoc/item-title.rs @@ -0,0 +1,33 @@ +#![crate_name = "foo"] +#![feature(doc_keyword)] + +// @has foo/fn.widget_count.html '//head/title' 'widget_count in foo - Rust' +/// blah +pub fn widget_count() {} + +// @has foo/struct.Widget.html '//head/title' 'Widget in foo - Rust' +pub struct Widget; + +// @has foo/constant.ANSWER.html '//head/title' 'ANSWER in foo - Rust' +pub const ANSWER: u8 = 42; + +pub mod blah { + // @has foo/blah/struct.Widget.html '//head/title' 'Widget in foo::blah - Rust' + pub struct Widget; + + // @has foo/blah/trait.Awesome.html '//head/title' 'Awesome in foo::blah - Rust' + pub trait Awesome {} + + // @has foo/blah/fn.make_widget.html '//head/title' 'make_widget in foo::blah - Rust' + pub fn make_widget() {} + + // @has foo/macro.cool_macro.html '//head/title' 'cool_macro in foo - Rust' + #[macro_export] + macro_rules! cool_macro { + ($t:tt) => { $t } + } +} + +// @has foo/keyword.continue.html '//head/title' 'continue - Rust' +#[doc(keyword = "continue")] +mod continue_keyword {} diff --git a/src/test/rustdoc/mod-title.rs b/src/test/rustdoc/mod-title.rs new file mode 100644 index 0000000000000..6b7f67d17ab3a --- /dev/null +++ b/src/test/rustdoc/mod-title.rs @@ -0,0 +1,12 @@ +#![crate_name = "foo"] + +// @has foo/bar/index.html '//head/title' 'foo::bar - Rust' +/// blah +pub mod bar { + pub fn a() {} +} + +// @has foo/baz/index.html '//head/title' 'foo::baz - Rust' +pub mod baz { + pub fn a() {} +} From b6647b569262215f4f69a93b8e8121438c9db98b Mon Sep 17 00:00:00 2001 From: marmeladema Date: Tue, 20 Apr 2021 22:40:09 +0100 Subject: [PATCH 11/28] Add test for issue #79949 --- .../ui/associated-type-bounds/issue-79949.rs | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/test/ui/associated-type-bounds/issue-79949.rs diff --git a/src/test/ui/associated-type-bounds/issue-79949.rs b/src/test/ui/associated-type-bounds/issue-79949.rs new file mode 100644 index 0000000000000..9f924f1fd81d8 --- /dev/null +++ b/src/test/ui/associated-type-bounds/issue-79949.rs @@ -0,0 +1,26 @@ +// check-pass + +#![allow(incomplete_features)] +#![feature(associated_type_bounds)] +#![feature(generic_associated_types)] + +trait MP { + type T<'a>; +} +struct S(String); +impl MP for S { + type T<'a> = &'a str; +} + +trait SR: MP { + fn sr(&self) -> i32 + where + for<'a> IM: T::T<'a>>>; +} + +trait T { + type T; +} +trait U {} + +fn main() {} From 19e51aaef7cf2f7a9e0e72168caf73a94a1cbfb1 Mon Sep 17 00:00:00 2001 From: marmeladema Date: Tue, 20 Apr 2021 23:33:13 +0100 Subject: [PATCH 12/28] Add test for issue #79636 --- .../generic-associated-types/issue-79636-1.rs | 24 +++++++++++++++++++ .../issue-79636-1.stderr | 19 +++++++++++++++ .../generic-associated-types/issue-79636-2.rs | 18 ++++++++++++++ .../issue-79636-2.stderr | 19 +++++++++++++++ 4 files changed, 80 insertions(+) create mode 100644 src/test/ui/generic-associated-types/issue-79636-1.rs create mode 100644 src/test/ui/generic-associated-types/issue-79636-1.stderr create mode 100644 src/test/ui/generic-associated-types/issue-79636-2.rs create mode 100644 src/test/ui/generic-associated-types/issue-79636-2.stderr diff --git a/src/test/ui/generic-associated-types/issue-79636-1.rs b/src/test/ui/generic-associated-types/issue-79636-1.rs new file mode 100644 index 0000000000000..17f9387e29204 --- /dev/null +++ b/src/test/ui/generic-associated-types/issue-79636-1.rs @@ -0,0 +1,24 @@ +#![allow(incomplete_features)] +#![feature(generic_associated_types)] + +trait Monad { + type Unwrapped; + type Wrapped; + //~^ ERROR: missing generics for associated type `Monad::Wrapped` + + fn bind(self, f: F) -> Self::Wrapped { + todo!() + } +} + +fn join(outer: MOuter) -> MOuter::Wrapped +where + MOuter: Monad, + MInner: Monad>, +{ + outer.bind(|inner| inner) +} + +fn main() { + assert_eq!(join(Some(Some(true))), Some(true)); +} diff --git a/src/test/ui/generic-associated-types/issue-79636-1.stderr b/src/test/ui/generic-associated-types/issue-79636-1.stderr new file mode 100644 index 0000000000000..58eeb43f70d66 --- /dev/null +++ b/src/test/ui/generic-associated-types/issue-79636-1.stderr @@ -0,0 +1,19 @@ +error[E0107]: missing generics for associated type `Monad::Wrapped` + --> $DIR/issue-79636-1.rs:6:10 + | +LL | type Wrapped; + | ^^^^^^^ expected 1 type argument + | +note: associated type defined here, with 1 type parameter: `B` + --> $DIR/issue-79636-1.rs:6:10 + | +LL | type Wrapped; + | ^^^^^^^ - +help: use angle brackets to add missing type argument + | +LL | type Wrapped; + | ^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0107`. diff --git a/src/test/ui/generic-associated-types/issue-79636-2.rs b/src/test/ui/generic-associated-types/issue-79636-2.rs new file mode 100644 index 0000000000000..5a6542193752b --- /dev/null +++ b/src/test/ui/generic-associated-types/issue-79636-2.rs @@ -0,0 +1,18 @@ +#![allow(incomplete_features)] +#![feature(generic_associated_types)] + +trait SomeTrait { + type Wrapped: SomeTrait; + //~^ ERROR: missing generics for associated type `SomeTrait::Wrapped` + + fn f() -> (); +} + +fn program() -> () +where + W: SomeTrait, +{ + return W::f(); +} + +fn main() {} diff --git a/src/test/ui/generic-associated-types/issue-79636-2.stderr b/src/test/ui/generic-associated-types/issue-79636-2.stderr new file mode 100644 index 0000000000000..d5e3c56ebb9ef --- /dev/null +++ b/src/test/ui/generic-associated-types/issue-79636-2.stderr @@ -0,0 +1,19 @@ +error[E0107]: missing generics for associated type `SomeTrait::Wrapped` + --> $DIR/issue-79636-2.rs:5:10 + | +LL | type Wrapped: SomeTrait; + | ^^^^^^^ expected 1 type argument + | +note: associated type defined here, with 1 type parameter: `A` + --> $DIR/issue-79636-2.rs:5:10 + | +LL | type Wrapped: SomeTrait; + | ^^^^^^^ - +help: use angle brackets to add missing type argument + | +LL | type Wrapped: SomeTrait; + | ^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0107`. From 25cb1af7b232c93396b122ed6eb0887a388183f7 Mon Sep 17 00:00:00 2001 From: marmeladema Date: Tue, 20 Apr 2021 23:41:40 +0100 Subject: [PATCH 13/28] Add test for issue #78671 --- .../generic-associated-types/issue-78671.rs | 14 ++++++++++++++ .../issue-78671.stderr | 19 +++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 src/test/ui/generic-associated-types/issue-78671.rs create mode 100644 src/test/ui/generic-associated-types/issue-78671.stderr diff --git a/src/test/ui/generic-associated-types/issue-78671.rs b/src/test/ui/generic-associated-types/issue-78671.rs new file mode 100644 index 0000000000000..1b02aac8bcb24 --- /dev/null +++ b/src/test/ui/generic-associated-types/issue-78671.rs @@ -0,0 +1,14 @@ +#![allow(incomplete_features)] +#![feature(generic_associated_types)] + +trait CollectionFamily { + type Member; + //~^ ERROR: missing generics for associated type +} +fn floatify() { + Box::new(Family) as &dyn CollectionFamily +} + +struct Family; + +fn main() {} diff --git a/src/test/ui/generic-associated-types/issue-78671.stderr b/src/test/ui/generic-associated-types/issue-78671.stderr new file mode 100644 index 0000000000000..7a9aced5beab8 --- /dev/null +++ b/src/test/ui/generic-associated-types/issue-78671.stderr @@ -0,0 +1,19 @@ +error[E0107]: missing generics for associated type `CollectionFamily::Member` + --> $DIR/issue-78671.rs:5:10 + | +LL | type Member; + | ^^^^^^ expected 1 type argument + | +note: associated type defined here, with 1 type parameter: `T` + --> $DIR/issue-78671.rs:5:10 + | +LL | type Member; + | ^^^^^^ - +help: use angle brackets to add missing type argument + | +LL | type Member; + | ^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0107`. From 1ef760d88e8cbbc73ca53598f8de5536d1fbfac9 Mon Sep 17 00:00:00 2001 From: marmeladema Date: Tue, 20 Apr 2021 23:49:04 +0100 Subject: [PATCH 14/28] Add test for issue #70303 --- .../generic-associated-types/issue-70303.rs | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 src/test/ui/generic-associated-types/issue-70303.rs diff --git a/src/test/ui/generic-associated-types/issue-70303.rs b/src/test/ui/generic-associated-types/issue-70303.rs new file mode 100644 index 0000000000000..a1cb2295b639e --- /dev/null +++ b/src/test/ui/generic-associated-types/issue-70303.rs @@ -0,0 +1,60 @@ +// check-pass + +#![allow(incomplete_features)] +#![feature(generic_associated_types)] + +trait Document { + type Cursor<'a>: DocCursor<'a>; + + fn cursor(&self) -> Self::Cursor<'_>; +} + +struct DocumentImpl {} + +impl Document for DocumentImpl { + type Cursor<'a> = DocCursorImpl<'a>; + + fn cursor(&self) -> Self::Cursor<'_> { + DocCursorImpl { + document: &self, + } + } +} + + +trait DocCursor<'a> {} + +struct DocCursorImpl<'a> { + document: &'a DocumentImpl, +} + +impl<'a> DocCursor<'a> for DocCursorImpl<'a> {} + +struct Lexer<'d, Cursor> +where + Cursor: DocCursor<'d>, +{ + cursor: Cursor, + _phantom: std::marker::PhantomData<&'d ()>, +} + + +impl<'d, Cursor> Lexer<'d, Cursor> +where + Cursor: DocCursor<'d>, +{ + pub fn from(document: &'d Doc) -> Lexer<'d, Cursor> + where + Doc: Document = Cursor>, + { + Lexer { + cursor: document.cursor(), + _phantom: std::marker::PhantomData, + } + } +} + +pub fn main() { + let doc = DocumentImpl {}; + let lexer: Lexer<'_, DocCursorImpl<'_>> = Lexer::from(&doc); +} From 7cf4f4276f691b3052df64930a9f02e33e2783df Mon Sep 17 00:00:00 2001 From: Smitty Date: Tue, 20 Apr 2021 18:53:15 -0400 Subject: [PATCH 15/28] Rename pushname to is_module --- src/librustdoc/html/render/context.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/librustdoc/html/render/context.rs b/src/librustdoc/html/render/context.rs index 3fcf972a5b887..397e03afae67d 100644 --- a/src/librustdoc/html/render/context.rs +++ b/src/librustdoc/html/render/context.rs @@ -167,13 +167,13 @@ impl<'tcx> Context<'tcx> { "../".repeat(self.current.len()) } - fn render_item(&self, it: &clean::Item, pushname: bool) -> String { + fn render_item(&self, it: &clean::Item, is_module: bool) -> String { let mut title = String::new(); - if pushname { + if is_module { title.push_str(&it.name.unwrap().as_str()); } if !it.is_primitive() && !it.is_keyword() { - if pushname { + if is_module { title.push_str(" in "); } // No need to include the namespace for primitive types and keywords From a9ff7ac9c3e583e7723722319d48caf35bdc0efb Mon Sep 17 00:00:00 2001 From: Smitty Date: Tue, 20 Apr 2021 18:57:26 -0400 Subject: [PATCH 16/28] Merge mod-title and item-title tests --- src/test/rustdoc/item-title.rs | 1 + src/test/rustdoc/mod-title.rs | 12 ------------ 2 files changed, 1 insertion(+), 12 deletions(-) delete mode 100644 src/test/rustdoc/mod-title.rs diff --git a/src/test/rustdoc/item-title.rs b/src/test/rustdoc/item-title.rs index d0fbdf95ddce1..4c0d233fbec31 100644 --- a/src/test/rustdoc/item-title.rs +++ b/src/test/rustdoc/item-title.rs @@ -11,6 +11,7 @@ pub struct Widget; // @has foo/constant.ANSWER.html '//head/title' 'ANSWER in foo - Rust' pub const ANSWER: u8 = 42; +// @has foo/blah/index.html '//head/title' 'foo::blah - Rust' pub mod blah { // @has foo/blah/struct.Widget.html '//head/title' 'Widget in foo::blah - Rust' pub struct Widget; diff --git a/src/test/rustdoc/mod-title.rs b/src/test/rustdoc/mod-title.rs deleted file mode 100644 index 6b7f67d17ab3a..0000000000000 --- a/src/test/rustdoc/mod-title.rs +++ /dev/null @@ -1,12 +0,0 @@ -#![crate_name = "foo"] - -// @has foo/bar/index.html '//head/title' 'foo::bar - Rust' -/// blah -pub mod bar { - pub fn a() {} -} - -// @has foo/baz/index.html '//head/title' 'foo::baz - Rust' -pub mod baz { - pub fn a() {} -} From 05121a22e61c02933ea1c619e4126b4dafe2a2d1 Mon Sep 17 00:00:00 2001 From: Smitty Date: Tue, 20 Apr 2021 19:10:00 -0400 Subject: [PATCH 17/28] fix is_module check --- src/librustdoc/html/render/context.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/librustdoc/html/render/context.rs b/src/librustdoc/html/render/context.rs index 397e03afae67d..0aa7aa763c2af 100644 --- a/src/librustdoc/html/render/context.rs +++ b/src/librustdoc/html/render/context.rs @@ -169,11 +169,11 @@ impl<'tcx> Context<'tcx> { fn render_item(&self, it: &clean::Item, is_module: bool) -> String { let mut title = String::new(); - if is_module { + if !is_module { title.push_str(&it.name.unwrap().as_str()); } if !it.is_primitive() && !it.is_keyword() { - if is_module { + if !is_module { title.push_str(" in "); } // No need to include the namespace for primitive types and keywords @@ -597,7 +597,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> { info!("Recursing into {}", self.dst.display()); - let buf = self.render_item(item, false); + let buf = self.render_item(item, true); // buf will be empty if the module is stripped and there is no redirect for it if !buf.is_empty() { self.shared.ensure_dir(&self.dst)?; @@ -640,7 +640,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> { self.render_redirect_pages = item.is_stripped(); } - let buf = self.render_item(&item, true); + let buf = self.render_item(&item, false); // buf will be empty if the item is stripped and there is no redirect for it if !buf.is_empty() { let name = item.name.as_ref().unwrap(); From cbd0d89a26a7688970af5c8cc9e455deafd3697d Mon Sep 17 00:00:00 2001 From: marmeladema Date: Tue, 20 Apr 2021 23:59:05 +0100 Subject: [PATCH 18/28] Add test for issue #70304 --- .../generic-associated-types/issue-70304.rs | 63 +++++++++++++++++++ .../issue-70304.stderr | 15 +++++ 2 files changed, 78 insertions(+) create mode 100644 src/test/ui/generic-associated-types/issue-70304.rs create mode 100644 src/test/ui/generic-associated-types/issue-70304.stderr diff --git a/src/test/ui/generic-associated-types/issue-70304.rs b/src/test/ui/generic-associated-types/issue-70304.rs new file mode 100644 index 0000000000000..225f61d132ee6 --- /dev/null +++ b/src/test/ui/generic-associated-types/issue-70304.rs @@ -0,0 +1,63 @@ +#![allow(incomplete_features)] +#![feature(generic_associated_types)] + +trait Document { + type Cursor<'a>: DocCursor<'a>; + + fn cursor(&self) -> Self::Cursor<'_>; +} + +struct DocumentImpl {} + +impl Document for DocumentImpl { + type Cursor<'a> = DocCursorImpl<'a>; + + fn cursor(&self) -> Self::Cursor<'_> { + DocCursorImpl { + document: &self, + } + } +} + + +trait DocCursor<'a> {} + +struct DocCursorImpl<'a> { + document: &'a DocumentImpl, +} + +impl<'a> DocCursor<'a> for DocCursorImpl<'a> {} + +struct Lexer<'d, Cursor> +where + Cursor: DocCursor<'d>, +{ + cursor: Cursor, + _phantom: std::marker::PhantomData<&'d ()>, +} + + +impl<'d, Cursor> Lexer<'d, Cursor> +where + Cursor: DocCursor<'d>, +{ + pub fn from(document: &'d Doc) -> Lexer<'d, Cursor> + where + Doc: Document = Cursor>, + { + Lexer { + cursor: document.cursor(), + _phantom: std::marker::PhantomData, + } + } +} + +fn create_doc() -> impl Document = DocCursorImpl<'_>> { + //~^ ERROR: missing lifetime specifier + DocumentImpl {} +} + +pub fn main() { + let doc = create_doc(); + let lexer: Lexer<'_, DocCursorImpl<'_>> = Lexer::from(&doc); +} diff --git a/src/test/ui/generic-associated-types/issue-70304.stderr b/src/test/ui/generic-associated-types/issue-70304.stderr new file mode 100644 index 0000000000000..dfa86018976dc --- /dev/null +++ b/src/test/ui/generic-associated-types/issue-70304.stderr @@ -0,0 +1,15 @@ +error[E0106]: missing lifetime specifier + --> $DIR/issue-70304.rs:55:41 + | +LL | fn create_doc() -> impl Document = DocCursorImpl<'_>> { + | ^^ expected named lifetime parameter + | + = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from +help: consider using the `'static` lifetime + | +LL | fn create_doc() -> impl Document = DocCursorImpl<'_>> { + | ^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0106`. From d328dbc60f51a70f0c6eeec644af303719e563a4 Mon Sep 17 00:00:00 2001 From: marmeladema Date: Wed, 21 Apr 2021 00:07:42 +0100 Subject: [PATCH 19/28] Add test for issue #71176 --- .../generic-associated-types/issue-71176.rs | 21 +++++++++++++++++++ .../issue-71176.stderr | 19 +++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 src/test/ui/generic-associated-types/issue-71176.rs create mode 100644 src/test/ui/generic-associated-types/issue-71176.stderr diff --git a/src/test/ui/generic-associated-types/issue-71176.rs b/src/test/ui/generic-associated-types/issue-71176.rs new file mode 100644 index 0000000000000..470476bf476a0 --- /dev/null +++ b/src/test/ui/generic-associated-types/issue-71176.rs @@ -0,0 +1,21 @@ +#![allow(incomplete_features)] +#![feature(generic_associated_types)] + +trait Provider { + type A<'a>; + //~^ ERROR: missing generics for associated type +} + +impl Provider for () { + type A<'a> = (); +} + +struct Holder { + inner: Box>, +} + +fn main() { + Holder { + inner: Box::new(()), + }; +} diff --git a/src/test/ui/generic-associated-types/issue-71176.stderr b/src/test/ui/generic-associated-types/issue-71176.stderr new file mode 100644 index 0000000000000..dd19dd4ad8e83 --- /dev/null +++ b/src/test/ui/generic-associated-types/issue-71176.stderr @@ -0,0 +1,19 @@ +error[E0107]: missing generics for associated type `Provider::A` + --> $DIR/issue-71176.rs:5:10 + | +LL | type A<'a>; + | ^ expected 1 lifetime argument + | +note: associated type defined here, with 1 lifetime parameter: `'a` + --> $DIR/issue-71176.rs:5:10 + | +LL | type A<'a>; + | ^ -- +help: use angle brackets to add missing lifetime argument + | +LL | type A<'a><'a>; + | ^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0107`. From 3ddafb2d7c96787e692e90c76f2ca5bdb936cb0c Mon Sep 17 00:00:00 2001 From: Smitty Date: Tue, 20 Apr 2021 19:53:44 -0400 Subject: [PATCH 20/28] Add test for title of root page in item-title.rs --- src/test/rustdoc/crate-title.rs | 3 --- src/test/rustdoc/{item-title.rs => title.rs} | 2 ++ 2 files changed, 2 insertions(+), 3 deletions(-) delete mode 100644 src/test/rustdoc/crate-title.rs rename src/test/rustdoc/{item-title.rs => title.rs} (95%) diff --git a/src/test/rustdoc/crate-title.rs b/src/test/rustdoc/crate-title.rs deleted file mode 100644 index 6f96f98e7074f..0000000000000 --- a/src/test/rustdoc/crate-title.rs +++ /dev/null @@ -1,3 +0,0 @@ -#![crate_name = "foo"] - -// @has foo/index.html '//head/title' 'foo - Rust' diff --git a/src/test/rustdoc/item-title.rs b/src/test/rustdoc/title.rs similarity index 95% rename from src/test/rustdoc/item-title.rs rename to src/test/rustdoc/title.rs index 4c0d233fbec31..b0e22af0b1c7f 100644 --- a/src/test/rustdoc/item-title.rs +++ b/src/test/rustdoc/title.rs @@ -1,6 +1,8 @@ #![crate_name = "foo"] #![feature(doc_keyword)] +// @has foo/index.html '//head/title' 'foo - Rust' + // @has foo/fn.widget_count.html '//head/title' 'widget_count in foo - Rust' /// blah pub fn widget_count() {} From df147c718c5819631eefc774e6e40d4515f30c90 Mon Sep 17 00:00:00 2001 From: Smitty Date: Tue, 20 Apr 2021 19:56:28 -0400 Subject: [PATCH 21/28] Just merge all of the tests into one --- src/test/rustdoc/prim-title.rs | 7 ------- src/test/rustdoc/{title.rs => tab_title.rs} | 8 ++++++++ 2 files changed, 8 insertions(+), 7 deletions(-) delete mode 100644 src/test/rustdoc/prim-title.rs rename src/test/rustdoc/{title.rs => tab_title.rs} (86%) diff --git a/src/test/rustdoc/prim-title.rs b/src/test/rustdoc/prim-title.rs deleted file mode 100644 index fa3fd512fada6..0000000000000 --- a/src/test/rustdoc/prim-title.rs +++ /dev/null @@ -1,7 +0,0 @@ -#![crate_name = "foo"] - -// @has foo/primitive.u8.html '//head/title' 'u8 - Rust' -// @!has - '//head/title' 'foo' -#[doc(primitive = "u8")] -/// `u8` docs -mod u8 {} diff --git a/src/test/rustdoc/title.rs b/src/test/rustdoc/tab_title.rs similarity index 86% rename from src/test/rustdoc/title.rs rename to src/test/rustdoc/tab_title.rs index b0e22af0b1c7f..7dce6092deaed 100644 --- a/src/test/rustdoc/title.rs +++ b/src/test/rustdoc/tab_title.rs @@ -1,6 +1,8 @@ #![crate_name = "foo"] #![feature(doc_keyword)] +// tests for the html <title> element + // @has foo/index.html '//head/title' 'foo - Rust' // @has foo/fn.widget_count.html '//head/title' 'widget_count in foo - Rust' @@ -34,3 +36,9 @@ pub mod blah { // @has foo/keyword.continue.html '//head/title' 'continue - Rust' #[doc(keyword = "continue")] mod continue_keyword {} + +// @has foo/primitive.u8.html '//head/title' 'u8 - Rust' +// @!has - '//head/title' 'foo' +#[doc(primitive = "u8")] +/// `u8` docs +mod u8 {} From 82dc73b1aef4a687466e00d87c5791b2a04d28f9 Mon Sep 17 00:00:00 2001 From: Mara Bos <m-ou.se@m-ou.se> Date: Wed, 21 Apr 2021 13:50:56 +0200 Subject: [PATCH 22/28] Format `Struct { .. }` on one line even with `{:#?}`. --- library/core/src/fmt/builders.rs | 27 +++++++++------------------ library/core/tests/fmt/builders.rs | 7 +------ 2 files changed, 10 insertions(+), 24 deletions(-) diff --git a/library/core/src/fmt/builders.rs b/library/core/src/fmt/builders.rs index 475ebcf07d5ed..b660788c0515f 100644 --- a/library/core/src/fmt/builders.rs +++ b/library/core/src/fmt/builders.rs @@ -188,28 +188,19 @@ impl<'a, 'b: 'a> DebugStruct<'a, 'b> { #[stable(feature = "debug_non_exhaustive", since = "1.53.0")] pub fn finish_non_exhaustive(&mut self) -> fmt::Result { self.result = self.result.and_then(|_| { - // Draw non-exhaustive dots (`..`), and open brace if necessary (no fields). - if self.is_pretty() { - if !self.has_fields { - self.fmt.write_str(" {\n")?; - } - let mut slot = None; - let mut state = Default::default(); - let mut writer = PadAdapter::wrap(&mut self.fmt, &mut slot, &mut state); - writer.write_str("..\n")?; - } else { - if self.has_fields { - self.fmt.write_str(", ..")?; + if self.has_fields { + if self.is_pretty() { + let mut slot = None; + let mut state = Default::default(); + let mut writer = PadAdapter::wrap(&mut self.fmt, &mut slot, &mut state); + writer.write_str("..\n")?; + self.fmt.write_str("}") } else { - self.fmt.write_str(" { ..")?; + self.fmt.write_str(", .. }") } - } - if self.is_pretty() { - self.fmt.write_str("}")? } else { - self.fmt.write_str(" }")?; + self.fmt.write_str(" { .. }") } - Ok(()) }); self.result } diff --git a/library/core/tests/fmt/builders.rs b/library/core/tests/fmt/builders.rs index 129c121e8ceac..7580010a28b4a 100644 --- a/library/core/tests/fmt/builders.rs +++ b/library/core/tests/fmt/builders.rs @@ -105,12 +105,7 @@ mod debug_struct { } assert_eq!("Foo { .. }", format!("{:?}", Foo)); - assert_eq!( - "Foo { - .. -}", - format!("{:#?}", Foo) - ); + assert_eq!("Foo { .. }", format!("{:#?}", Foo)); } #[test] From cc44ce0a3f379bc6e8a4078ee6f0b1a4237fa975 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez <guillaume1.gomez@gmail.com> Date: Wed, 21 Apr 2021 14:20:56 +0200 Subject: [PATCH 23/28] Correctly handle --open argument on doc command --- src/bootstrap/doc.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs index dc96fd819d558..50370a5ffb608 100644 --- a/src/bootstrap/doc.rs +++ b/src/bootstrap/doc.rs @@ -479,12 +479,16 @@ impl Step for Std { // Look for library/std, library/core etc in the `x.py doc` arguments and // open the corresponding rendered docs. for path in builder.paths.iter().map(components_simplified) { - if path.get(0) == Some(&"library") { - let requested_crate = &path[1]; - if krates.contains(&requested_crate) { - let index = out.join(requested_crate).join("index.html"); - open(builder, &index); - } + let requested_crate = if path.get(0) == Some(&"library") { + &path[1] + } else if !path.is_empty() { + &path[0] + } else { + continue; + }; + if krates.contains(&requested_crate) { + let index = out.join(requested_crate).join("index.html"); + open(builder, &index); } } } From 1fb3256fcb9f616b19245eedea6503bce35e5b81 Mon Sep 17 00:00:00 2001 From: Christiaan Dirkx <christiaan@dirkx.email> Date: Mon, 5 Apr 2021 13:31:11 +0200 Subject: [PATCH 24/28] Replace all `fmt.pad` with `debug_struct` --- library/core/src/any.rs | 6 +++--- library/core/src/ascii.rs | 2 +- library/core/src/ffi.rs | 2 +- library/core/src/fmt/mod.rs | 4 ++-- library/core/src/hash/mod.rs | 2 +- library/core/src/iter/sources/empty.rs | 2 +- library/core/src/slice/ascii.rs | 2 +- library/core/src/str/iter.rs | 2 +- library/std/src/collections/hash/map.rs | 4 ++-- library/std/src/collections/hash/set.rs | 2 +- library/std/src/env.rs | 6 +++--- library/std/src/io/stdio.rs | 12 ++++++------ library/std/src/io/util.rs | 6 +++--- library/std/src/process.rs | 8 ++++---- library/std/src/sync/barrier.rs | 2 +- library/std/src/sync/condvar.rs | 2 +- library/std/src/sync/mpsc/mod.rs | 2 +- library/std/src/sync/once.rs | 2 +- library/std/src/sys_common/poison.rs | 2 +- library/std/src/thread/local.rs | 8 ++++---- library/std/src/thread/mod.rs | 2 +- 21 files changed, 40 insertions(+), 40 deletions(-) diff --git a/library/core/src/any.rs b/library/core/src/any.rs index 98c34f344251e..339e874558c51 100644 --- a/library/core/src/any.rs +++ b/library/core/src/any.rs @@ -141,7 +141,7 @@ impl<T: 'static + ?Sized> Any for T { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for dyn Any { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.pad("Any") + f.debug_struct("Any").finish() } } @@ -151,14 +151,14 @@ impl fmt::Debug for dyn Any { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for dyn Any + Send { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.pad("Any") + f.debug_struct("Any").finish() } } #[stable(feature = "any_send_sync_methods", since = "1.28.0")] impl fmt::Debug for dyn Any + Send + Sync { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.pad("Any") + f.debug_struct("Any").finish() } } diff --git a/library/core/src/ascii.rs b/library/core/src/ascii.rs index a8a25f927163c..4780d8dc7883f 100644 --- a/library/core/src/ascii.rs +++ b/library/core/src/ascii.rs @@ -145,6 +145,6 @@ impl fmt::Display for EscapeDefault { #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for EscapeDefault { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.pad("EscapeDefault { .. }") + f.debug_struct("EscapeDefault").finish_non_exhaustive() } } diff --git a/library/core/src/ffi.rs b/library/core/src/ffi.rs index 9302baa823bc5..b208ddd4b272f 100644 --- a/library/core/src/ffi.rs +++ b/library/core/src/ffi.rs @@ -53,7 +53,7 @@ pub enum c_void { #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for c_void { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.pad("c_void") + f.debug_struct("c_void").finish() } } diff --git a/library/core/src/fmt/mod.rs b/library/core/src/fmt/mod.rs index 59493bb0425f3..0edb7da571725 100644 --- a/library/core/src/fmt/mod.rs +++ b/library/core/src/fmt/mod.rs @@ -2220,7 +2220,7 @@ impl Debug for () { #[stable(feature = "rust1", since = "1.0.0")] impl<T: ?Sized> Debug for PhantomData<T> { fn fmt(&self, f: &mut Formatter<'_>) -> Result { - f.pad("PhantomData") + f.debug_struct("PhantomData").finish() } } @@ -2270,7 +2270,7 @@ impl<T: ?Sized + Debug> Debug for RefMut<'_, T> { #[stable(feature = "core_impl_debug", since = "1.9.0")] impl<T: ?Sized> Debug for UnsafeCell<T> { fn fmt(&self, f: &mut Formatter<'_>) -> Result { - f.pad("UnsafeCell") + f.debug_struct("UnsafeCell").finish() } } diff --git a/library/core/src/hash/mod.rs b/library/core/src/hash/mod.rs index 0c3303cc21094..7dbd68b73f05a 100644 --- a/library/core/src/hash/mod.rs +++ b/library/core/src/hash/mod.rs @@ -507,7 +507,7 @@ pub struct BuildHasherDefault<H>(marker::PhantomData<H>); #[stable(since = "1.9.0", feature = "core_impl_debug")] impl<H> fmt::Debug for BuildHasherDefault<H> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.pad("BuildHasherDefault") + f.debug_struct("BuildHasherDefault").finish() } } diff --git a/library/core/src/iter/sources/empty.rs b/library/core/src/iter/sources/empty.rs index 5d4a9fe8c6cc0..919c564f2872a 100644 --- a/library/core/src/iter/sources/empty.rs +++ b/library/core/src/iter/sources/empty.rs @@ -36,7 +36,7 @@ unsafe impl<T> Sync for Empty<T> {} #[stable(feature = "core_impl_debug", since = "1.9.0")] impl<T> fmt::Debug for Empty<T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.pad("Empty") + f.debug_struct("Empty").finish() } } diff --git a/library/core/src/slice/ascii.rs b/library/core/src/slice/ascii.rs index 22fa08b979570..906dcb1e8bcee 100644 --- a/library/core/src/slice/ascii.rs +++ b/library/core/src/slice/ascii.rs @@ -146,7 +146,7 @@ impl<'a> fmt::Display for EscapeAscii<'a> { #[unstable(feature = "inherent_ascii_escape", issue = "77174")] impl<'a> fmt::Debug for EscapeAscii<'a> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.pad("EscapeAscii { .. }") + f.debug_struct("EscapeAscii").finish_non_exhaustive() } } diff --git a/library/core/src/str/iter.rs b/library/core/src/str/iter.rs index 4eac017f9153c..7ebff180f9d73 100644 --- a/library/core/src/str/iter.rs +++ b/library/core/src/str/iter.rs @@ -1359,7 +1359,7 @@ pub struct EncodeUtf16<'a> { #[stable(feature = "collection_debug", since = "1.17.0")] impl fmt::Debug for EncodeUtf16<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.pad("EncodeUtf16 { .. }") + f.debug_struct("EncodeUtf16").finish_non_exhaustive() } } diff --git a/library/std/src/collections/hash/map.rs b/library/std/src/collections/hash/map.rs index 3dcc5cd2b5911..bdf559847cc85 100644 --- a/library/std/src/collections/hash/map.rs +++ b/library/std/src/collections/hash/map.rs @@ -2257,7 +2257,7 @@ where F: FnMut(&K, &mut V) -> bool, { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.pad("DrainFilter { .. }") + f.debug_struct("DrainFilter").finish_non_exhaustive() } } @@ -2957,7 +2957,7 @@ impl Default for RandomState { #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for RandomState { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.pad("RandomState { .. }") + f.debug_struct("RandomState").finish_non_exhaustive() } } diff --git a/library/std/src/collections/hash/set.rs b/library/std/src/collections/hash/set.rs index 8c801b9f1285d..5220c8ad70977 100644 --- a/library/std/src/collections/hash/set.rs +++ b/library/std/src/collections/hash/set.rs @@ -1533,7 +1533,7 @@ where F: FnMut(&K) -> bool, { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.pad("DrainFilter { .. }") + f.debug_struct("DrainFilter").finish_non_exhaustive() } } diff --git a/library/std/src/env.rs b/library/std/src/env.rs index 9763a2da34151..8f8d4e3a89832 100644 --- a/library/std/src/env.rs +++ b/library/std/src/env.rs @@ -154,7 +154,7 @@ impl Iterator for Vars { #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for Vars { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.pad("Vars { .. }") + f.debug_struct("Vars").finish_non_exhaustive() } } @@ -172,7 +172,7 @@ impl Iterator for VarsOs { #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for VarsOs { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.pad("VarsOs { .. }") + f.debug_struct("VarOs").finish_non_exhaustive() } } @@ -419,7 +419,7 @@ impl<'a> Iterator for SplitPaths<'a> { #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for SplitPaths<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.pad("SplitPaths { .. }") + f.debug_struct("SplitPaths").finish_non_exhaustive() } } diff --git a/library/std/src/io/stdio.rs b/library/std/src/io/stdio.rs index 1e72c9e0611ea..c2e0b24ba8327 100644 --- a/library/std/src/io/stdio.rs +++ b/library/std/src/io/stdio.rs @@ -373,7 +373,7 @@ impl Stdin { #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for Stdin { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.pad("Stdin { .. }") + f.debug_struct("Stdin").finish_non_exhaustive() } } @@ -467,7 +467,7 @@ impl BufRead for StdinLock<'_> { #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for StdinLock<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.pad("StdinLock { .. }") + f.debug_struct("StdinLock").finish_non_exhaustive() } } @@ -607,7 +607,7 @@ impl Stdout { #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for Stdout { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.pad("Stdout { .. }") + f.debug_struct("Stdout").finish_non_exhaustive() } } @@ -689,7 +689,7 @@ impl Write for StdoutLock<'_> { #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for StdoutLock<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.pad("StdoutLock { .. }") + f.debug_struct("StdoutLock").finish_non_exhaustive() } } @@ -804,7 +804,7 @@ impl Stderr { #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for Stderr { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.pad("Stderr { .. }") + f.debug_struct("Stderr").finish_non_exhaustive() } } @@ -886,7 +886,7 @@ impl Write for StderrLock<'_> { #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for StderrLock<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.pad("StderrLock { .. }") + f.debug_struct("StderrLock").finish_non_exhaustive() } } diff --git a/library/std/src/io/util.rs b/library/std/src/io/util.rs index f472361f916db..73f2f3eb3f5dc 100644 --- a/library/std/src/io/util.rs +++ b/library/std/src/io/util.rs @@ -78,7 +78,7 @@ impl Seek for Empty { #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for Empty { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.pad("Empty { .. }") + f.debug_struct("Empty").finish_non_exhaustive() } } @@ -150,7 +150,7 @@ impl Read for Repeat { #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for Repeat { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.pad("Repeat { .. }") + f.debug_struct("Repeat").finish_non_exhaustive() } } @@ -236,6 +236,6 @@ impl Write for &Sink { #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for Sink { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.pad("Sink { .. }") + f.debug_struct("Sink").finish_non_exhaustive() } } diff --git a/library/std/src/process.rs b/library/std/src/process.rs index 5690de681cab9..931b3b600a302 100644 --- a/library/std/src/process.rs +++ b/library/std/src/process.rs @@ -312,7 +312,7 @@ impl FromInner<AnonPipe> for ChildStdin { #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for ChildStdin { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.pad("ChildStdin { .. }") + f.debug_struct("ChildStdin").finish_non_exhaustive() } } @@ -373,7 +373,7 @@ impl FromInner<AnonPipe> for ChildStdout { #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for ChildStdout { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.pad("ChildStdout { .. }") + f.debug_struct("ChildStdout").finish_non_exhaustive() } } @@ -434,7 +434,7 @@ impl FromInner<AnonPipe> for ChildStderr { #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for ChildStderr { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.pad("ChildStderr { .. }") + f.debug_struct("ChildStderr").finish_non_exhaustive() } } @@ -1257,7 +1257,7 @@ impl FromInner<imp::Stdio> for Stdio { #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for Stdio { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.pad("Stdio { .. }") + f.debug_struct("Stdio").finish_non_exhaustive() } } diff --git a/library/std/src/sync/barrier.rs b/library/std/src/sync/barrier.rs index eab26b6c7150c..a17b82f82e8c2 100644 --- a/library/std/src/sync/barrier.rs +++ b/library/std/src/sync/barrier.rs @@ -60,7 +60,7 @@ pub struct BarrierWaitResult(bool); #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for Barrier { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.pad("Barrier { .. }") + f.debug_struct("Barrier").finish_non_exhaustive() } } diff --git a/library/std/src/sync/condvar.rs b/library/std/src/sync/condvar.rs index ffc1e57f4e03f..60be63c9543fa 100644 --- a/library/std/src/sync/condvar.rs +++ b/library/std/src/sync/condvar.rs @@ -548,7 +548,7 @@ impl Condvar { #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for Condvar { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.pad("Condvar { .. }") + f.debug_struct("Condvar").finish_non_exhaustive() } } diff --git a/library/std/src/sync/mpsc/mod.rs b/library/std/src/sync/mpsc/mod.rs index c8f0a6b99fe6b..ea1d598d26461 100644 --- a/library/std/src/sync/mpsc/mod.rs +++ b/library/std/src/sync/mpsc/mod.rs @@ -1477,7 +1477,7 @@ impl<T> fmt::Debug for Receiver<T> { #[stable(feature = "rust1", since = "1.0.0")] impl<T> fmt::Debug for SendError<T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - "SendError(..)".fmt(f) + f.debug_struct("SendError").finish_non_exhaustive() } } diff --git a/library/std/src/sync/once.rs b/library/std/src/sync/once.rs index a24a5cb2ae39f..6da6c18e47799 100644 --- a/library/std/src/sync/once.rs +++ b/library/std/src/sync/once.rs @@ -481,7 +481,7 @@ fn wait(state_and_queue: &AtomicUsize, mut current_state: usize) { #[stable(feature = "std_debug", since = "1.16.0")] impl fmt::Debug for Once { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.pad("Once { .. }") + f.debug_struct("Once").finish_non_exhaustive() } } diff --git a/library/std/src/sys_common/poison.rs b/library/std/src/sys_common/poison.rs index 2ab2c700a1bf1..1f71187f1b466 100644 --- a/library/std/src/sys_common/poison.rs +++ b/library/std/src/sys_common/poison.rs @@ -127,7 +127,7 @@ pub type TryLockResult<Guard> = Result<Guard, TryLockError<Guard>>; #[stable(feature = "rust1", since = "1.0.0")] impl<T> fmt::Debug for PoisonError<T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - "PoisonError { inner: .. }".fmt(f) + f.debug_struct("PoisonError").finish_non_exhaustive() } } diff --git a/library/std/src/thread/local.rs b/library/std/src/thread/local.rs index 37525e50604dd..f0355aa1e1606 100644 --- a/library/std/src/thread/local.rs +++ b/library/std/src/thread/local.rs @@ -100,7 +100,7 @@ pub struct LocalKey<T: 'static> { #[stable(feature = "std_debug", since = "1.16.0")] impl<T: 'static> fmt::Debug for LocalKey<T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.pad("LocalKey { .. }") + f.debug_struct("LocalKey").finish_non_exhaustive() } } @@ -472,7 +472,7 @@ pub mod statik { impl<T> fmt::Debug for Key<T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.pad("Key { .. }") + f.debug_struct("Key").finish_non_exhaustive() } } @@ -537,7 +537,7 @@ pub mod fast { impl<T> fmt::Debug for Key<T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.pad("Key { .. }") + f.debug_struct("Key").finish_non_exhaustive() } } @@ -651,7 +651,7 @@ pub mod os { impl<T> fmt::Debug for Key<T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.pad("Key { .. }") + f.debug_struct("Key").finish_non_exhaustive() } } diff --git a/library/std/src/thread/mod.rs b/library/std/src/thread/mod.rs index 54e39f762741f..30d8c2a1b6fa0 100644 --- a/library/std/src/thread/mod.rs +++ b/library/std/src/thread/mod.rs @@ -1413,7 +1413,7 @@ impl<T> IntoInner<imp::Thread> for JoinHandle<T> { #[stable(feature = "std_debug", since = "1.16.0")] impl<T> fmt::Debug for JoinHandle<T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.pad("JoinHandle { .. }") + f.debug_struct("JoinHandle").finish_non_exhaustive() } } From fdae75738b8d9b1df6cf1f24de9a40ac12046dd8 Mon Sep 17 00:00:00 2001 From: Christiaan Dirkx <christiaan@dirkx.email> Date: Wed, 21 Apr 2021 14:51:04 +0200 Subject: [PATCH 25/28] Change the `Debug` impl of `Any` and `UnsafeCell` to use `finish_non_exhaustive` --- library/core/src/any.rs | 6 +++--- library/core/src/fmt/mod.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/library/core/src/any.rs b/library/core/src/any.rs index 339e874558c51..5e1725cfc7a63 100644 --- a/library/core/src/any.rs +++ b/library/core/src/any.rs @@ -141,7 +141,7 @@ impl<T: 'static + ?Sized> Any for T { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for dyn Any { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("Any").finish() + f.debug_struct("Any").finish_non_exhaustive() } } @@ -151,14 +151,14 @@ impl fmt::Debug for dyn Any { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for dyn Any + Send { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("Any").finish() + f.debug_struct("Any").finish_non_exhaustive() } } #[stable(feature = "any_send_sync_methods", since = "1.28.0")] impl fmt::Debug for dyn Any + Send + Sync { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("Any").finish() + f.debug_struct("Any").finish_non_exhaustive() } } diff --git a/library/core/src/fmt/mod.rs b/library/core/src/fmt/mod.rs index 0edb7da571725..87042d95fbef0 100644 --- a/library/core/src/fmt/mod.rs +++ b/library/core/src/fmt/mod.rs @@ -2270,7 +2270,7 @@ impl<T: ?Sized + Debug> Debug for RefMut<'_, T> { #[stable(feature = "core_impl_debug", since = "1.9.0")] impl<T: ?Sized> Debug for UnsafeCell<T> { fn fmt(&self, f: &mut Formatter<'_>) -> Result { - f.debug_struct("UnsafeCell").finish() + f.debug_struct("UnsafeCell").finish_non_exhaustive() } } From fccc75cf8299158125f5785855d7235a178434d7 Mon Sep 17 00:00:00 2001 From: Christiaan Dirkx <christiaan@dirkx.email> Date: Wed, 21 Apr 2021 15:45:41 +0200 Subject: [PATCH 26/28] Fix `alloc::test::test_show` --- library/alloc/src/tests.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/library/alloc/src/tests.rs b/library/alloc/src/tests.rs index bddaab0c76188..b4741c35c583f 100644 --- a/library/alloc/src/tests.rs +++ b/library/alloc/src/tests.rs @@ -49,17 +49,17 @@ fn test_show() { let b = Box::new(Test) as Box<dyn Any>; let a_str = format!("{:?}", a); let b_str = format!("{:?}", b); - assert_eq!(a_str, "Any"); - assert_eq!(b_str, "Any"); + assert_eq!(a_str, "Any { .. }"); + assert_eq!(b_str, "Any { .. }"); static EIGHT: usize = 8; static TEST: Test = Test; let a = &EIGHT as &dyn Any; let b = &TEST as &dyn Any; let s = format!("{:?}", a); - assert_eq!(s, "Any"); + assert_eq!(s, "Any { .. }"); let s = format!("{:?}", b); - assert_eq!(s, "Any"); + assert_eq!(s, "Any { .. }"); } #[test] From aa46f08abde35740fc41b0e4f2d83d38b597a3d5 Mon Sep 17 00:00:00 2001 From: Christiaan Dirkx <christiaan@dirkx.email> Date: Wed, 21 Apr 2021 16:06:32 +0200 Subject: [PATCH 27/28] Apply suggestions from code review --- library/std/src/sys/unix/process/process_common.rs | 2 +- library/std/src/sys/unix/process/process_vxworks.rs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/library/std/src/sys/unix/process/process_common.rs b/library/std/src/sys/unix/process/process_common.rs index 1ef6df0fe95c6..b9dcc4e4b9e38 100644 --- a/library/std/src/sys/unix/process/process_common.rs +++ b/library/std/src/sys/unix/process/process_common.rs @@ -223,7 +223,7 @@ impl Command { pub fn get_groups(&self) -> Option<&[gid_t]> { self.groups.as_deref() } - #[allow(dead_code)] + pub fn get_closures(&mut self) -> &mut Vec<Box<dyn FnMut() -> io::Result<()> + Send + Sync>> { &mut self.closures } diff --git a/library/std/src/sys/unix/process/process_vxworks.rs b/library/std/src/sys/unix/process/process_vxworks.rs index 68467da284f23..eecdb624b9cfa 100644 --- a/library/std/src/sys/unix/process/process_vxworks.rs +++ b/library/std/src/sys/unix/process/process_vxworks.rs @@ -18,7 +18,6 @@ impl Command { needs_stdin: bool, ) -> io::Result<(Process, StdioPipes)> { use crate::sys::cvt_r; - // const CLOEXEC_MSG_FOOTER: &'static [u8] = b"NOEX"; let envp = self.capture_env(); if self.saw_nul() { @@ -61,6 +60,9 @@ impl Command { t!(cvt(libc::chdir(cwd.as_ptr()))); } + // pre_exec closures are ignored on VxWorks + let _ = self.get_closures(); + let c_envp = envp .as_ref() .map(|c| c.as_ptr()) From f1f3069a98b4c391b231ae4a9a9f02a8b46f56d2 Mon Sep 17 00:00:00 2001 From: Mara Bos <m-ou.se@m-ou.se> Date: Wed, 21 Apr 2021 21:54:39 +0200 Subject: [PATCH 28/28] Remove `delete` alias from `mem::drop`. --- library/core/src/mem/mod.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/library/core/src/mem/mod.rs b/library/core/src/mem/mod.rs index 446d72f1d32e4..5bf47c3951da2 100644 --- a/library/core/src/mem/mod.rs +++ b/library/core/src/mem/mod.rs @@ -886,7 +886,6 @@ pub const fn replace<T>(dest: &mut T, src: T) -> T { /// ``` /// /// [`RefCell`]: crate::cell::RefCell -#[doc(alias = "delete")] #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub fn drop<T>(_x: T) {}