1
Fork 0

Use Rust 2021 prelude in std itself.

This commit is contained in:
Mara Bos 2022-05-09 11:12:32 +02:00
parent 8a2fe75d0e
commit 4f212f08cf
39 changed files with 7 additions and 43 deletions

View file

@ -12,7 +12,7 @@ use crate::collections::TryReserveErrorKind;
use crate::fmt::{self, Debug}; use crate::fmt::{self, Debug};
#[allow(deprecated)] #[allow(deprecated)]
use crate::hash::{BuildHasher, Hash, Hasher, SipHasher13}; use crate::hash::{BuildHasher, Hash, Hasher, SipHasher13};
use crate::iter::{FromIterator, FusedIterator}; use crate::iter::FusedIterator;
use crate::ops::Index; use crate::ops::Index;
use crate::sys; use crate::sys;

View file

@ -7,7 +7,7 @@ use crate::borrow::Borrow;
use crate::collections::TryReserveError; use crate::collections::TryReserveError;
use crate::fmt; use crate::fmt;
use crate::hash::{BuildHasher, Hash}; use crate::hash::{BuildHasher, Hash};
use crate::iter::{Chain, FromIterator, FusedIterator}; use crate::iter::{Chain, FusedIterator};
use crate::ops::{BitAnd, BitOr, BitXor, Sub}; use crate::ops::{BitAnd, BitOr, BitXor, Sub};
use super::map::{map_try_reserve_error, RandomState}; use super::map::{map_try_reserve_error, RandomState};

View file

@ -6,7 +6,7 @@ use crate::cmp;
use crate::collections::TryReserveError; use crate::collections::TryReserveError;
use crate::fmt; use crate::fmt;
use crate::hash::{Hash, Hasher}; use crate::hash::{Hash, Hasher};
use crate::iter::{Extend, FromIterator}; use crate::iter::Extend;
use crate::ops; use crate::ops;
use crate::rc::Rc; use crate::rc::Rc;
use crate::str::FromStr; use crate::str::FromStr;

View file

@ -7,8 +7,6 @@ use crate::alloc::Allocator;
use crate::cmp; use crate::cmp;
use crate::io::{self, ErrorKind, IoSlice, IoSliceMut, ReadBuf, SeekFrom}; 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 /// A `Cursor` wraps an in-memory buffer and provides it with a
/// [`Seek`] implementation. /// [`Seek`] implementation.
/// ///

View file

@ -252,7 +252,6 @@
mod tests; mod tests;
use crate::cmp; use crate::cmp;
use crate::convert::TryInto;
use crate::fmt; use crate::fmt;
use crate::mem::replace; use crate::mem::replace;
use crate::ops::{Deref, DerefMut}; use crate::ops::{Deref, DerefMut};

View file

@ -345,7 +345,7 @@
// to import the prelude implicitly when building crates that depend on std. // to import the prelude implicitly when building crates that depend on std.
#[prelude_import] #[prelude_import]
#[allow(unused)] #[allow(unused)]
use prelude::v1::*; use prelude::rust_2021::*;
// Access to Bencher, etc. // Access to Bencher, etc.
#[cfg(test)] #[cfg(test)]

View file

@ -2,7 +2,6 @@
mod tests; mod tests;
use crate::cmp::Ordering; use crate::cmp::Ordering;
use crate::convert::TryInto;
use crate::fmt; use crate::fmt;
use crate::hash; use crate::hash;
use crate::io::{self, Write}; use crate::io::{self, Write};

View file

@ -6,7 +6,6 @@
#[cfg(test)] #[cfg(test)]
mod tests; mod tests;
use crate::convert::TryInto as _;
use crate::error::Error; use crate::error::Error;
use crate::fmt; use crate::fmt;
use crate::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6}; use crate::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6};

View file

@ -1,5 +1,4 @@
use super::{sockaddr_un, SocketAddr}; use super::{sockaddr_un, SocketAddr};
use crate::convert::TryFrom;
use crate::io::{self, IoSlice, IoSliceMut}; use crate::io::{self, IoSlice, IoSliceMut};
use crate::marker::PhantomData; use crate::marker::PhantomData;
use crate::mem::{size_of, zeroed}; use crate::mem::{size_of, zeroed};

View file

@ -10,7 +10,6 @@ use crate::io::{self, ErrorKind, IoSlice, IoSliceMut};
target_os = "netbsd", target_os = "netbsd",
target_os = "openbsd", target_os = "openbsd",
))] ))]
use crate::iter::FromIterator;
#[cfg(any( #[cfg(any(
target_os = "android", target_os = "android",
target_os = "dragonfly", target_os = "dragonfly",

View file

@ -3,7 +3,6 @@
#![unstable(feature = "io_safety", issue = "87074")] #![unstable(feature = "io_safety", issue = "87074")]
use super::raw::{AsRawHandle, FromRawHandle, IntoRawHandle, RawHandle}; use super::raw::{AsRawHandle, FromRawHandle, IntoRawHandle, RawHandle};
use crate::convert::TryFrom;
use crate::fmt; use crate::fmt;
use crate::fs; use crate::fs;
use crate::io; use crate::io;

View file

@ -1,4 +1,3 @@
use crate::convert::TryFrom;
use crate::fmt; use crate::fmt;
use crate::io::{self, ErrorKind, IoSlice, IoSliceMut}; use crate::io::{self, ErrorKind, IoSlice, IoSliceMut};
use crate::net::{IpAddr, Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr}; use crate::net::{IpAddr, Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr};

View file

@ -1,7 +1,6 @@
#![allow(dead_code)] #![allow(dead_code)]
use crate::cmp::Ordering; use crate::cmp::Ordering;
use crate::convert::TryInto;
use crate::sys::hermit::abi; use crate::sys::hermit::abi;
use crate::sys::hermit::abi::timespec; use crate::sys::hermit::abi::timespec;
use crate::sys::hermit::abi::{CLOCK_MONOTONIC, CLOCK_REALTIME, NSEC_PER_SEC}; use crate::sys::hermit::abi::{CLOCK_MONOTONIC, CLOCK_REALTIME, NSEC_PER_SEC};

View file

@ -1,7 +1,6 @@
use super::abi; use super::abi;
use crate::{ use crate::{
cell::UnsafeCell, cell::UnsafeCell,
convert::TryFrom,
mem::MaybeUninit, mem::MaybeUninit,
sync::atomic::{AtomicBool, AtomicUsize, Ordering}, sync::atomic::{AtomicBool, AtomicUsize, Ordering},
}; };

View file

@ -8,7 +8,6 @@ use super::{
}; };
use crate::{ use crate::{
cell::UnsafeCell, cell::UnsafeCell,
convert::TryFrom,
ffi::CStr, ffi::CStr,
hint, io, hint, io,
mem::ManuallyDrop, mem::ManuallyDrop,

View file

@ -1,5 +1,5 @@
use super::{abi, error::expect_success}; 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)] #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
pub struct Instant(abi::SYSTIM); pub struct Instant(abi::SYSTIM);

View file

@ -1,5 +1,4 @@
use crate::cmp; use crate::cmp;
use crate::convert::TryFrom;
use crate::io::{Error as IoError, ErrorKind, IoSlice, IoSliceMut, Result as IoResult}; use crate::io::{Error as IoError, ErrorKind, IoSlice, IoSliceMut, Result as IoResult};
use crate::sys::rand::rdrand64; use crate::sys::rand::rdrand64;
use crate::time::{Duration, Instant}; use crate::time::{Duration, Instant};

View file

@ -1,4 +1,3 @@
use crate::convert::TryFrom;
use crate::error; use crate::error;
use crate::fmt; use crate::fmt;
use crate::io::{self, IoSlice, IoSliceMut}; use crate::io::{self, IoSlice, IoSliceMut};

View file

@ -1,5 +1,5 @@
use super::{abi, error::expect_success}; 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; pub use super::itron::time::Instant;

View file

@ -943,7 +943,6 @@ impl File {
} }
pub fn truncate(&self, size: u64) -> io::Result<()> { pub fn truncate(&self, size: u64) -> io::Result<()> {
use crate::convert::TryInto;
let size: off64_t = let size: off64_t =
size.try_into().map_err(|e| io::Error::new(io::ErrorKind::InvalidInput, e))?; size.try_into().map_err(|e| io::Error::new(io::ErrorKind::InvalidInput, e))?;
cvt_r(|| unsafe { ftruncate64(self.as_raw_fd(), size) }).map(drop) cvt_r(|| unsafe { ftruncate64(self.as_raw_fd(), size) }).map(drop)

View file

@ -136,7 +136,6 @@ pub fn futex_wake_all(futex: &AtomicU32) {
#[cfg(target_os = "openbsd")] #[cfg(target_os = "openbsd")]
pub fn futex_wait(futex: &AtomicU32, expected: u32, timeout: Option<Duration>) -> bool { pub fn futex_wait(futex: &AtomicU32, expected: u32, timeout: Option<Duration>) -> bool {
use crate::convert::TryInto;
use crate::ptr::{null, null_mut}; use crate::ptr::{null, null_mut};
let timespec = timeout.and_then(|d| { let timespec = timeout.and_then(|d| {
Some(libc::timespec { Some(libc::timespec {
@ -185,8 +184,6 @@ pub fn futex_wake_all(futex: &AtomicU32) {
#[cfg(target_os = "dragonfly")] #[cfg(target_os = "dragonfly")]
pub fn futex_wait(futex: &AtomicU32, expected: u32, timeout: Option<Duration>) -> bool { pub fn futex_wait(futex: &AtomicU32, expected: u32, timeout: Option<Duration>) -> bool {
use crate::convert::TryFrom;
// A timeout of 0 means infinite. // A timeout of 0 means infinite.
// We round smaller timeouts up to 1 millisecond. // We round smaller timeouts up to 1 millisecond.
// Overflows are rounded up to an infinite timeout. // Overflows are rounded up to an infinite timeout.

View file

@ -45,7 +45,6 @@
//! * complexity //! * complexity
use crate::cmp::min; use crate::cmp::min;
use crate::convert::TryInto;
use crate::fs::{File, Metadata}; use crate::fs::{File, Metadata};
use crate::io::copy::generic_copy; use crate::io::copy::generic_copy;
use crate::io::{ use crate::io::{

View file

@ -9,7 +9,6 @@ macro_rules! unimpl {
pub mod net { pub mod net {
#![allow(warnings)] #![allow(warnings)]
use crate::convert::TryFrom;
use crate::fmt; use crate::fmt;
use crate::io::{self, IoSlice, IoSliceMut}; use crate::io::{self, IoSlice, IoSliceMut};
use crate::net::{Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr}; use crate::net::{Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr};

View file

@ -1,4 +1,3 @@
use crate::convert::{TryFrom, TryInto};
use crate::fmt; use crate::fmt;
use crate::io; use crate::io;
use crate::mem; use crate::mem;

View file

@ -1,4 +1,3 @@
use crate::convert::{TryFrom, TryInto};
use crate::fmt; use crate::fmt;
use crate::io::{self, Error, ErrorKind}; use crate::io::{self, Error, ErrorKind};
use crate::mem; use crate::mem;

View file

@ -1,4 +1,3 @@
use crate::convert::{TryFrom, TryInto};
use crate::fmt; use crate::fmt;
use crate::io; use crate::io;
use crate::io::ErrorKind; use crate::io::ErrorKind;

View file

@ -1,4 +1,3 @@
use crate::convert::{TryFrom, TryInto};
use crate::fmt; use crate::fmt;
use crate::io::{self, Error, ErrorKind}; use crate::io::{self, Error, ErrorKind};
use crate::num::NonZeroI32; use crate::num::NonZeroI32;

View file

@ -1,6 +1,5 @@
#![allow(non_camel_case_types, unused)] #![allow(non_camel_case_types, unused)]
use crate::convert::TryInto;
use crate::io; use crate::io;
use crate::mem::MaybeUninit; use crate::mem::MaybeUninit;
use crate::os::raw::c_char; use crate::os::raw::c_char;

View file

@ -2,7 +2,6 @@ use crate::fmt;
use crate::time::Duration; use crate::time::Duration;
pub use self::inner::Instant; pub use self::inner::Instant;
use crate::convert::TryInto;
const NSEC_PER_SEC: u64 = 1_000_000_000; const NSEC_PER_SEC: u64 = 1_000_000_000;
pub const UNIX_EPOCH: SystemTime = SystemTime { t: Timespec::zero() }; pub const UNIX_EPOCH: SystemTime = SystemTime { t: Timespec::zero() };
@ -127,7 +126,6 @@ impl Timespec {
} }
pub fn to_timespec(&self) -> Option<libc::timespec> { pub fn to_timespec(&self) -> Option<libc::timespec> {
use crate::convert::TryInto;
Some(libc::timespec { Some(libc::timespec {
tv_sec: self.tv_sec.try_into().ok()?, tv_sec: self.tv_sec.try_into().ok()?,
tv_nsec: self.tv_nsec.try_into().ok()?, tv_nsec: self.tv_nsec.try_into().ok()?,

View file

@ -1,4 +1,3 @@
use crate::convert::TryFrom;
use crate::fmt; use crate::fmt;
use crate::io::{self, IoSlice, IoSliceMut}; use crate::io::{self, IoSlice, IoSliceMut};
use crate::net::{Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr}; use crate::net::{Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr};

View file

@ -2,7 +2,6 @@
use super::err2io; use super::err2io;
use super::fd::WasiFd; use super::fd::WasiFd;
use crate::convert::TryFrom;
use crate::fmt; use crate::fmt;
use crate::io::{self, IoSlice, IoSliceMut}; use crate::io::{self, IoSlice, IoSliceMut};
use crate::net::{Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr}; use crate::net::{Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr};

View file

@ -1,5 +1,4 @@
use crate::arch::wasm32; use crate::arch::wasm32;
use crate::convert::TryInto;
use crate::sync::atomic::AtomicU32; use crate::sync::atomic::AtomicU32;
use crate::time::Duration; use crate::time::Duration;

View file

@ -1,6 +1,5 @@
use crate::os::windows::prelude::*; use crate::os::windows::prelude::*;
use crate::convert::TryInto;
use crate::ffi::OsString; use crate::ffi::OsString;
use crate::fmt; use crate::fmt;
use crate::io::{self, Error, IoSlice, IoSliceMut, ReadBuf, SeekFrom}; use crate::io::{self, Error, IoSlice, IoSliceMut, ReadBuf, SeekFrom};

View file

@ -5,7 +5,6 @@ mod tests;
use crate::cmp; use crate::cmp;
use crate::collections::BTreeMap; use crate::collections::BTreeMap;
use crate::convert::{TryFrom, TryInto};
use crate::env; use crate::env;
use crate::env::consts::{EXE_EXTENSION, EXE_SUFFIX}; use crate::env::consts::{EXE_EXTENSION, EXE_SUFFIX};
use crate::ffi::{OsStr, OsString}; use crate::ffi::{OsStr, OsString};

View file

@ -1,4 +1,3 @@
use crate::convert::TryInto;
use crate::ffi::CStr; use crate::ffi::CStr;
use crate::io; use crate::io;
use crate::num::NonZeroUsize; use crate::num::NonZeroUsize;

View file

@ -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 // [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 // [4]: Windows Internals, Part 1, ISBN 9780735671300
use crate::convert::TryFrom;
use crate::pin::Pin; use crate::pin::Pin;
use crate::ptr; use crate::ptr;
use crate::sync::atomic::{ use crate::sync::atomic::{

View file

@ -1,5 +1,4 @@
use crate::cmp::Ordering; use crate::cmp::Ordering;
use crate::convert::TryInto;
use crate::fmt; use crate::fmt;
use crate::mem; use crate::mem;
use crate::sys::c; use crate::sys::c;

View file

@ -2,7 +2,6 @@
mod tests; mod tests;
use crate::cmp; use crate::cmp;
use crate::convert::{TryFrom, TryInto};
use crate::ffi::CString; use crate::ffi::CString;
use crate::fmt; use crate::fmt;
use crate::io::{self, ErrorKind, IoSlice, IoSliceMut}; use crate::io::{self, ErrorKind, IoSlice, IoSliceMut};

View file

@ -25,7 +25,7 @@ use crate::char;
use crate::collections::TryReserveError; use crate::collections::TryReserveError;
use crate::fmt; use crate::fmt;
use crate::hash::{Hash, Hasher}; use crate::hash::{Hash, Hasher};
use crate::iter::{FromIterator, FusedIterator}; use crate::iter::FusedIterator;
use crate::mem; use crate::mem;
use crate::ops; use crate::ops;
use crate::rc::Rc; use crate::rc::Rc;