Skip to content

Commit

Permalink
Use Rust 2021 prelude in std itself.
Browse files Browse the repository at this point in the history
  • Loading branch information
m-ou-se committed May 9, 2022
1 parent 8a2fe75 commit 4f212f0
Show file tree
Hide file tree
Showing 39 changed files with 7 additions and 43 deletions.
2 changes: 1 addition & 1 deletion library/std/src/collections/hash/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion library/std/src/collections/hash/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/ffi/os_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions library/std/src/io/cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down
1 change: 0 additions & 1 deletion library/std/src/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
1 change: 0 additions & 1 deletion library/std/src/net/addr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
1 change: 0 additions & 1 deletion library/std/src/net/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
1 change: 0 additions & 1 deletion library/std/src/os/unix/net/ancillary.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
1 change: 0 additions & 1 deletion library/std/src/os/unix/net/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion library/std/src/os/windows/io/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion library/std/src/sys/hermit/net.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
1 change: 0 additions & 1 deletion library/std/src/sys/hermit/time.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
1 change: 0 additions & 1 deletion library/std/src/sys/itron/spin.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use super::abi;
use crate::{
cell::UnsafeCell,
convert::TryFrom,
mem::MaybeUninit,
sync::atomic::{AtomicBool, AtomicUsize, Ordering},
};
Expand Down
1 change: 0 additions & 1 deletion library/std/src/sys/itron/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use super::{
};
use crate::{
cell::UnsafeCell,
convert::TryFrom,
ffi::CStr,
hint, io,
mem::ManuallyDrop,
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/itron/time.rs
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
1 change: 0 additions & 1 deletion library/std/src/sys/sgx/abi/usercalls/mod.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
1 change: 0 additions & 1 deletion library/std/src/sys/sgx/net.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::convert::TryFrom;
use crate::error;
use crate::fmt;
use crate::io::{self, IoSlice, IoSliceMut};
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/solid/time.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
1 change: 0 additions & 1 deletion library/std/src/sys/unix/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 0 additions & 3 deletions library/std/src/sys/unix/futex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Duration>) -> bool {
use crate::convert::TryInto;
use crate::ptr::{null, null_mut};
let timespec = timeout.and_then(|d| {
Some(libc::timespec {
Expand Down Expand Up @@ -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<Duration>) -> 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.
Expand Down
1 change: 0 additions & 1 deletion library/std/src/sys/unix/kernel_copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down
1 change: 0 additions & 1 deletion library/std/src/sys/unix/l4re.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
1 change: 0 additions & 1 deletion library/std/src/sys/unix/process/process_fuchsia.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::convert::{TryFrom, TryInto};
use crate::fmt;
use crate::io;
use crate::mem;
Expand Down
1 change: 0 additions & 1 deletion library/std/src/sys/unix/process/process_unix.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::convert::{TryFrom, TryInto};
use crate::fmt;
use crate::io::{self, Error, ErrorKind};
use crate::mem;
Expand Down
1 change: 0 additions & 1 deletion library/std/src/sys/unix/process/process_unsupported.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::convert::{TryFrom, TryInto};
use crate::fmt;
use crate::io;
use crate::io::ErrorKind;
Expand Down
1 change: 0 additions & 1 deletion library/std/src/sys/unix/process/process_vxworks.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::convert::{TryFrom, TryInto};
use crate::fmt;
use crate::io::{self, Error, ErrorKind};
use crate::num::NonZeroI32;
Expand Down
1 change: 0 additions & 1 deletion library/std/src/sys/unix/process/zircon.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 0 additions & 2 deletions library/std/src/sys/unix/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() };
Expand Down Expand Up @@ -127,7 +126,6 @@ impl Timespec {
}

pub fn to_timespec(&self) -> Option<libc::timespec> {
use crate::convert::TryInto;
Some(libc::timespec {
tv_sec: self.tv_sec.try_into().ok()?,
tv_nsec: self.tv_nsec.try_into().ok()?,
Expand Down
1 change: 0 additions & 1 deletion library/std/src/sys/unsupported/net.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::convert::TryFrom;
use crate::fmt;
use crate::io::{self, IoSlice, IoSliceMut};
use crate::net::{Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr};
Expand Down
1 change: 0 additions & 1 deletion library/std/src/sys/wasi/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
1 change: 0 additions & 1 deletion library/std/src/sys/wasm/atomics/futex.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::arch::wasm32;
use crate::convert::TryInto;
use crate::sync::atomic::AtomicU32;
use crate::time::Duration;

Expand Down
1 change: 0 additions & 1 deletion library/std/src/sys/windows/fs.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
1 change: 0 additions & 1 deletion library/std/src/sys/windows/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
1 change: 0 additions & 1 deletion library/std/src/sys/windows/thread.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::convert::TryInto;
use crate::ffi::CStr;
use crate::io;
use crate::num::NonZeroUsize;
Expand Down
1 change: 0 additions & 1 deletion library/std/src/sys/windows/thread_parker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down
1 change: 0 additions & 1 deletion library/std/src/sys/windows/time.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::cmp::Ordering;
use crate::convert::TryInto;
use crate::fmt;
use crate::mem;
use crate::sys::c;
Expand Down
1 change: 0 additions & 1 deletion library/std/src/sys_common/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys_common/wtf8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 4f212f0

Please sign in to comment.