From 4f212f08cf0edb1fe990c8ca30fef09c27606682 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Mon, 9 May 2022 11:12:32 +0200 Subject: [PATCH] Use Rust 2021 prelude in std itself. --- library/std/src/collections/hash/map.rs | 2 +- library/std/src/collections/hash/set.rs | 2 +- library/std/src/ffi/os_str.rs | 2 +- library/std/src/io/cursor.rs | 2 -- library/std/src/io/mod.rs | 1 - library/std/src/lib.rs | 2 +- library/std/src/net/addr.rs | 1 - library/std/src/net/parser.rs | 1 - library/std/src/os/unix/net/ancillary.rs | 1 - library/std/src/os/unix/net/tests.rs | 1 - library/std/src/os/windows/io/handle.rs | 1 - library/std/src/sys/hermit/net.rs | 1 - library/std/src/sys/hermit/time.rs | 1 - library/std/src/sys/itron/spin.rs | 1 - library/std/src/sys/itron/thread.rs | 1 - library/std/src/sys/itron/time.rs | 2 +- library/std/src/sys/sgx/abi/usercalls/mod.rs | 1 - library/std/src/sys/sgx/net.rs | 1 - library/std/src/sys/solid/time.rs | 2 +- library/std/src/sys/unix/fs.rs | 1 - library/std/src/sys/unix/futex.rs | 3 --- library/std/src/sys/unix/kernel_copy.rs | 1 - library/std/src/sys/unix/l4re.rs | 1 - library/std/src/sys/unix/process/process_fuchsia.rs | 1 - library/std/src/sys/unix/process/process_unix.rs | 1 - library/std/src/sys/unix/process/process_unsupported.rs | 1 - library/std/src/sys/unix/process/process_vxworks.rs | 1 - library/std/src/sys/unix/process/zircon.rs | 1 - library/std/src/sys/unix/time.rs | 2 -- library/std/src/sys/unsupported/net.rs | 1 - library/std/src/sys/wasi/net.rs | 1 - library/std/src/sys/wasm/atomics/futex.rs | 1 - library/std/src/sys/windows/fs.rs | 1 - library/std/src/sys/windows/process.rs | 1 - library/std/src/sys/windows/thread.rs | 1 - library/std/src/sys/windows/thread_parker.rs | 1 - library/std/src/sys/windows/time.rs | 1 - library/std/src/sys_common/net.rs | 1 - library/std/src/sys_common/wtf8.rs | 2 +- 39 files changed, 7 insertions(+), 43 deletions(-) diff --git a/library/std/src/collections/hash/map.rs b/library/std/src/collections/hash/map.rs index e38368790e69a..977714281fbbe 100644 --- a/library/std/src/collections/hash/map.rs +++ b/library/std/src/collections/hash/map.rs @@ -12,7 +12,7 @@ use crate::collections::TryReserveErrorKind; use crate::fmt::{self, Debug}; #[allow(deprecated)] use crate::hash::{BuildHasher, Hash, Hasher, SipHasher13}; -use crate::iter::{FromIterator, FusedIterator}; +use crate::iter::FusedIterator; use crate::ops::Index; use crate::sys; diff --git a/library/std/src/collections/hash/set.rs b/library/std/src/collections/hash/set.rs index fa471a3c3f323..13bba0a6fd892 100644 --- a/library/std/src/collections/hash/set.rs +++ b/library/std/src/collections/hash/set.rs @@ -7,7 +7,7 @@ use crate::borrow::Borrow; use crate::collections::TryReserveError; use crate::fmt; use crate::hash::{BuildHasher, Hash}; -use crate::iter::{Chain, FromIterator, FusedIterator}; +use crate::iter::{Chain, FusedIterator}; use crate::ops::{BitAnd, BitOr, BitXor, Sub}; use super::map::{map_try_reserve_error, RandomState}; diff --git a/library/std/src/ffi/os_str.rs b/library/std/src/ffi/os_str.rs index dd316bdb2c6ce..810d85554aa16 100644 --- a/library/std/src/ffi/os_str.rs +++ b/library/std/src/ffi/os_str.rs @@ -6,7 +6,7 @@ use crate::cmp; use crate::collections::TryReserveError; use crate::fmt; use crate::hash::{Hash, Hasher}; -use crate::iter::{Extend, FromIterator}; +use crate::iter::Extend; use crate::ops; use crate::rc::Rc; use crate::str::FromStr; diff --git a/library/std/src/io/cursor.rs b/library/std/src/io/cursor.rs index 57f1d628f6ad9..0ce6ae00ee250 100644 --- a/library/std/src/io/cursor.rs +++ b/library/std/src/io/cursor.rs @@ -7,8 +7,6 @@ use crate::alloc::Allocator; use crate::cmp; use crate::io::{self, ErrorKind, IoSlice, IoSliceMut, ReadBuf, SeekFrom}; -use core::convert::TryInto; - /// A `Cursor` wraps an in-memory buffer and provides it with a /// [`Seek`] implementation. /// diff --git a/library/std/src/io/mod.rs b/library/std/src/io/mod.rs index cd2197fca350e..94812e3fe3b2c 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -252,7 +252,6 @@ mod tests; use crate::cmp; -use crate::convert::TryInto; use crate::fmt; use crate::mem::replace; use crate::ops::{Deref, DerefMut}; diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index c394865d886e8..519f050d2fcbe 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -345,7 +345,7 @@ // to import the prelude implicitly when building crates that depend on std. #[prelude_import] #[allow(unused)] -use prelude::v1::*; +use prelude::rust_2021::*; // Access to Bencher, etc. #[cfg(test)] diff --git a/library/std/src/net/addr.rs b/library/std/src/net/addr.rs index 201cbf3f08d28..81dd042425c1d 100644 --- a/library/std/src/net/addr.rs +++ b/library/std/src/net/addr.rs @@ -2,7 +2,6 @@ mod tests; use crate::cmp::Ordering; -use crate::convert::TryInto; use crate::fmt; use crate::hash; use crate::io::{self, Write}; diff --git a/library/std/src/net/parser.rs b/library/std/src/net/parser.rs index fb292ed29a18a..069b660998559 100644 --- a/library/std/src/net/parser.rs +++ b/library/std/src/net/parser.rs @@ -6,7 +6,6 @@ #[cfg(test)] mod tests; -use crate::convert::TryInto as _; use crate::error::Error; use crate::fmt; use crate::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6}; diff --git a/library/std/src/os/unix/net/ancillary.rs b/library/std/src/os/unix/net/ancillary.rs index 658c79896eb2e..9e31b8b32a197 100644 --- a/library/std/src/os/unix/net/ancillary.rs +++ b/library/std/src/os/unix/net/ancillary.rs @@ -1,5 +1,4 @@ use super::{sockaddr_un, SocketAddr}; -use crate::convert::TryFrom; use crate::io::{self, IoSlice, IoSliceMut}; use crate::marker::PhantomData; use crate::mem::{size_of, zeroed}; diff --git a/library/std/src/os/unix/net/tests.rs b/library/std/src/os/unix/net/tests.rs index aa0df61c1920d..c1f11c56b8f65 100644 --- a/library/std/src/os/unix/net/tests.rs +++ b/library/std/src/os/unix/net/tests.rs @@ -10,7 +10,6 @@ use crate::io::{self, ErrorKind, IoSlice, IoSliceMut}; target_os = "netbsd", target_os = "openbsd", ))] -use crate::iter::FromIterator; #[cfg(any( target_os = "android", target_os = "dragonfly", diff --git a/library/std/src/os/windows/io/handle.rs b/library/std/src/os/windows/io/handle.rs index f3d7be3f95c6b..41758f2ced111 100644 --- a/library/std/src/os/windows/io/handle.rs +++ b/library/std/src/os/windows/io/handle.rs @@ -3,7 +3,6 @@ #![unstable(feature = "io_safety", issue = "87074")] use super::raw::{AsRawHandle, FromRawHandle, IntoRawHandle, RawHandle}; -use crate::convert::TryFrom; use crate::fmt; use crate::fs; use crate::io; diff --git a/library/std/src/sys/hermit/net.rs b/library/std/src/sys/hermit/net.rs index f65fd8e53bdc9..74547617150b0 100644 --- a/library/std/src/sys/hermit/net.rs +++ b/library/std/src/sys/hermit/net.rs @@ -1,4 +1,3 @@ -use crate::convert::TryFrom; use crate::fmt; use crate::io::{self, ErrorKind, IoSlice, IoSliceMut}; use crate::net::{IpAddr, Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr}; diff --git a/library/std/src/sys/hermit/time.rs b/library/std/src/sys/hermit/time.rs index 27173de630729..c17e6c8af6276 100644 --- a/library/std/src/sys/hermit/time.rs +++ b/library/std/src/sys/hermit/time.rs @@ -1,7 +1,6 @@ #![allow(dead_code)] use crate::cmp::Ordering; -use crate::convert::TryInto; use crate::sys::hermit::abi; use crate::sys::hermit::abi::timespec; use crate::sys::hermit::abi::{CLOCK_MONOTONIC, CLOCK_REALTIME, NSEC_PER_SEC}; diff --git a/library/std/src/sys/itron/spin.rs b/library/std/src/sys/itron/spin.rs index d0149d1f037db..44d409444bca4 100644 --- a/library/std/src/sys/itron/spin.rs +++ b/library/std/src/sys/itron/spin.rs @@ -1,7 +1,6 @@ use super::abi; use crate::{ cell::UnsafeCell, - convert::TryFrom, mem::MaybeUninit, sync::atomic::{AtomicBool, AtomicUsize, Ordering}, }; diff --git a/library/std/src/sys/itron/thread.rs b/library/std/src/sys/itron/thread.rs index 5b718a460dfa9..d28f57f33be20 100644 --- a/library/std/src/sys/itron/thread.rs +++ b/library/std/src/sys/itron/thread.rs @@ -8,7 +8,6 @@ use super::{ }; use crate::{ cell::UnsafeCell, - convert::TryFrom, ffi::CStr, hint, io, mem::ManuallyDrop, diff --git a/library/std/src/sys/itron/time.rs b/library/std/src/sys/itron/time.rs index 25f13ee441aca..427ea0d80e107 100644 --- a/library/std/src/sys/itron/time.rs +++ b/library/std/src/sys/itron/time.rs @@ -1,5 +1,5 @@ use super::{abi, error::expect_success}; -use crate::{convert::TryInto, mem::MaybeUninit, time::Duration}; +use crate::{mem::MaybeUninit, time::Duration}; #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)] pub struct Instant(abi::SYSTIM); diff --git a/library/std/src/sys/sgx/abi/usercalls/mod.rs b/library/std/src/sys/sgx/abi/usercalls/mod.rs index 4030355f13518..2f99abba77667 100644 --- a/library/std/src/sys/sgx/abi/usercalls/mod.rs +++ b/library/std/src/sys/sgx/abi/usercalls/mod.rs @@ -1,5 +1,4 @@ use crate::cmp; -use crate::convert::TryFrom; use crate::io::{Error as IoError, ErrorKind, IoSlice, IoSliceMut, Result as IoResult}; use crate::sys::rand::rdrand64; use crate::time::{Duration, Instant}; diff --git a/library/std/src/sys/sgx/net.rs b/library/std/src/sys/sgx/net.rs index feb0b62dcd1f7..1d899525081b9 100644 --- a/library/std/src/sys/sgx/net.rs +++ b/library/std/src/sys/sgx/net.rs @@ -1,4 +1,3 @@ -use crate::convert::TryFrom; use crate::error; use crate::fmt; use crate::io::{self, IoSlice, IoSliceMut}; diff --git a/library/std/src/sys/solid/time.rs b/library/std/src/sys/solid/time.rs index ab988be24442a..ce31cb45a69a1 100644 --- a/library/std/src/sys/solid/time.rs +++ b/library/std/src/sys/solid/time.rs @@ -1,5 +1,5 @@ use super::{abi, error::expect_success}; -use crate::{convert::TryInto, mem::MaybeUninit, time::Duration}; +use crate::{mem::MaybeUninit, time::Duration}; pub use super::itron::time::Instant; diff --git a/library/std/src/sys/unix/fs.rs b/library/std/src/sys/unix/fs.rs index 61fb2814018e0..5d0fb07900326 100644 --- a/library/std/src/sys/unix/fs.rs +++ b/library/std/src/sys/unix/fs.rs @@ -943,7 +943,6 @@ impl File { } pub fn truncate(&self, size: u64) -> io::Result<()> { - use crate::convert::TryInto; let size: off64_t = size.try_into().map_err(|e| io::Error::new(io::ErrorKind::InvalidInput, e))?; cvt_r(|| unsafe { ftruncate64(self.as_raw_fd(), size) }).map(drop) diff --git a/library/std/src/sys/unix/futex.rs b/library/std/src/sys/unix/futex.rs index c1966d6707856..8d5ad18997d07 100644 --- a/library/std/src/sys/unix/futex.rs +++ b/library/std/src/sys/unix/futex.rs @@ -136,7 +136,6 @@ pub fn futex_wake_all(futex: &AtomicU32) { #[cfg(target_os = "openbsd")] pub fn futex_wait(futex: &AtomicU32, expected: u32, timeout: Option) -> bool { - use crate::convert::TryInto; use crate::ptr::{null, null_mut}; let timespec = timeout.and_then(|d| { Some(libc::timespec { @@ -185,8 +184,6 @@ pub fn futex_wake_all(futex: &AtomicU32) { #[cfg(target_os = "dragonfly")] pub fn futex_wait(futex: &AtomicU32, expected: u32, timeout: Option) -> bool { - use crate::convert::TryFrom; - // A timeout of 0 means infinite. // We round smaller timeouts up to 1 millisecond. // Overflows are rounded up to an infinite timeout. diff --git a/library/std/src/sys/unix/kernel_copy.rs b/library/std/src/sys/unix/kernel_copy.rs index e85e4c5d618ce..8f7abb55e2376 100644 --- a/library/std/src/sys/unix/kernel_copy.rs +++ b/library/std/src/sys/unix/kernel_copy.rs @@ -45,7 +45,6 @@ //! * complexity use crate::cmp::min; -use crate::convert::TryInto; use crate::fs::{File, Metadata}; use crate::io::copy::generic_copy; use crate::io::{ diff --git a/library/std/src/sys/unix/l4re.rs b/library/std/src/sys/unix/l4re.rs index f052d8f7f055f..9967588939ac9 100644 --- a/library/std/src/sys/unix/l4re.rs +++ b/library/std/src/sys/unix/l4re.rs @@ -9,7 +9,6 @@ macro_rules! unimpl { pub mod net { #![allow(warnings)] - use crate::convert::TryFrom; use crate::fmt; use crate::io::{self, IoSlice, IoSliceMut}; use crate::net::{Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr}; diff --git a/library/std/src/sys/unix/process/process_fuchsia.rs b/library/std/src/sys/unix/process/process_fuchsia.rs index e3347ab12a730..73f5d3a618bad 100644 --- a/library/std/src/sys/unix/process/process_fuchsia.rs +++ b/library/std/src/sys/unix/process/process_fuchsia.rs @@ -1,4 +1,3 @@ -use crate::convert::{TryFrom, TryInto}; use crate::fmt; use crate::io; use crate::mem; diff --git a/library/std/src/sys/unix/process/process_unix.rs b/library/std/src/sys/unix/process/process_unix.rs index d48faaa88fb4f..23bb6d6c15f63 100644 --- a/library/std/src/sys/unix/process/process_unix.rs +++ b/library/std/src/sys/unix/process/process_unix.rs @@ -1,4 +1,3 @@ -use crate::convert::{TryFrom, TryInto}; use crate::fmt; use crate::io::{self, Error, ErrorKind}; use crate::mem; diff --git a/library/std/src/sys/unix/process/process_unsupported.rs b/library/std/src/sys/unix/process/process_unsupported.rs index bbabdf787d994..5db57ee9e9e18 100644 --- a/library/std/src/sys/unix/process/process_unsupported.rs +++ b/library/std/src/sys/unix/process/process_unsupported.rs @@ -1,4 +1,3 @@ -use crate::convert::{TryFrom, TryInto}; use crate::fmt; use crate::io; use crate::io::ErrorKind; diff --git a/library/std/src/sys/unix/process/process_vxworks.rs b/library/std/src/sys/unix/process/process_vxworks.rs index 016bc20ec0a47..200ef67196798 100644 --- a/library/std/src/sys/unix/process/process_vxworks.rs +++ b/library/std/src/sys/unix/process/process_vxworks.rs @@ -1,4 +1,3 @@ -use crate::convert::{TryFrom, TryInto}; use crate::fmt; use crate::io::{self, Error, ErrorKind}; use crate::num::NonZeroI32; diff --git a/library/std/src/sys/unix/process/zircon.rs b/library/std/src/sys/unix/process/zircon.rs index 4dfa2b4ff1eb4..2e596486f9c86 100644 --- a/library/std/src/sys/unix/process/zircon.rs +++ b/library/std/src/sys/unix/process/zircon.rs @@ -1,6 +1,5 @@ #![allow(non_camel_case_types, unused)] -use crate::convert::TryInto; use crate::io; use crate::mem::MaybeUninit; use crate::os::raw::c_char; diff --git a/library/std/src/sys/unix/time.rs b/library/std/src/sys/unix/time.rs index ac8355188bb3c..333182bdad4de 100644 --- a/library/std/src/sys/unix/time.rs +++ b/library/std/src/sys/unix/time.rs @@ -2,7 +2,6 @@ use crate::fmt; use crate::time::Duration; pub use self::inner::Instant; -use crate::convert::TryInto; const NSEC_PER_SEC: u64 = 1_000_000_000; pub const UNIX_EPOCH: SystemTime = SystemTime { t: Timespec::zero() }; @@ -127,7 +126,6 @@ impl Timespec { } pub fn to_timespec(&self) -> Option { - use crate::convert::TryInto; Some(libc::timespec { tv_sec: self.tv_sec.try_into().ok()?, tv_nsec: self.tv_nsec.try_into().ok()?, diff --git a/library/std/src/sys/unsupported/net.rs b/library/std/src/sys/unsupported/net.rs index dbb6ce22c22de..360115d503374 100644 --- a/library/std/src/sys/unsupported/net.rs +++ b/library/std/src/sys/unsupported/net.rs @@ -1,4 +1,3 @@ -use crate::convert::TryFrom; use crate::fmt; use crate::io::{self, IoSlice, IoSliceMut}; use crate::net::{Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr}; diff --git a/library/std/src/sys/wasi/net.rs b/library/std/src/sys/wasi/net.rs index c66e0e4d328ad..937b1b850e7ba 100644 --- a/library/std/src/sys/wasi/net.rs +++ b/library/std/src/sys/wasi/net.rs @@ -2,7 +2,6 @@ use super::err2io; use super::fd::WasiFd; -use crate::convert::TryFrom; use crate::fmt; use crate::io::{self, IoSlice, IoSliceMut}; use crate::net::{Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr}; diff --git a/library/std/src/sys/wasm/atomics/futex.rs b/library/std/src/sys/wasm/atomics/futex.rs index 11413ba3bf564..f4fbe9f48554b 100644 --- a/library/std/src/sys/wasm/atomics/futex.rs +++ b/library/std/src/sys/wasm/atomics/futex.rs @@ -1,5 +1,4 @@ use crate::arch::wasm32; -use crate::convert::TryInto; use crate::sync::atomic::AtomicU32; use crate::time::Duration; diff --git a/library/std/src/sys/windows/fs.rs b/library/std/src/sys/windows/fs.rs index 95903899297b6..157d8a044d3cd 100644 --- a/library/std/src/sys/windows/fs.rs +++ b/library/std/src/sys/windows/fs.rs @@ -1,6 +1,5 @@ use crate::os::windows::prelude::*; -use crate::convert::TryInto; use crate::ffi::OsString; use crate::fmt; use crate::io::{self, Error, IoSlice, IoSliceMut, ReadBuf, SeekFrom}; diff --git a/library/std/src/sys/windows/process.rs b/library/std/src/sys/windows/process.rs index cc29d1a72fbf4..224063cad3645 100644 --- a/library/std/src/sys/windows/process.rs +++ b/library/std/src/sys/windows/process.rs @@ -5,7 +5,6 @@ mod tests; use crate::cmp; use crate::collections::BTreeMap; -use crate::convert::{TryFrom, TryInto}; use crate::env; use crate::env::consts::{EXE_EXTENSION, EXE_SUFFIX}; use crate::ffi::{OsStr, OsString}; diff --git a/library/std/src/sys/windows/thread.rs b/library/std/src/sys/windows/thread.rs index 2f469513eb4fd..c5c9e97e646fb 100644 --- a/library/std/src/sys/windows/thread.rs +++ b/library/std/src/sys/windows/thread.rs @@ -1,4 +1,3 @@ -use crate::convert::TryInto; use crate::ffi::CStr; use crate::io; use crate::num::NonZeroUsize; diff --git a/library/std/src/sys/windows/thread_parker.rs b/library/std/src/sys/windows/thread_parker.rs index 5144834447503..d876e0f6f3c03 100644 --- a/library/std/src/sys/windows/thread_parker.rs +++ b/library/std/src/sys/windows/thread_parker.rs @@ -57,7 +57,6 @@ // [3]: https://docs.microsoft.com/en-us/archive/msdn-magazine/2012/november/windows-with-c-the-evolution-of-synchronization-in-windows-and-c // [4]: Windows Internals, Part 1, ISBN 9780735671300 -use crate::convert::TryFrom; use crate::pin::Pin; use crate::ptr; use crate::sync::atomic::{ diff --git a/library/std/src/sys/windows/time.rs b/library/std/src/sys/windows/time.rs index a04908b541cdb..8f46781c75340 100644 --- a/library/std/src/sys/windows/time.rs +++ b/library/std/src/sys/windows/time.rs @@ -1,5 +1,4 @@ use crate::cmp::Ordering; -use crate::convert::TryInto; use crate::fmt; use crate::mem; use crate::sys::c; diff --git a/library/std/src/sys_common/net.rs b/library/std/src/sys_common/net.rs index 3b7cdd55a081c..05425f4a3622c 100644 --- a/library/std/src/sys_common/net.rs +++ b/library/std/src/sys_common/net.rs @@ -2,7 +2,6 @@ mod tests; use crate::cmp; -use crate::convert::{TryFrom, TryInto}; use crate::ffi::CString; use crate::fmt; use crate::io::{self, ErrorKind, IoSlice, IoSliceMut}; diff --git a/library/std/src/sys_common/wtf8.rs b/library/std/src/sys_common/wtf8.rs index 7d66973bed6f5..57fa4989358a4 100644 --- a/library/std/src/sys_common/wtf8.rs +++ b/library/std/src/sys_common/wtf8.rs @@ -25,7 +25,7 @@ use crate::char; use crate::collections::TryReserveError; use crate::fmt; use crate::hash::{Hash, Hasher}; -use crate::iter::{FromIterator, FusedIterator}; +use crate::iter::FusedIterator; use crate::mem; use crate::ops; use crate::rc::Rc;