diff --git a/src/libstd/Cargo.toml b/src/libstd/Cargo.toml index 7d60a170422b3..1a6b58f35b398 100644 --- a/src/libstd/Cargo.toml +++ b/src/libstd/Cargo.toml @@ -6,6 +6,7 @@ build = "build.rs" license = "MIT/Apache-2.0" repository = "https://github.com/rust-lang/rust.git" description = "The Rust Standard Library" +edition = "2018" [lib] name = "std" diff --git a/src/libstd/alloc.rs b/src/libstd/alloc.rs index 8b6e5680c2d6c..a13da2901df94 100644 --- a/src/libstd/alloc.rs +++ b/src/libstd/alloc.rs @@ -64,7 +64,8 @@ use core::sync::atomic::{AtomicPtr, Ordering}; use core::{mem, ptr}; use core::ptr::NonNull; -use sys_common::util::dumb_print; + +use crate::sys_common::util::dumb_print; #[stable(feature = "alloc_module", since = "1.28.0")] #[doc(inline)] @@ -208,7 +209,7 @@ pub fn rust_oom(layout: Layout) -> ! { unsafe { mem::transmute(hook) } }; hook(layout); - unsafe { ::sys::abort_internal(); } + unsafe { crate::sys::abort_internal(); } } #[cfg(not(test))] diff --git a/src/libstd/build.rs b/src/libstd/build.rs index 9b4ea0829aa96..726c27321538d 100644 --- a/src/libstd/build.rs +++ b/src/libstd/build.rs @@ -1,7 +1,5 @@ #![deny(warnings)] -extern crate cc; - use std::env; fn main() { diff --git a/src/libstd/collections/hash/bench.rs b/src/libstd/collections/hash/bench.rs index 8ca43f8ada211..7f5add0543685 100644 --- a/src/libstd/collections/hash/bench.rs +++ b/src/libstd/collections/hash/bench.rs @@ -1,8 +1,6 @@ #![cfg(test)] -extern crate test; - -use self::test::Bencher; +use test::Bencher; #[bench] fn new_drop(b: &mut Bencher) { diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 4fb0235539c48..a51847c92b51e 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -1,18 +1,18 @@ use self::Entry::*; use self::VacantEntryState::*; -use intrinsics::unlikely; -use collections::CollectionAllocErr; -use cell::Cell; -use borrow::Borrow; -use cmp::max; -use fmt::{self, Debug}; +use crate::intrinsics::unlikely; +use crate::collections::CollectionAllocErr; +use crate::cell::Cell; +use crate::borrow::Borrow; +use crate::cmp::max; +use crate::fmt::{self, Debug}; #[allow(deprecated)] -use hash::{Hash, Hasher, BuildHasher, SipHasher13}; -use iter::{FromIterator, FusedIterator}; -use mem::{self, replace}; -use ops::{Deref, DerefMut, Index}; -use sys; +use crate::hash::{Hash, Hasher, BuildHasher, SipHasher13}; +use crate::iter::{FromIterator, FusedIterator}; +use crate::mem::{self, replace}; +use crate::ops::{Deref, DerefMut, Index}; +use crate::sys; use super::table::{self, Bucket, EmptyBucket, Fallibility, FullBucket, FullBucketMut, RawTable, SafeHash}; @@ -3328,7 +3328,7 @@ mod test_map { use super::HashMap; use super::Entry::{Occupied, Vacant}; use super::RandomState; - use cell::RefCell; + use crate::cell::RefCell; use rand::{thread_rng, Rng}; use realstd::collections::CollectionAllocErr::*; use realstd::mem::size_of; diff --git a/src/libstd/collections/hash/set.rs b/src/libstd/collections/hash/set.rs index 46a5f26df6351..8a599c11b2095 100644 --- a/src/libstd/collections/hash/set.rs +++ b/src/libstd/collections/hash/set.rs @@ -1,8 +1,8 @@ -use borrow::Borrow; -use fmt; -use hash::{Hash, BuildHasher}; -use iter::{Chain, FromIterator, FusedIterator}; -use ops::{BitOr, BitAnd, BitXor, Sub}; +use crate::borrow::Borrow; +use crate::fmt; +use crate::hash::{Hash, BuildHasher}; +use crate::iter::{Chain, FromIterator, FusedIterator}; +use crate::ops::{BitOr, BitAnd, BitXor, Sub}; use super::Recover; use super::map::{self, HashMap, Keys, RandomState}; @@ -1751,7 +1751,7 @@ mod test_set { #[test] fn test_replace() { - use hash; + use crate::hash; #[derive(Debug)] struct Foo(&'static str, i32); diff --git a/src/libstd/collections/hash/table.rs b/src/libstd/collections/hash/table.rs index 865431252acf6..31e7a6931356c 100644 --- a/src/libstd/collections/hash/table.rs +++ b/src/libstd/collections/hash/table.rs @@ -1,12 +1,11 @@ -use alloc::{Global, Alloc, Layout, LayoutErr, handle_alloc_error}; -use collections::CollectionAllocErr; -use hash::{BuildHasher, Hash, Hasher}; -use marker; -use mem::{size_of, needs_drop}; -use mem; -use ops::{Deref, DerefMut}; -use ptr::{self, Unique, NonNull}; -use hint; +use crate::alloc::{Global, Alloc, Layout, LayoutErr, handle_alloc_error}; +use crate::collections::CollectionAllocErr; +use crate::hash::{BuildHasher, Hash, Hasher}; +use crate::marker; +use crate::mem::{self, size_of, needs_drop}; +use crate::ops::{Deref, DerefMut}; +use crate::ptr::{self, Unique, NonNull}; +use crate::hint; use self::BucketState::*; diff --git a/src/libstd/collections/mod.rs b/src/libstd/collections/mod.rs index 9ebeff48426f5..286ce2d389b8c 100644 --- a/src/libstd/collections/mod.rs +++ b/src/libstd/collections/mod.rs @@ -412,7 +412,7 @@ #[stable(feature = "rust1", since = "1.0.0")] #[rustc_deprecated(reason = "moved to `std::ops::Bound`", since = "1.26.0")] #[doc(hidden)] -pub use ops::Bound; +pub use crate::ops::Bound; #[stable(feature = "rust1", since = "1.0.0")] pub use alloc_crate::collections::{BinaryHeap, BTreeMap, BTreeSet}; #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libstd/env.rs b/src/libstd/env.rs index 543973ab991df..97c67f562a7df 100644 --- a/src/libstd/env.rs +++ b/src/libstd/env.rs @@ -13,13 +13,13 @@ #![stable(feature = "env", since = "1.0.0")] -use error::Error; -use ffi::{OsStr, OsString}; -use fmt; -use io; -use path::{Path, PathBuf}; -use sys; -use sys::os as os_imp; +use crate::error::Error; +use crate::ffi::{OsStr, OsString}; +use crate::fmt; +use crate::io; +use crate::path::{Path, PathBuf}; +use crate::sys; +use crate::sys::os as os_imp; /// Returns the current working directory as a [`PathBuf`]. /// @@ -800,7 +800,7 @@ impl fmt::Debug for ArgsOs { /// Constants associated with the current target #[stable(feature = "env", since = "1.0.0")] pub mod consts { - use sys::env::os; + use crate::sys::env::os; /// A string describing the architecture of the CPU that is currently /// in use. @@ -972,7 +972,7 @@ mod arch { mod tests { use super::*; - use path::Path; + use crate::path::Path; #[test] #[cfg_attr(target_os = "emscripten", ignore)] @@ -995,7 +995,7 @@ mod tests { #[test] #[cfg(windows)] fn split_paths_windows() { - use path::PathBuf; + use crate::path::PathBuf; fn check_parse(unparsed: &str, parsed: &[&str]) -> bool { split_paths(unparsed).collect::>() == @@ -1017,7 +1017,7 @@ mod tests { #[test] #[cfg(unix)] fn split_paths_unix() { - use path::PathBuf; + use crate::path::PathBuf; fn check_parse(unparsed: &str, parsed: &[&str]) -> bool { split_paths(unparsed).collect::>() == @@ -1034,7 +1034,7 @@ mod tests { #[test] #[cfg(unix)] fn join_paths_unix() { - use ffi::OsStr; + use crate::ffi::OsStr; fn test_eq(input: &[&str], output: &str) -> bool { &*join_paths(input.iter().cloned()).unwrap() == @@ -1052,7 +1052,7 @@ mod tests { #[test] #[cfg(windows)] fn join_paths_windows() { - use ffi::OsStr; + use crate::ffi::OsStr; fn test_eq(input: &[&str], output: &str) -> bool { &*join_paths(input.iter().cloned()).unwrap() == diff --git a/src/libstd/error.rs b/src/libstd/error.rs index 17e50a649fa52..2858308e8f8d5 100644 --- a/src/libstd/error.rs +++ b/src/libstd/error.rs @@ -13,17 +13,18 @@ // coherence challenge (e.g., specialization, neg impls, etc) we can // reconsider what crate these items belong in. -use alloc::{AllocErr, LayoutErr, CannotReallocInPlace}; -use any::TypeId; -use borrow::Cow; -use cell; -use char; use core::array; -use fmt::{self, Debug, Display}; -use mem::transmute; -use num; -use str; -use string; + +use crate::alloc::{AllocErr, LayoutErr, CannotReallocInPlace}; +use crate::any::TypeId; +use crate::borrow::Cow; +use crate::cell; +use crate::char; +use crate::fmt::{self, Debug, Display}; +use crate::mem::transmute; +use crate::num; +use crate::str; +use crate::string; /// `Error` is a trait representing the basic expectations for error values, /// i.e., values of type `E` in [`Result`]. Errors must describe @@ -852,7 +853,7 @@ impl dyn Error + Send + Sync { #[cfg(test)] mod tests { use super::Error; - use fmt; + use crate::fmt; #[derive(Debug, PartialEq)] struct A; diff --git a/src/libstd/f32.rs b/src/libstd/f32.rs index cb1f93581775c..f6cd9e82abd40 100644 --- a/src/libstd/f32.rs +++ b/src/libstd/f32.rs @@ -9,9 +9,9 @@ #![allow(missing_docs)] #[cfg(not(test))] -use intrinsics; +use crate::intrinsics; #[cfg(not(test))] -use sys::cmath; +use crate::sys::cmath; #[stable(feature = "rust1", since = "1.0.0")] pub use core::f32::{RADIX, MANTISSA_DIGITS, DIGITS, EPSILON}; @@ -488,7 +488,7 @@ impl f32 { #[inline] pub fn log2(self) -> f32 { #[cfg(target_os = "android")] - return ::sys::android::log2f32(self); + return crate::sys::android::log2f32(self); #[cfg(not(target_os = "android"))] return unsafe { intrinsics::log2f32(self) }; } @@ -932,7 +932,7 @@ impl f32 { #[inline] pub fn acosh(self) -> f32 { match self { - x if x < 1.0 => ::f32::NAN, + x if x < 1.0 => crate::f32::NAN, x => (x + ((x * x) - 1.0).sqrt()).ln(), } } @@ -960,10 +960,10 @@ impl f32 { #[cfg(test)] mod tests { - use f32; - use f32::*; - use num::*; - use num::FpCategory as Fp; + use crate::f32; + use crate::f32::*; + use crate::num::*; + use crate::num::FpCategory as Fp; #[test] fn test_num_f32() { diff --git a/src/libstd/f64.rs b/src/libstd/f64.rs index 7fa7b80751938..8ff97ab828a73 100644 --- a/src/libstd/f64.rs +++ b/src/libstd/f64.rs @@ -9,9 +9,9 @@ #![allow(missing_docs)] #[cfg(not(test))] -use intrinsics; +use crate::intrinsics; #[cfg(not(test))] -use sys::cmath; +use crate::sys::cmath; #[stable(feature = "rust1", since = "1.0.0")] pub use core::f64::{RADIX, MANTISSA_DIGITS, DIGITS, EPSILON}; @@ -436,7 +436,7 @@ impl f64 { pub fn log2(self) -> f64 { self.log_wrapper(|n| { #[cfg(target_os = "android")] - return ::sys::android::log2f64(n); + return crate::sys::android::log2f64(n); #[cfg(not(target_os = "android"))] return unsafe { intrinsics::log2f64(n) }; }) @@ -906,10 +906,10 @@ impl f64 { #[cfg(test)] mod tests { - use f64; - use f64::*; - use num::*; - use num::FpCategory as Fp; + use crate::f64; + use crate::f64::*; + use crate::num::*; + use crate::num::FpCategory as Fp; #[test] fn test_num_f64() { diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs index 0ef7224282782..139680e526fd6 100644 --- a/src/libstd/ffi/c_str.rs +++ b/src/libstd/ffi/c_str.rs @@ -1,19 +1,19 @@ -use ascii; -use borrow::{Cow, Borrow}; -use cmp::Ordering; -use error::Error; -use fmt::{self, Write}; -use io; -use mem; -use memchr; -use ops; -use os::raw::c_char; -use ptr; -use rc::Rc; -use slice; -use str::{self, Utf8Error}; -use sync::Arc; -use sys; +use crate::ascii; +use crate::borrow::{Cow, Borrow}; +use crate::cmp::Ordering; +use crate::error::Error; +use crate::fmt::{self, Write}; +use crate::io; +use crate::mem; +use crate::memchr; +use crate::ops; +use crate::os::raw::c_char; +use crate::ptr; +use crate::rc::Rc; +use crate::slice; +use crate::str::{self, Utf8Error}; +use crate::sync::Arc; +use crate::sys; /// A type representing an owned, C-compatible, nul-terminated string with no nul bytes in the /// middle. @@ -1303,12 +1303,12 @@ impl AsRef for CString { #[cfg(test)] mod tests { use super::*; - use os::raw::c_char; - use borrow::Cow::{Borrowed, Owned}; - use hash::{Hash, Hasher}; - use collections::hash_map::DefaultHasher; - use rc::Rc; - use sync::Arc; + use crate::os::raw::c_char; + use crate::borrow::Cow::{Borrowed, Owned}; + use crate::hash::{Hash, Hasher}; + use crate::collections::hash_map::DefaultHasher; + use crate::rc::Rc; + use crate::sync::Arc; #[test] fn c_to_rust() { diff --git a/src/libstd/ffi/os_str.rs b/src/libstd/ffi/os_str.rs index 81433832ffc7e..f68eaeb9c7e1f 100644 --- a/src/libstd/ffi/os_str.rs +++ b/src/libstd/ffi/os_str.rs @@ -1,13 +1,13 @@ -use borrow::{Borrow, Cow}; -use fmt; -use ops; -use cmp; -use hash::{Hash, Hasher}; -use rc::Rc; -use sync::Arc; +use crate::borrow::{Borrow, Cow}; +use crate::fmt; +use crate::ops; +use crate::cmp; +use crate::hash::{Hash, Hasher}; +use crate::rc::Rc; +use crate::sync::Arc; -use sys::os_str::{Buf, Slice}; -use sys_common::{AsInner, IntoInner, FromInner}; +use crate::sys::os_str::{Buf, Slice}; +use crate::sys_common::{AsInner, IntoInner, FromInner}; /// A type that can represent owned, mutable platform-native strings, but is /// cheaply inter-convertible with Rust strings. @@ -968,10 +968,10 @@ impl AsInner for OsStr { #[cfg(test)] mod tests { use super::*; - use sys_common::{AsInner, IntoInner}; + use crate::sys_common::{AsInner, IntoInner}; - use rc::Rc; - use sync::Arc; + use crate::rc::Rc; + use crate::sync::Arc; #[test] fn test_os_string_with_capacity() { diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index 79b5686faac60..25f2dd73504ae 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -7,13 +7,13 @@ #![stable(feature = "rust1", since = "1.0.0")] -use fmt; -use ffi::OsString; -use io::{self, SeekFrom, Seek, Read, Initializer, Write}; -use path::{Path, PathBuf}; -use sys::fs as fs_imp; -use sys_common::{AsInnerMut, FromInner, AsInner, IntoInner}; -use time::SystemTime; +use crate::fmt; +use crate::ffi::OsString; +use crate::io::{self, SeekFrom, Seek, Read, Initializer, Write}; +use crate::path::{Path, PathBuf}; +use crate::sys::fs as fs_imp; +use crate::sys_common::{AsInnerMut, FromInner, AsInner, IntoInner}; +use crate::time::SystemTime; /// A reference to an open file on the filesystem. /// @@ -2096,26 +2096,27 @@ impl AsInnerMut for DirBuilder { #[cfg(all(test, not(any(target_os = "cloudabi", target_os = "emscripten"))))] mod tests { - use io::prelude::*; + use crate::io::prelude::*; + + use crate::fs::{self, File, OpenOptions}; + use crate::io::{ErrorKind, SeekFrom}; + use crate::path::Path; + use crate::str; + use crate::sys_common::io::test::{TempDir, tmpdir}; + use crate::thread; - use fs::{self, File, OpenOptions}; - use io::{ErrorKind, SeekFrom}; - use path::Path; use rand::{rngs::StdRng, FromEntropy, RngCore}; - use str; - use sys_common::io::test::{TempDir, tmpdir}; - use thread; #[cfg(windows)] - use os::windows::fs::{symlink_dir, symlink_file}; + use crate::os::windows::fs::{symlink_dir, symlink_file}; #[cfg(windows)] - use sys::fs::symlink_junction; + use crate::sys::fs::symlink_junction; #[cfg(unix)] - use os::unix::fs::symlink as symlink_dir; + use crate::os::unix::fs::symlink as symlink_dir; #[cfg(unix)] - use os::unix::fs::symlink as symlink_file; + use crate::os::unix::fs::symlink as symlink_file; #[cfg(unix)] - use os::unix::fs::symlink as symlink_junction; + use crate::os::unix::fs::symlink as symlink_junction; macro_rules! check { ($e:expr) => ( match $e { @@ -2334,7 +2335,7 @@ mod tests { #[test] #[cfg(unix)] fn file_test_io_read_write_at() { - use os::unix::fs::FileExt; + use crate::os::unix::fs::FileExt; let tmpdir = tmpdir(); let filename = tmpdir.join("file_rt_io_file_test_read_write_at.txt"); @@ -2390,7 +2391,7 @@ mod tests { #[test] #[cfg(unix)] fn set_get_unix_permissions() { - use os::unix::fs::PermissionsExt; + use crate::os::unix::fs::PermissionsExt; let tmpdir = tmpdir(); let filename = &tmpdir.join("set_get_unix_permissions"); @@ -2411,7 +2412,7 @@ mod tests { #[test] #[cfg(windows)] fn file_test_io_seek_read_write() { - use os::windows::fs::FileExt; + use crate::os::windows::fs::FileExt; let tmpdir = tmpdir(); let filename = tmpdir.join("file_rt_io_file_test_seek_read_write.txt"); @@ -3013,7 +3014,7 @@ mod tests { #[test] fn open_flavors() { - use fs::OpenOptions as OO; + use crate::fs::OpenOptions as OO; fn c(t: &T) -> T { t.clone() } let tmpdir = tmpdir(); diff --git a/src/libstd/io/buffered.rs b/src/libstd/io/buffered.rs index 6383a14cf184c..559a54d3c8aca 100644 --- a/src/libstd/io/buffered.rs +++ b/src/libstd/io/buffered.rs @@ -1,12 +1,12 @@ //! Buffering wrappers for I/O traits -use io::prelude::*; +use crate::io::prelude::*; -use cmp; -use error; -use fmt; -use io::{self, Initializer, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom, IoVec, IoVecMut}; -use memchr; +use crate::cmp; +use crate::error; +use crate::fmt; +use crate::io::{self, Initializer, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom, IoVec, IoVecMut}; +use crate::memchr; /// The `BufReader` struct adds buffering to any reader. /// @@ -977,11 +977,10 @@ impl fmt::Debug for LineWriter where W: fmt::Debug { #[cfg(test)] mod tests { - use io::prelude::*; - use io::{self, BufReader, BufWriter, LineWriter, SeekFrom}; - use sync::atomic::{AtomicUsize, Ordering}; - use thread; - use test; + use crate::io::prelude::*; + use crate::io::{self, BufReader, BufWriter, LineWriter, SeekFrom}; + use crate::sync::atomic::{AtomicUsize, Ordering}; + use crate::thread; /// A dummy reader intended at testing short-reads propagation. pub struct ShortReader { diff --git a/src/libstd/io/cursor.rs b/src/libstd/io/cursor.rs index 577a115025ba7..873da0898c7fe 100644 --- a/src/libstd/io/cursor.rs +++ b/src/libstd/io/cursor.rs @@ -1,8 +1,9 @@ -use io::prelude::*; +use crate::io::prelude::*; + +use crate::cmp; +use crate::io::{self, Initializer, SeekFrom, Error, ErrorKind, IoVec, IoVecMut}; use core::convert::TryInto; -use cmp; -use io::{self, Initializer, SeekFrom, Error, ErrorKind, IoVec, IoVecMut}; /// A `Cursor` wraps an in-memory buffer and provides it with a /// [`Seek`] implementation. @@ -378,8 +379,8 @@ impl Write for Cursor> { #[cfg(test)] mod tests { - use io::prelude::*; - use io::{Cursor, SeekFrom, IoVec, IoVecMut}; + use crate::io::prelude::*; + use crate::io::{Cursor, SeekFrom, IoVec, IoVecMut}; #[test] fn test_vec_writer() { diff --git a/src/libstd/io/error.rs b/src/libstd/io/error.rs index e9b4f60182c49..fdc5625ff1841 100644 --- a/src/libstd/io/error.rs +++ b/src/libstd/io/error.rs @@ -1,8 +1,8 @@ -use error; -use fmt; -use result; -use sys; -use convert::From; +use crate::error; +use crate::fmt; +use crate::result; +use crate::sys; +use crate::convert::From; /// A specialized [`Result`](../result/enum.Result.html) type for I/O /// operations. @@ -566,10 +566,10 @@ fn _assert_error_is_sync_send() { #[cfg(test)] mod test { use super::{Error, ErrorKind, Repr, Custom}; - use error; - use fmt; - use sys::os::error_string; - use sys::decode_error_kind; + use crate::error; + use crate::fmt; + use crate::sys::os::error_string; + use crate::sys::decode_error_kind; #[test] fn test_debug_error() { diff --git a/src/libstd/io/impls.rs b/src/libstd/io/impls.rs index aa8db177ffcd1..bd3d0a4163869 100644 --- a/src/libstd/io/impls.rs +++ b/src/libstd/io/impls.rs @@ -1,8 +1,8 @@ -use cmp; -use io::{self, SeekFrom, Read, Initializer, Write, Seek, BufRead, Error, ErrorKind, IoVecMut, +use crate::cmp; +use crate::io::{self, SeekFrom, Read, Initializer, Write, Seek, BufRead, Error, ErrorKind, IoVecMut, IoVec}; -use fmt; -use mem; +use crate::fmt; +use crate::mem; // ============================================================================= // Forwarding implementations @@ -323,8 +323,7 @@ impl Write for Vec { #[cfg(test)] mod tests { - use io::prelude::*; - use test; + use crate::io::prelude::*; #[bench] fn bench_read_slice(b: &mut test::Bencher) { diff --git a/src/libstd/io/lazy.rs b/src/libstd/io/lazy.rs index e3ebe82e3daca..e864aa2c864bb 100644 --- a/src/libstd/io/lazy.rs +++ b/src/libstd/io/lazy.rs @@ -1,8 +1,8 @@ -use cell::Cell; -use ptr; -use sync::Arc; -use sys_common; -use sys_common::mutex::Mutex; +use crate::cell::Cell; +use crate::ptr; +use crate::sync::Arc; +use crate::sys_common; +use crate::sys_common::mutex::Mutex; pub struct Lazy { // We never call `lock.init()`, so it is UB to attempt to acquire this mutex reentrantly! diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index 613ae7a672844..e3e2754a7aa09 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -259,14 +259,14 @@ #![stable(feature = "rust1", since = "1.0.0")] -use cmp; -use fmt; -use slice; -use str; -use memchr; -use ops::{Deref, DerefMut}; -use ptr; -use sys; +use crate::cmp; +use crate::fmt; +use crate::slice; +use crate::str; +use crate::memchr; +use crate::ops::{Deref, DerefMut}; +use crate::ptr; +use crate::sys; #[stable(feature = "rust1", since = "1.0.0")] pub use self::buffered::{BufReader, BufWriter, LineWriter}; @@ -297,7 +297,7 @@ mod lazy; mod util; mod stdio; -const DEFAULT_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE; +const DEFAULT_BUF_SIZE: usize = crate::sys_common::io::DEFAULT_BUF_SIZE; struct Guard<'a> { buf: &'a mut Vec, len: usize } @@ -2155,10 +2155,9 @@ impl Iterator for Lines { #[cfg(test)] mod tests { - use io::prelude::*; - use io; + use crate::io::prelude::*; + use crate::io; use super::Cursor; - use test; use super::repeat; #[test] diff --git a/src/libstd/io/stdio.rs b/src/libstd/io/stdio.rs index 0324568e6fb52..13bf357e2eb8f 100644 --- a/src/libstd/io/stdio.rs +++ b/src/libstd/io/stdio.rs @@ -1,13 +1,13 @@ -use io::prelude::*; +use crate::io::prelude::*; -use cell::RefCell; -use fmt; -use io::lazy::Lazy; -use io::{self, Initializer, BufReader, LineWriter}; -use sync::{Arc, Mutex, MutexGuard}; -use sys::stdio; -use sys_common::remutex::{ReentrantMutex, ReentrantMutexGuard}; -use thread::LocalKey; +use crate::cell::RefCell; +use crate::fmt; +use crate::io::lazy::Lazy; +use crate::io::{self, Initializer, BufReader, LineWriter}; +use crate::sync::{Arc, Mutex, MutexGuard}; +use crate::sys::stdio; +use crate::sys_common::remutex::{ReentrantMutex, ReentrantMutexGuard}; +use crate::thread::LocalKey; /// Stdout used by print! and println! macros thread_local! { @@ -668,8 +668,8 @@ impl fmt::Debug for StderrLock<'_> { issue = "0")] #[doc(hidden)] pub fn set_panic(sink: Option>) -> Option> { - use panicking::LOCAL_STDERR; - use mem; + use crate::panicking::LOCAL_STDERR; + use crate::mem; LOCAL_STDERR.with(move |slot| { mem::replace(&mut *slot.borrow_mut(), sink) }).and_then(|mut s| { @@ -692,7 +692,7 @@ pub fn set_panic(sink: Option>) -> Option>) -> Option> { - use mem; + use crate::mem; LOCAL_STDOUT.with(move |slot| { mem::replace(&mut *slot.borrow_mut(), sink) }).and_then(|mut s| { @@ -749,14 +749,14 @@ pub fn _print(args: fmt::Arguments) { issue = "0")] #[doc(hidden)] pub fn _eprint(args: fmt::Arguments) { - use panicking::LOCAL_STDERR; + use crate::panicking::LOCAL_STDERR; print_to(args, &LOCAL_STDERR, stderr, "stderr"); } #[cfg(test)] mod tests { - use panic::{UnwindSafe, RefUnwindSafe}; - use thread; + use crate::panic::{UnwindSafe, RefUnwindSafe}; + use crate::thread; use super::*; #[test] diff --git a/src/libstd/io/util.rs b/src/libstd/io/util.rs index 5ce955eb1e4af..6aaf8f1889ac0 100644 --- a/src/libstd/io/util.rs +++ b/src/libstd/io/util.rs @@ -1,8 +1,8 @@ #![allow(missing_copy_implementations)] -use fmt; -use io::{self, Read, Initializer, Write, ErrorKind, BufRead, IoVec, IoVecMut}; -use mem; +use crate::fmt; +use crate::io::{self, Read, Initializer, Write, ErrorKind, BufRead, IoVec, IoVecMut}; +use crate::mem; /// Copies the entire contents of a reader into a writer. /// @@ -224,8 +224,8 @@ impl fmt::Debug for Sink { #[cfg(test)] mod tests { - use io::prelude::*; - use io::{copy, sink, empty, repeat}; + use crate::io::prelude::*; + use crate::io::{copy, sink, empty, repeat}; #[test] fn copy_copies() { diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index ff72704bfbf69..32a168619dfb3 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -209,6 +209,10 @@ #![deny(intra_doc_link_resolution_failure)] #![deny(missing_debug_implementations)] +#![deny(rust_2018_idioms)] +#![allow(explicit_outlives_requirements)] +#![allow(elided_lifetimes_in_paths)] + // Tell the compiler to link to either panic_abort or panic_unwind #![needs_panic_runtime] @@ -313,29 +317,25 @@ use prelude::v1::*; // Access to Bencher, etc. #[cfg(test)] extern crate test; -#[cfg(test)] extern crate rand; // Re-export a few macros from core #[stable(feature = "rust1", since = "1.0.0")] pub use core::{assert_eq, assert_ne, debug_assert, debug_assert_eq, debug_assert_ne}; #[stable(feature = "rust1", since = "1.0.0")] -pub use core::{unreachable, unimplemented, write, writeln, try}; +pub use core::{unreachable, unimplemented, write, writeln, r#try}; #[allow(unused_imports)] // macros from `alloc` are not used on all platforms #[macro_use] extern crate alloc as alloc_crate; #[doc(masked)] +#[allow(unused_extern_crates)] extern crate libc; -extern crate rustc_demangle; // We always need an unwinder currently for backtraces #[doc(masked)] #[allow(unused_extern_crates)] extern crate unwind; -#[cfg(feature = "backtrace")] -extern crate backtrace_sys; - // During testing, this crate is not actually the "real" std library, but rather // it links to the real std library, which was compiled from this same source // code. So any lang items std defines are conditionally excluded (or else they @@ -344,9 +344,6 @@ extern crate backtrace_sys; // testing gives test-std access to real-std lang items and globals. See #2912 #[cfg(test)] extern crate std as realstd; -#[cfg(all(target_vendor = "fortanix", target_env = "sgx"))] -extern crate fortanix_sgx_abi; - // The standard macros that are not built-in to the compiler. #[macro_use] mod macros; diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index b9204d27f5392..281641c3c1232 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -333,7 +333,7 @@ macro_rules! dbg { #[cfg_attr(stage0, allow_internal_unstable)] #[cfg_attr(not(stage0), allow_internal_unstable(gen_future, generators))] #[allow_internal_unsafe] -macro_rules! await { +macro_rules! r#await { ($e:expr) => { { let mut pinned = $e; loop { diff --git a/src/libstd/memchr.rs b/src/libstd/memchr.rs index 9f44c67c1cc5c..d69294b2d200c 100644 --- a/src/libstd/memchr.rs +++ b/src/libstd/memchr.rs @@ -22,7 +22,7 @@ /// ``` #[inline] pub fn memchr(needle: u8, haystack: &[u8]) -> Option { - ::sys::memchr::memchr(needle, haystack) + crate::sys::memchr::memchr(needle, haystack) } /// A safe interface to `memrchr`. @@ -42,7 +42,7 @@ pub fn memchr(needle: u8, haystack: &[u8]) -> Option { /// ``` #[inline] pub fn memrchr(needle: u8, haystack: &[u8]) -> Option { - ::sys::memchr::memrchr(needle, haystack) + crate::sys::memchr::memrchr(needle, haystack) } #[cfg(test)] diff --git a/src/libstd/net/addr.rs b/src/libstd/net/addr.rs index 4b60ee8e6dadd..f5a87cc3ea67a 100644 --- a/src/libstd/net/addr.rs +++ b/src/libstd/net/addr.rs @@ -1,16 +1,16 @@ -use fmt; -use hash; -use io; -use mem; -use net::{ntoh, hton, IpAddr, Ipv4Addr, Ipv6Addr}; -use option; -use sys::net::netc as c; -use sys_common::{FromInner, AsInner, IntoInner}; -use sys_common::net::LookupHost; -use vec; -use iter; -use slice; -use convert::TryInto; +use crate::fmt; +use crate::hash; +use crate::io; +use crate::mem; +use crate::net::{ntoh, hton, IpAddr, Ipv4Addr, Ipv6Addr}; +use crate::option; +use crate::sys::net::netc as c; +use crate::sys_common::{FromInner, AsInner, IntoInner}; +use crate::sys_common::net::LookupHost; +use crate::vec; +use crate::iter; +use crate::slice; +use crate::convert::TryInto; /// An internet socket address, either IPv4 or IPv6. /// @@ -921,8 +921,8 @@ impl ToSocketAddrs for String { #[cfg(all(test, not(target_os = "emscripten")))] mod tests { - use net::*; - use net::test::{tsa, sa6, sa4}; + use crate::net::*; + use crate::net::test::{tsa, sa6, sa4}; #[test] fn to_socket_addr_ipaddr_u16() { diff --git a/src/libstd/net/ip.rs b/src/libstd/net/ip.rs index c856129016814..fa256ce508655 100644 --- a/src/libstd/net/ip.rs +++ b/src/libstd/net/ip.rs @@ -3,11 +3,11 @@ be to be stable", issue = "27709")] -use cmp::Ordering; -use fmt; -use hash; -use sys::net::netc as c; -use sys_common::{AsInner, FromInner}; +use crate::cmp::Ordering; +use crate::fmt; +use crate::hash; +use crate::sys::net::netc as c; +use crate::sys_common::{AsInner, FromInner}; /// An IP address, either IPv4 or IPv6. /// @@ -1509,9 +1509,9 @@ impl From<[u16; 8]> for IpAddr { // Tests for this module #[cfg(all(test, not(target_os = "emscripten")))] mod tests { - use net::*; - use net::Ipv6MulticastScope::*; - use net::test::{tsa, sa6, sa4}; + use crate::net::*; + use crate::net::Ipv6MulticastScope::*; + use crate::net::test::{tsa, sa6, sa4}; #[test] fn test_from_str_ipv4() { diff --git a/src/libstd/net/mod.rs b/src/libstd/net/mod.rs index 93e724db3d4d0..b68146939fdcc 100644 --- a/src/libstd/net/mod.rs +++ b/src/libstd/net/mod.rs @@ -28,7 +28,7 @@ #![stable(feature = "rust1", since = "1.0.0")] -use io::{self, Error, ErrorKind}; +use crate::io::{self, Error, ErrorKind}; #[stable(feature = "rust1", since = "1.0.0")] pub use self::ip::{IpAddr, Ipv4Addr, Ipv6Addr, Ipv6MulticastScope}; diff --git a/src/libstd/net/parser.rs b/src/libstd/net/parser.rs index 70e0c2ad4b49b..7951cd6bcf28c 100644 --- a/src/libstd/net/parser.rs +++ b/src/libstd/net/parser.rs @@ -3,10 +3,10 @@ //! This module is "publicly exported" through the `FromStr` implementations //! below. -use error::Error; -use fmt; -use net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6}; -use str::FromStr; +use crate::error::Error; +use crate::fmt; +use crate::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6}; +use crate::str::FromStr; struct Parser<'a> { // parsing as ASCII, so can use byte array diff --git a/src/libstd/net/tcp.rs b/src/libstd/net/tcp.rs index 3aa29f83b2938..275557da96f67 100644 --- a/src/libstd/net/tcp.rs +++ b/src/libstd/net/tcp.rs @@ -1,11 +1,11 @@ -use io::prelude::*; +use crate::io::prelude::*; -use fmt; -use io::{self, Initializer, IoVec, IoVecMut}; -use net::{ToSocketAddrs, SocketAddr, Shutdown}; -use sys_common::net as net_imp; -use sys_common::{AsInner, FromInner, IntoInner}; -use time::Duration; +use crate::fmt; +use crate::io::{self, Initializer, IoVec, IoVecMut}; +use crate::net::{ToSocketAddrs, SocketAddr, Shutdown}; +use crate::sys_common::net as net_imp; +use crate::sys_common::{AsInner, FromInner, IntoInner}; +use crate::time::Duration; /// A TCP stream between a local and a remote socket. /// @@ -929,14 +929,14 @@ impl fmt::Debug for TcpListener { #[cfg(all(test, not(any(target_os = "cloudabi", target_os = "emscripten"))))] mod tests { - use io::{ErrorKind, IoVec, IoVecMut}; - use io::prelude::*; - use net::*; - use net::test::{next_test_ip4, next_test_ip6}; - use sync::mpsc::channel; - use sys_common::AsInner; - use time::{Instant, Duration}; - use thread; + use crate::io::{ErrorKind, IoVec, IoVecMut}; + use crate::io::prelude::*; + use crate::net::*; + use crate::net::test::{next_test_ip4, next_test_ip6}; + use crate::sync::mpsc::channel; + use crate::sys_common::AsInner; + use crate::time::{Instant, Duration}; + use crate::thread; fn each_ip(f: &mut dyn FnMut(SocketAddr)) { f(next_test_ip4()); diff --git a/src/libstd/net/test.rs b/src/libstd/net/test.rs index eb5862cbdd945..89fefd9d1d5e0 100644 --- a/src/libstd/net/test.rs +++ b/src/libstd/net/test.rs @@ -1,8 +1,8 @@ #![allow(warnings)] // not used on emscripten -use env; -use net::{SocketAddr, SocketAddrV4, SocketAddrV6, Ipv4Addr, Ipv6Addr, ToSocketAddrs}; -use sync::atomic::{AtomicUsize, Ordering}; +use crate::env; +use crate::net::{SocketAddr, SocketAddrV4, SocketAddrV6, Ipv4Addr, Ipv6Addr, ToSocketAddrs}; +use crate::sync::atomic::{AtomicUsize, Ordering}; static PORT: AtomicUsize = AtomicUsize::new(0); diff --git a/src/libstd/net/udp.rs b/src/libstd/net/udp.rs index d49871ce7bd86..edc9d665444a0 100644 --- a/src/libstd/net/udp.rs +++ b/src/libstd/net/udp.rs @@ -1,9 +1,9 @@ -use fmt; -use io::{self, Error, ErrorKind}; -use net::{ToSocketAddrs, SocketAddr, Ipv4Addr, Ipv6Addr}; -use sys_common::net as net_imp; -use sys_common::{AsInner, FromInner, IntoInner}; -use time::Duration; +use crate::fmt; +use crate::io::{self, Error, ErrorKind}; +use crate::net::{ToSocketAddrs, SocketAddr, Ipv4Addr, Ipv6Addr}; +use crate::sys_common::net as net_imp; +use crate::sys_common::{AsInner, FromInner, IntoInner}; +use crate::time::Duration; /// A UDP socket. /// @@ -808,13 +808,13 @@ impl fmt::Debug for UdpSocket { #[cfg(all(test, not(any(target_os = "cloudabi", target_os = "emscripten"))))] mod tests { - use io::ErrorKind; - use net::*; - use net::test::{next_test_ip4, next_test_ip6}; - use sync::mpsc::channel; - use sys_common::AsInner; - use time::{Instant, Duration}; - use thread; + use crate::io::ErrorKind; + use crate::net::*; + use crate::net::test::{next_test_ip4, next_test_ip6}; + use crate::sync::mpsc::channel; + use crate::sys_common::AsInner; + use crate::time::{Instant, Duration}; + use crate::thread; fn each_ip(f: &mut dyn FnMut(SocketAddr, SocketAddr)) { f(next_test_ip4(), next_test_ip4()); diff --git a/src/libstd/num.rs b/src/libstd/num.rs index c80b9a56704a7..828d5720eec1e 100644 --- a/src/libstd/num.rs +++ b/src/libstd/num.rs @@ -14,8 +14,8 @@ pub use core::num::Wrapping; #[stable(feature = "nonzero", since = "1.28.0")] pub use core::num::{NonZeroU8, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU128, NonZeroUsize}; -#[cfg(test)] use fmt; -#[cfg(test)] use ops::{Add, Sub, Mul, Div, Rem}; +#[cfg(test)] use crate::fmt; +#[cfg(test)] use crate::ops::{Add, Sub, Mul, Div, Rem}; /// Helper function for testing numeric operations #[cfg(test)] @@ -35,16 +35,16 @@ pub fn test_num(ten: T, two: T) where #[cfg(test)] mod tests { - use u8; - use u16; - use u32; - use u64; - use usize; - use ops::Mul; + use crate::u8; + use crate::u16; + use crate::u32; + use crate::u64; + use crate::usize; + use crate::ops::Mul; #[test] fn test_saturating_add_uint() { - use usize::MAX; + use crate::usize::MAX; assert_eq!(3_usize.saturating_add(5_usize), 8_usize); assert_eq!(3_usize.saturating_add(MAX-1), MAX); assert_eq!(MAX.saturating_add(MAX), MAX); @@ -53,7 +53,7 @@ mod tests { #[test] fn test_saturating_sub_uint() { - use usize::MAX; + use crate::usize::MAX; assert_eq!(5_usize.saturating_sub(3_usize), 2_usize); assert_eq!(3_usize.saturating_sub(5_usize), 0_usize); assert_eq!(0_usize.saturating_sub(1_usize), 0_usize); @@ -62,7 +62,7 @@ mod tests { #[test] fn test_saturating_add_int() { - use isize::{MIN,MAX}; + use crate::isize::{MIN,MAX}; assert_eq!(3i32.saturating_add(5), 8); assert_eq!(3isize.saturating_add(MAX-1), MAX); assert_eq!(MAX.saturating_add(MAX), MAX); @@ -74,7 +74,7 @@ mod tests { #[test] fn test_saturating_sub_int() { - use isize::{MIN,MAX}; + use crate::isize::{MIN,MAX}; assert_eq!(3i32.saturating_sub(5), -2); assert_eq!(MIN.saturating_sub(1), MIN); assert_eq!((-2isize).saturating_sub(MAX), MIN); @@ -232,8 +232,8 @@ mod tests { assert_eq!(u64_val.to_string(), "0"); } - fn from_str(t: &str) -> Option { - ::str::FromStr::from_str(t).ok() + fn from_str(t: &str) -> Option { + crate::str::FromStr::from_str(t).ok() } #[test] @@ -275,8 +275,7 @@ mod tests { #[cfg(test)] mod bench { - extern crate test; - use self::test::Bencher; + use test::Bencher; #[bench] fn bench_pow_function(b: &mut Bencher) { diff --git a/src/libstd/os/android/fs.rs b/src/libstd/os/android/fs.rs index 7aab6bf27ca88..9b24f86204bb6 100644 --- a/src/libstd/os/android/fs.rs +++ b/src/libstd/os/android/fs.rs @@ -1,12 +1,10 @@ #![stable(feature = "metadata_ext", since = "1.1.0")] -use libc; - -use fs::Metadata; -use sys_common::AsInner; +use crate::fs::Metadata; +use crate::sys_common::AsInner; #[allow(deprecated)] -use os::android::raw; +use crate::os::android::raw; /// OS-specific extensions to [`fs::Metadata`]. /// diff --git a/src/libstd/os/android/raw.rs b/src/libstd/os/android/raw.rs index e03de8a7cc40b..acf5ca1e4297b 100644 --- a/src/libstd/os/android/raw.rs +++ b/src/libstd/os/android/raw.rs @@ -8,7 +8,7 @@ definitions")] #![allow(deprecated)] -use os::raw::c_long; +use crate::os::raw::c_long; #[stable(feature = "pthread_t", since = "1.8.0")] pub type pthread_t = c_long; @@ -19,8 +19,8 @@ pub use self::arch::{dev_t, mode_t, blkcnt_t, blksize_t, ino_t, nlink_t, off_t, #[cfg(any(target_arch = "arm", target_arch = "x86"))] mod arch { - use os::raw::{c_uint, c_uchar, c_ulonglong, c_longlong, c_ulong}; - use os::unix::raw::{uid_t, gid_t}; + use crate::os::raw::{c_uint, c_uchar, c_ulonglong, c_longlong, c_ulong}; + use crate::os::unix::raw::{uid_t, gid_t}; #[stable(feature = "raw_ext", since = "1.1.0")] pub type dev_t = u64; @@ -89,8 +89,8 @@ mod arch { #[cfg(target_arch = "aarch64")] mod arch { - use os::raw::{c_uchar, c_ulong}; - use os::unix::raw::{uid_t, gid_t}; + use crate::os::raw::{c_uchar, c_ulong}; + use crate::os::unix::raw::{uid_t, gid_t}; #[stable(feature = "raw_ext", since = "1.1.0")] pub type dev_t = u64; @@ -157,8 +157,8 @@ mod arch { #[cfg(target_arch = "x86_64")] mod arch { - use os::raw::{c_uint, c_long, c_ulong}; - use os::unix::raw::{uid_t, gid_t}; + use crate::os::raw::{c_uint, c_long, c_ulong}; + use crate::os::unix::raw::{uid_t, gid_t}; #[stable(feature = "raw_ext", since = "1.1.0")] pub type dev_t = u64; diff --git a/src/libstd/os/bitrig/fs.rs b/src/libstd/os/bitrig/fs.rs index 8d6da3b7a0730..849d4aa67f204 100644 --- a/src/libstd/os/bitrig/fs.rs +++ b/src/libstd/os/bitrig/fs.rs @@ -1,12 +1,10 @@ #![stable(feature = "metadata_ext", since = "1.1.0")] -use libc; - -use fs::Metadata; -use sys_common::AsInner; +use crate::fs::Metadata; +use crate::sys_common::AsInner; #[allow(deprecated)] -use os::bitrig::raw; +use crate::os::bitrig::raw; /// OS-specific extensions to [`fs::Metadata`]. /// diff --git a/src/libstd/os/bitrig/raw.rs b/src/libstd/os/bitrig/raw.rs index 034dc986b6917..c966d5a8e5b49 100644 --- a/src/libstd/os/bitrig/raw.rs +++ b/src/libstd/os/bitrig/raw.rs @@ -8,8 +8,8 @@ definitions")] #![allow(deprecated)] -use os::raw::c_long; -use os::unix::raw::{uid_t, gid_t}; +use crate::os::raw::c_long; +use crate::os::unix::raw::{uid_t, gid_t}; #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64; #[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64; diff --git a/src/libstd/os/dragonfly/fs.rs b/src/libstd/os/dragonfly/fs.rs index 14f5e8035687f..ba38660224f24 100644 --- a/src/libstd/os/dragonfly/fs.rs +++ b/src/libstd/os/dragonfly/fs.rs @@ -1,12 +1,10 @@ #![stable(feature = "metadata_ext", since = "1.1.0")] -use libc; - -use fs::Metadata; -use sys_common::AsInner; +use crate::fs::Metadata; +use crate::sys_common::AsInner; #[allow(deprecated)] -use os::dragonfly::raw; +use crate::os::dragonfly::raw; /// OS-specific extensions to [`fs::Metadata`]. /// diff --git a/src/libstd/os/dragonfly/raw.rs b/src/libstd/os/dragonfly/raw.rs index 4f36652ddcf50..46ef5a1e7cf7b 100644 --- a/src/libstd/os/dragonfly/raw.rs +++ b/src/libstd/os/dragonfly/raw.rs @@ -8,7 +8,7 @@ definitions")] #![allow(deprecated)] -use os::raw::c_long; +use crate::os::raw::c_long; #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64; #[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64; diff --git a/src/libstd/os/emscripten/fs.rs b/src/libstd/os/emscripten/fs.rs index 33c41c9223e69..aa6aa38283def 100644 --- a/src/libstd/os/emscripten/fs.rs +++ b/src/libstd/os/emscripten/fs.rs @@ -1,12 +1,10 @@ #![stable(feature = "metadata_ext", since = "1.1.0")] -use libc; - -use fs::Metadata; -use sys_common::AsInner; +use crate::fs::Metadata; +use crate::sys_common::AsInner; #[allow(deprecated)] -use os::emscripten::raw; +use crate::os::emscripten::raw; /// OS-specific extensions to [`fs::Metadata`]. /// diff --git a/src/libstd/os/emscripten/raw.rs b/src/libstd/os/emscripten/raw.rs index d59ce482ef788..e551348797942 100644 --- a/src/libstd/os/emscripten/raw.rs +++ b/src/libstd/os/emscripten/raw.rs @@ -10,7 +10,7 @@ definitions")] #![allow(deprecated)] -use os::raw::{c_long, c_short, c_uint, c_ulong}; +use crate::os::raw::{c_long, c_short, c_uint, c_ulong}; #[stable(feature = "raw_ext", since = "1.1.0")] pub type dev_t = u64; #[stable(feature = "raw_ext", since = "1.1.0")] pub type mode_t = u32; diff --git a/src/libstd/os/fortanix_sgx/mod.rs b/src/libstd/os/fortanix_sgx/mod.rs index bd6f4b4465b24..bca22e717d724 100644 --- a/src/libstd/os/fortanix_sgx/mod.rs +++ b/src/libstd/os/fortanix_sgx/mod.rs @@ -11,34 +11,35 @@ /// /// [ABI documentation]: https://docs.rs/fortanix-sgx-abi/ pub mod usercalls { - pub use sys::abi::usercalls::*; + pub use crate::sys::abi::usercalls::*; /// Primitives for allocating memory in userspace as well as copying data /// to and from user memory. pub mod alloc { - pub use sys::abi::usercalls::alloc::*; + pub use crate::sys::abi::usercalls::alloc::*; } /// Lowest-level interfaces to usercalls and usercall ABI type definitions. pub mod raw { - pub use sys::abi::usercalls::raw::{do_usercall, Usercalls as UsercallNrs}; - pub use sys::abi::usercalls::raw::{accept_stream, alloc, async_queues, bind_stream, close, - connect_stream, exit, flush, free, insecure_time, + pub use crate::sys::abi::usercalls::raw::{do_usercall, Usercalls as UsercallNrs}; + pub use crate::sys::abi::usercalls::raw::{accept_stream, alloc, async_queues, bind_stream, + close, connect_stream, exit, flush, free, insecure_time, launch_thread, read, read_alloc, send, wait, write}; // fortanix-sgx-abi re-exports - pub use sys::abi::usercalls::raw::{ByteBuffer, FifoDescriptor, Return, Usercall}; - pub use sys::abi::usercalls::raw::Error; - pub use sys::abi::usercalls::raw::{EV_RETURNQ_NOT_EMPTY, EV_UNPARK, EV_USERCALLQ_NOT_FULL, - FD_STDERR, FD_STDIN, FD_STDOUT, RESULT_SUCCESS, - USERCALL_USER_DEFINED, WAIT_INDEFINITE, WAIT_NO}; - pub use sys::abi::usercalls::raw::{Fd, Result, Tcs}; + pub use crate::sys::abi::usercalls::raw::{ByteBuffer, FifoDescriptor, Return, Usercall}; + pub use crate::sys::abi::usercalls::raw::Error; + pub use crate::sys::abi::usercalls::raw::{EV_RETURNQ_NOT_EMPTY, EV_UNPARK, + EV_USERCALLQ_NOT_FULL, FD_STDERR, FD_STDIN, FD_STDOUT, + RESULT_SUCCESS, USERCALL_USER_DEFINED, WAIT_INDEFINITE, + WAIT_NO}; + pub use crate::sys::abi::usercalls::raw::{Fd, Result, Tcs}; } } /// Functions for querying mapping information for pointers. pub mod mem { - pub use sys::abi::mem::*; + pub use crate::sys::abi::mem::*; } -pub use sys::ext::{io, arch, ffi}; +pub use crate::sys::ext::{io, arch, ffi}; diff --git a/src/libstd/os/freebsd/fs.rs b/src/libstd/os/freebsd/fs.rs index 1b4a0fcfa7c1e..4cc3a4b91fbd8 100644 --- a/src/libstd/os/freebsd/fs.rs +++ b/src/libstd/os/freebsd/fs.rs @@ -1,12 +1,10 @@ #![stable(feature = "metadata_ext", since = "1.1.0")] -use libc; - -use fs::Metadata; -use sys_common::AsInner; +use crate::fs::Metadata; +use crate::sys_common::AsInner; #[allow(deprecated)] -use os::freebsd::raw; +use crate::os::freebsd::raw; /// OS-specific extensions to [`fs::Metadata`]. /// diff --git a/src/libstd/os/freebsd/raw.rs b/src/libstd/os/freebsd/raw.rs index 7d90e583b5b9f..0c58154ae607d 100644 --- a/src/libstd/os/freebsd/raw.rs +++ b/src/libstd/os/freebsd/raw.rs @@ -8,7 +8,7 @@ definitions")] #![allow(deprecated)] -use os::raw::c_long; +use crate::os::raw::c_long; #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64; #[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64; diff --git a/src/libstd/os/fuchsia/fs.rs b/src/libstd/os/fuchsia/fs.rs index 8c2d23cb1c2ec..1544bdfbe0cde 100644 --- a/src/libstd/os/fuchsia/fs.rs +++ b/src/libstd/os/fuchsia/fs.rs @@ -1,7 +1,7 @@ #![stable(feature = "metadata_ext", since = "1.1.0")] -use fs::Metadata; -use sys_common::AsInner; +use crate::fs::Metadata; +use crate::sys_common::AsInner; /// OS-specific extensions to [`fs::Metadata`]. /// diff --git a/src/libstd/os/fuchsia/raw.rs b/src/libstd/os/fuchsia/raw.rs index b4a6bd3295c6b..7e44a79b371ce 100644 --- a/src/libstd/os/fuchsia/raw.rs +++ b/src/libstd/os/fuchsia/raw.rs @@ -8,7 +8,7 @@ definitions")] #![allow(deprecated)] -use os::raw::c_ulong; +use crate::os::raw::c_ulong; #[stable(feature = "raw_ext", since = "1.1.0")] pub type dev_t = u64; #[stable(feature = "raw_ext", since = "1.1.0")] pub type mode_t = u32; @@ -25,7 +25,7 @@ pub use self::arch::{off_t, ino_t, nlink_t, blksize_t, blkcnt_t, stat, time_t}; target_arch = "powerpc", target_arch = "arm"))] mod arch { - use os::raw::{c_long, c_short, c_uint}; + use crate::os::raw::{c_long, c_short, c_uint}; #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64; #[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64; @@ -81,7 +81,7 @@ mod arch { #[cfg(target_arch = "mips")] mod arch { - use os::raw::{c_long, c_ulong}; + use crate::os::raw::{c_long, c_ulong}; #[cfg(target_env = "musl")] #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = i64; @@ -151,7 +151,7 @@ mod arch { #[cfg(target_arch = "aarch64")] mod arch { - use os::raw::{c_long, c_int}; + use crate::os::raw::{c_long, c_int}; #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64; #[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64; @@ -207,7 +207,7 @@ mod arch { #[cfg(target_arch = "x86_64")] mod arch { - use os::raw::{c_long, c_int}; + use crate::os::raw::{c_long, c_int}; #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64; #[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64; diff --git a/src/libstd/os/haiku/fs.rs b/src/libstd/os/haiku/fs.rs index 2ed1ca975d8b6..4097f8c26a62f 100644 --- a/src/libstd/os/haiku/fs.rs +++ b/src/libstd/os/haiku/fs.rs @@ -1,12 +1,10 @@ #![stable(feature = "metadata_ext", since = "1.1.0")] -use libc; - -use fs::Metadata; -use sys_common::AsInner; +use crate::fs::Metadata; +use crate::sys_common::AsInner; #[allow(deprecated)] -use os::haiku::raw; +use crate::os::haiku::raw; /// OS-specific extensions to [`fs::Metadata`]. /// diff --git a/src/libstd/os/haiku/raw.rs b/src/libstd/os/haiku/raw.rs index e6af8f29807cf..d86f4f3ba57cb 100644 --- a/src/libstd/os/haiku/raw.rs +++ b/src/libstd/os/haiku/raw.rs @@ -4,8 +4,8 @@ #![allow(deprecated)] -use os::raw::{c_long}; -use os::unix::raw::{uid_t, gid_t}; +use crate::os::raw::{c_long}; +use crate::os::unix::raw::{uid_t, gid_t}; // Use the direct definition of usize, instead of uintptr_t like in libc #[stable(feature = "pthread_t", since = "1.8.0")] pub type pthread_t = usize; diff --git a/src/libstd/os/hermit/fs.rs b/src/libstd/os/hermit/fs.rs index b94324475e5ad..eb28a839ba865 100644 --- a/src/libstd/os/hermit/fs.rs +++ b/src/libstd/os/hermit/fs.rs @@ -1,12 +1,10 @@ #![stable(feature = "metadata_ext", since = "1.1.0")] -use libc; - -use fs::Metadata; -use sys_common::AsInner; +use crate::fs::Metadata; +use crate::sys_common::AsInner; #[allow(deprecated)] -use os::hermit::raw; +use crate::os::hermit::raw; /// OS-specific extensions to [`fs::Metadata`]. /// diff --git a/src/libstd/os/ios/fs.rs b/src/libstd/os/ios/fs.rs index 7f0bdb80b20d6..7b625f5e3fe36 100644 --- a/src/libstd/os/ios/fs.rs +++ b/src/libstd/os/ios/fs.rs @@ -1,12 +1,10 @@ #![stable(feature = "metadata_ext", since = "1.1.0")] -use libc; - -use fs::Metadata; -use sys_common::AsInner; +use crate::fs::Metadata; +use crate::sys_common::AsInner; #[allow(deprecated)] -use os::ios::raw; +use crate::os::ios::raw; /// OS-specific extensions to [`fs::Metadata`]. /// diff --git a/src/libstd/os/ios/raw.rs b/src/libstd/os/ios/raw.rs index 1b528ce8c91b6..fa38bca09e26a 100644 --- a/src/libstd/os/ios/raw.rs +++ b/src/libstd/os/ios/raw.rs @@ -8,7 +8,7 @@ definitions")] #![allow(deprecated)] -use os::raw::c_long; +use crate::os::raw::c_long; #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64; #[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64; diff --git a/src/libstd/os/linux/fs.rs b/src/libstd/os/linux/fs.rs index 572d814fc0696..ec5e98370768d 100644 --- a/src/libstd/os/linux/fs.rs +++ b/src/libstd/os/linux/fs.rs @@ -1,12 +1,10 @@ #![stable(feature = "metadata_ext", since = "1.1.0")] -use libc; - -use fs::Metadata; -use sys_common::AsInner; +use crate::fs::Metadata; +use crate::sys_common::AsInner; #[allow(deprecated)] -use os::linux::raw; +use crate::os::linux::raw; /// OS-specific extensions to [`fs::Metadata`]. /// diff --git a/src/libstd/os/linux/raw.rs b/src/libstd/os/linux/raw.rs index e5ab8a839cb7b..77eeacb4b477c 100644 --- a/src/libstd/os/linux/raw.rs +++ b/src/libstd/os/linux/raw.rs @@ -9,7 +9,7 @@ #![allow(deprecated)] #![allow(missing_debug_implementations)] -use os::raw::c_ulong; +use crate::os::raw::c_ulong; #[stable(feature = "raw_ext", since = "1.1.0")] pub type dev_t = u64; #[stable(feature = "raw_ext", since = "1.1.0")] pub type mode_t = u32; @@ -28,7 +28,7 @@ pub use self::arch::{off_t, ino_t, nlink_t, blksize_t, blkcnt_t, stat, time_t}; target_arch = "asmjs", target_arch = "wasm32"))] mod arch { - use os::raw::{c_long, c_short, c_uint}; + use crate::os::raw::{c_long, c_short, c_uint}; #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64; #[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64; @@ -84,7 +84,7 @@ mod arch { #[cfg(target_arch = "mips")] mod arch { - use os::raw::{c_long, c_ulong}; + use crate::os::raw::{c_long, c_ulong}; #[cfg(target_env = "musl")] #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = i64; @@ -156,7 +156,7 @@ mod arch { #[cfg(target_arch = "aarch64")] mod arch { - use os::raw::{c_long, c_int}; + use crate::os::raw::{c_long, c_int}; #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64; #[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64; @@ -212,7 +212,7 @@ mod arch { #[cfg(any(target_arch = "x86_64", target_arch = "powerpc64"))] mod arch { - use os::raw::{c_long, c_int}; + use crate::os::raw::{c_long, c_int}; #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64; #[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64; diff --git a/src/libstd/os/macos/fs.rs b/src/libstd/os/macos/fs.rs index 1227fc46fcdc1..1bd66ad4c764c 100644 --- a/src/libstd/os/macos/fs.rs +++ b/src/libstd/os/macos/fs.rs @@ -1,12 +1,10 @@ #![stable(feature = "metadata_ext", since = "1.1.0")] -use libc; - -use fs::Metadata; -use sys_common::AsInner; +use crate::fs::Metadata; +use crate::sys_common::AsInner; #[allow(deprecated)] -use os::macos::raw; +use crate::os::macos::raw; /// OS-specific extensions to [`fs::Metadata`]. /// diff --git a/src/libstd/os/macos/raw.rs b/src/libstd/os/macos/raw.rs index 684cb891e0012..5685642c07ff8 100644 --- a/src/libstd/os/macos/raw.rs +++ b/src/libstd/os/macos/raw.rs @@ -8,7 +8,7 @@ definitions")] #![allow(deprecated)] -use os::raw::c_long; +use crate::os::raw::c_long; #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64; #[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64; diff --git a/src/libstd/os/mod.rs b/src/libstd/os/mod.rs index 6215ba47e30a8..5cce3df71d6a9 100644 --- a/src/libstd/os/mod.rs +++ b/src/libstd/os/mod.rs @@ -12,10 +12,10 @@ cfg_if! { // cross-platform way in the documentation #[stable(feature = "rust1", since = "1.0.0")] - pub use sys::unix_ext as unix; + pub use crate::sys::unix_ext as unix; #[stable(feature = "rust1", since = "1.0.0")] - pub use sys::windows_ext as windows; + pub use crate::sys::windows_ext as windows; #[doc(cfg(target_os = "linux"))] pub mod linux; @@ -26,11 +26,11 @@ cfg_if! { #[cfg(any(target_os = "redox", unix))] #[stable(feature = "rust1", since = "1.0.0")] - pub use sys::ext as unix; + pub use crate::sys::ext as unix; #[cfg(windows)] #[stable(feature = "rust1", since = "1.0.0")] - pub use sys::ext as windows; + pub use crate::sys::ext as windows; #[cfg(any(target_os = "linux", target_os = "l4re"))] pub mod linux; diff --git a/src/libstd/os/netbsd/fs.rs b/src/libstd/os/netbsd/fs.rs index 7022013e9dd29..6dffb70b5dc7b 100644 --- a/src/libstd/os/netbsd/fs.rs +++ b/src/libstd/os/netbsd/fs.rs @@ -1,12 +1,10 @@ #![stable(feature = "metadata_ext", since = "1.1.0")] -use libc; - -use fs::Metadata; -use sys_common::AsInner; +use crate::fs::Metadata; +use crate::sys_common::AsInner; #[allow(deprecated)] -use os::netbsd::raw; +use crate::os::netbsd::raw; /// OS-specific extensions to [`fs::Metadata`]. /// diff --git a/src/libstd/os/netbsd/raw.rs b/src/libstd/os/netbsd/raw.rs index f02bae801a24b..1d5d5c6891e3f 100644 --- a/src/libstd/os/netbsd/raw.rs +++ b/src/libstd/os/netbsd/raw.rs @@ -8,8 +8,8 @@ definitions")] #![allow(deprecated)] -use os::raw::c_long; -use os::unix::raw::{uid_t, gid_t}; +use crate::os::raw::c_long; +use crate::os::unix::raw::{uid_t, gid_t}; #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64; #[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64; diff --git a/src/libstd/os/openbsd/fs.rs b/src/libstd/os/openbsd/fs.rs index 4d9749199f94d..73f9757f3b794 100644 --- a/src/libstd/os/openbsd/fs.rs +++ b/src/libstd/os/openbsd/fs.rs @@ -1,12 +1,10 @@ #![stable(feature = "metadata_ext", since = "1.1.0")] -use libc; - -use fs::Metadata; -use sys_common::AsInner; +use crate::fs::Metadata; +use crate::sys_common::AsInner; #[allow(deprecated)] -use os::openbsd::raw; +use crate::os::openbsd::raw; /// OS-specific extensions to [`fs::Metadata`]. /// diff --git a/src/libstd/os/openbsd/raw.rs b/src/libstd/os/openbsd/raw.rs index 27710ca6ce7b0..094168453d792 100644 --- a/src/libstd/os/openbsd/raw.rs +++ b/src/libstd/os/openbsd/raw.rs @@ -8,7 +8,7 @@ definitions")] #![allow(deprecated)] -use os::raw::c_long; +use crate::os::raw::c_long; #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64; #[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64; diff --git a/src/libstd/os/raw/mod.rs b/src/libstd/os/raw/mod.rs index 78288a6a1f0ca..e9043b4b40d73 100644 --- a/src/libstd/os/raw/mod.rs +++ b/src/libstd/os/raw/mod.rs @@ -86,9 +86,8 @@ pub use core::ffi::c_void; #[cfg(test)] #[allow(unused_imports)] mod tests { - use any::TypeId; - use libc; - use mem; + use crate::any::TypeId; + use crate::mem; macro_rules! ok { ($($t:ident)*) => {$( @@ -99,7 +98,7 @@ mod tests { #[test] fn same() { - use os::raw; + use crate::os::raw; ok!(c_char c_schar c_uchar c_short c_ushort c_int c_uint c_long c_ulong c_longlong c_ulonglong c_float c_double); } diff --git a/src/libstd/os/solaris/fs.rs b/src/libstd/os/solaris/fs.rs index f2f89b5dd8bcc..55a8d5d1ef007 100644 --- a/src/libstd/os/solaris/fs.rs +++ b/src/libstd/os/solaris/fs.rs @@ -1,12 +1,10 @@ #![stable(feature = "metadata_ext", since = "1.1.0")] -use libc; - -use fs::Metadata; -use sys_common::AsInner; +use crate::fs::Metadata; +use crate::sys_common::AsInner; #[allow(deprecated)] -use os::solaris::raw; +use crate::os::solaris::raw; /// OS-specific extensions to [`fs::Metadata`]. /// diff --git a/src/libstd/os/solaris/raw.rs b/src/libstd/os/solaris/raw.rs index 3c2c063ca41ee..93270efea2b68 100644 --- a/src/libstd/os/solaris/raw.rs +++ b/src/libstd/os/solaris/raw.rs @@ -8,8 +8,8 @@ definitions")] #![allow(deprecated)] -use os::raw::c_long; -use os::unix::raw::{uid_t, gid_t}; +use crate::os::raw::c_long; +use crate::os::unix::raw::{uid_t, gid_t}; #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64; #[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64; diff --git a/src/libstd/panic.rs b/src/libstd/panic.rs index daeac7107a56c..6a16414c1417e 100644 --- a/src/libstd/panic.rs +++ b/src/libstd/panic.rs @@ -2,21 +2,21 @@ #![stable(feature = "std_panic", since = "1.9.0")] -use any::Any; -use cell::UnsafeCell; -use fmt; -use future::Future; -use pin::Pin; -use ops::{Deref, DerefMut}; -use panicking; -use ptr::{Unique, NonNull}; -use rc::Rc; -use sync::{Arc, Mutex, RwLock, atomic}; -use task::{Waker, Poll}; -use thread::Result; +use crate::any::Any; +use crate::cell::UnsafeCell; +use crate::fmt; +use crate::future::Future; +use crate::pin::Pin; +use crate::ops::{Deref, DerefMut}; +use crate::panicking; +use crate::ptr::{Unique, NonNull}; +use crate::rc::Rc; +use crate::sync::{Arc, Mutex, RwLock, atomic}; +use crate::task::{Waker, Poll}; +use crate::thread::Result; #[stable(feature = "panic_hooks", since = "1.10.0")] -pub use panicking::{take_hook, set_hook}; +pub use crate::panicking::{take_hook, set_hook}; #[stable(feature = "panic_hooks", since = "1.10.0")] pub use core::panic::{PanicInfo, Location}; @@ -385,7 +385,7 @@ impl Future for AssertUnwindSafe { #[stable(feature = "catch_unwind", since = "1.9.0")] pub fn catch_unwind R + UnwindSafe, R>(f: F) -> Result { unsafe { - panicking::try(f) + panicking::r#try(f) } } diff --git a/src/libstd/panicking.rs b/src/libstd/panicking.rs index aaffc9bad4547..868b309686cf6 100644 --- a/src/libstd/panicking.rs +++ b/src/libstd/panicking.rs @@ -8,22 +8,22 @@ //! * Shims around "try" use core::panic::BoxMeUp; - -use io::prelude::*; - -use any::Any; -use cell::RefCell; use core::panic::{PanicInfo, Location}; -use fmt; -use intrinsics; -use mem; -use ptr; -use raw; -use sys::stdio::panic_output; -use sys_common::rwlock::RWLock; -use sys_common::thread_info; -use sys_common::util; -use thread; + +use crate::io::prelude::*; + +use crate::any::Any; +use crate::cell::RefCell; +use crate::fmt; +use crate::intrinsics; +use crate::mem; +use crate::ptr; +use crate::raw; +use crate::sys::stdio::panic_output; +use crate::sys_common::rwlock::RWLock; +use crate::sys_common::thread_info; +use crate::sys_common::util; +use crate::thread; thread_local! { pub static LOCAL_STDERR: RefCell>> = { @@ -159,7 +159,7 @@ pub fn take_hook() -> Box { fn default_hook(info: &PanicInfo) { #[cfg(feature = "backtrace")] - use sys_common::backtrace; + use crate::sys_common::backtrace; // If this is a double panic, make sure that we print a backtrace // for this panic. Otherwise only print it if logging is enabled. @@ -186,13 +186,13 @@ fn default_hook(info: &PanicInfo) { let thread = thread_info::current_thread(); let name = thread.as_ref().and_then(|t| t.name()).unwrap_or(""); - let write = |err: &mut dyn (::io::Write)| { + let write = |err: &mut dyn crate::io::Write| { let _ = writeln!(err, "thread '{}' panicked at '{}', {}", name, msg, location); #[cfg(feature = "backtrace")] { - use sync::atomic::{AtomicBool, Ordering}; + use crate::sync::atomic::{AtomicBool, Ordering}; static FIRST_PANIC: AtomicBool = AtomicBool::new(true); @@ -221,7 +221,7 @@ fn default_hook(info: &PanicInfo) { #[doc(hidden)] #[unstable(feature = "update_panic_count", issue = "0")] pub fn update_panic_count(amt: isize) -> usize { - use cell::Cell; + use crate::cell::Cell; thread_local! { static PANIC_COUNT: Cell = Cell::new(0) } PANIC_COUNT.with(|c| { @@ -235,7 +235,7 @@ pub fn update_panic_count(amt: isize) -> usize { pub use realstd::rt::update_panic_count; /// Invoke a closure, capturing the cause of an unwinding panic if one occurs. -pub unsafe fn try R>(f: F) -> Result> { +pub unsafe fn r#try R>(f: F) -> Result> { #[allow(unions_with_drop_fields)] union Data { f: F, @@ -352,7 +352,7 @@ fn continue_panic_fmt(info: &PanicInfo) -> ! { } fn fill(&mut self) -> &mut String { - use fmt::Write; + use crate::fmt::Write; let inner = self.inner; self.string.get_or_insert_with(|| { diff --git a/src/libstd/path.rs b/src/libstd/path.rs index 9f91a9f89eb76..858a5778b8161 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -67,22 +67,22 @@ #![stable(feature = "rust1", since = "1.0.0")] -use borrow::{Borrow, Cow}; -use cmp; -use error::Error; -use fmt; -use fs; -use hash::{Hash, Hasher}; -use io; -use iter::{self, FusedIterator}; -use ops::{self, Deref}; -use rc::Rc; -use str::FromStr; -use sync::Arc; - -use ffi::{OsStr, OsString}; - -use sys::path::{is_sep_byte, is_verbatim_sep, MAIN_SEP_STR, parse_prefix}; +use crate::borrow::{Borrow, Cow}; +use crate::cmp; +use crate::error::Error; +use crate::fmt; +use crate::fs; +use crate::hash::{Hash, Hasher}; +use crate::io; +use crate::iter::{self, FusedIterator}; +use crate::ops::{self, Deref}; +use crate::rc::Rc; +use crate::str::FromStr; +use crate::sync::Arc; + +use crate::ffi::{OsStr, OsString}; + +use crate::sys::path::{is_sep_byte, is_verbatim_sep, MAIN_SEP_STR, parse_prefix}; //////////////////////////////////////////////////////////////////////////////// // GENERAL NOTES @@ -279,7 +279,7 @@ pub fn is_separator(c: char) -> bool { /// /// For example, `/` on Unix and `\` on Windows. #[stable(feature = "rust1", since = "1.0.0")] -pub const MAIN_SEPARATOR: char = ::sys::path::MAIN_SEP; +pub const MAIN_SEPARATOR: char = crate::sys::path::MAIN_SEP; //////////////////////////////////////////////////////////////////////////////// // Misc helpers @@ -2819,8 +2819,8 @@ impl Error for StripPrefixError { mod tests { use super::*; - use rc::Rc; - use sync::Arc; + use crate::rc::Rc; + use crate::sync::Arc; macro_rules! t( ($path:expr, iter: $iter:expr) => ( @@ -2907,7 +2907,7 @@ mod tests { #[test] fn into() { - use borrow::Cow; + use crate::borrow::Cow; let static_path = Path::new("/home/foo"); let static_cow_path: Cow<'static, Path> = static_path.into(); @@ -4007,7 +4007,7 @@ mod tests { #[test] fn test_eq_receivers() { - use borrow::Cow; + use crate::borrow::Cow; let borrowed: &Path = Path::new("foo/bar"); let mut owned: PathBuf = PathBuf::new(); @@ -4032,8 +4032,8 @@ mod tests { #[test] pub fn test_compare() { - use hash::{Hash, Hasher}; - use collections::hash_map::DefaultHasher; + use crate::hash::{Hash, Hasher}; + use crate::collections::hash_map::DefaultHasher; fn hash(t: T) -> u64 { let mut s = DefaultHasher::new(); diff --git a/src/libstd/prelude/v1.rs b/src/libstd/prelude/v1.rs index 3001c899f6202..ce1e8e3319cf8 100644 --- a/src/libstd/prelude/v1.rs +++ b/src/libstd/prelude/v1.rs @@ -9,41 +9,41 @@ // Re-exported core operators #[stable(feature = "rust1", since = "1.0.0")] #[doc(no_inline)] -pub use marker::{Copy, Send, Sized, Sync, Unpin}; +pub use crate::marker::{Copy, Send, Sized, Sync, Unpin}; #[stable(feature = "rust1", since = "1.0.0")] #[doc(no_inline)] -pub use ops::{Drop, Fn, FnMut, FnOnce}; +pub use crate::ops::{Drop, Fn, FnMut, FnOnce}; // Re-exported functions #[stable(feature = "rust1", since = "1.0.0")] #[doc(no_inline)] -pub use mem::drop; +pub use crate::mem::drop; // Re-exported types and traits #[stable(feature = "rust1", since = "1.0.0")] #[doc(no_inline)] -pub use clone::Clone; +pub use crate::clone::Clone; #[stable(feature = "rust1", since = "1.0.0")] #[doc(no_inline)] -pub use cmp::{PartialEq, PartialOrd, Eq, Ord}; +pub use crate::cmp::{PartialEq, PartialOrd, Eq, Ord}; #[stable(feature = "rust1", since = "1.0.0")] #[doc(no_inline)] -pub use convert::{AsRef, AsMut, Into, From}; +pub use crate::convert::{AsRef, AsMut, Into, From}; #[stable(feature = "rust1", since = "1.0.0")] #[doc(no_inline)] -pub use default::Default; +pub use crate::default::Default; #[stable(feature = "rust1", since = "1.0.0")] #[doc(no_inline)] -pub use iter::{Iterator, Extend, IntoIterator}; +pub use crate::iter::{Iterator, Extend, IntoIterator}; #[stable(feature = "rust1", since = "1.0.0")] #[doc(no_inline)] -pub use iter::{DoubleEndedIterator, ExactSizeIterator}; +pub use crate::iter::{DoubleEndedIterator, ExactSizeIterator}; #[stable(feature = "rust1", since = "1.0.0")] #[doc(no_inline)] -pub use option::Option::{self, Some, None}; +pub use crate::option::Option::{self, Some, None}; #[stable(feature = "rust1", since = "1.0.0")] #[doc(no_inline)] -pub use result::Result::{self, Ok, Err}; +pub use crate::result::Result::{self, Ok, Err}; // The file so far is equivalent to src/libcore/prelude/v1.rs, @@ -54,16 +54,16 @@ pub use result::Result::{self, Ok, Err}; #[stable(feature = "rust1", since = "1.0.0")] #[doc(no_inline)] -pub use boxed::Box; +pub use crate::boxed::Box; #[stable(feature = "rust1", since = "1.0.0")] #[doc(no_inline)] -pub use borrow::ToOwned; +pub use crate::borrow::ToOwned; #[stable(feature = "rust1", since = "1.0.0")] #[doc(no_inline)] -pub use slice::SliceConcatExt; +pub use crate::slice::SliceConcatExt; #[stable(feature = "rust1", since = "1.0.0")] #[doc(no_inline)] -pub use string::{String, ToString}; +pub use crate::string::{String, ToString}; #[stable(feature = "rust1", since = "1.0.0")] #[doc(no_inline)] -pub use vec::Vec; +pub use crate::vec::Vec; diff --git a/src/libstd/process.rs b/src/libstd/process.rs index 735ce61c9bc29..568400093440c 100644 --- a/src/libstd/process.rs +++ b/src/libstd/process.rs @@ -106,17 +106,17 @@ #![stable(feature = "process", since = "1.0.0")] -use io::prelude::*; - -use ffi::OsStr; -use fmt; -use fs; -use io::{self, Initializer}; -use path::Path; -use str; -use sys::pipe::{read2, AnonPipe}; -use sys::process as imp; -use sys_common::{AsInner, AsInnerMut, FromInner, IntoInner}; +use crate::io::prelude::*; + +use crate::ffi::OsStr; +use crate::fmt; +use crate::fs; +use crate::io::{self, Initializer}; +use crate::path::Path; +use crate::str; +use crate::sys::pipe::{read2, AnonPipe}; +use crate::sys::process as imp; +use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner}; /// Representation of a running or exited child process. /// @@ -1481,8 +1481,8 @@ impl Child { /// [platform-specific behavior]: #platform-specific-behavior #[stable(feature = "rust1", since = "1.0.0")] pub fn exit(code: i32) -> ! { - ::sys_common::cleanup(); - ::sys::os::exit(code) + crate::sys_common::cleanup(); + crate::sys::os::exit(code) } /// Terminates the process in an abnormal fashion. @@ -1543,7 +1543,7 @@ pub fn exit(code: i32) -> ! { /// [panic hook]: ../../std/panic/fn.set_hook.html #[stable(feature = "process_abort", since = "1.17.0")] pub fn abort() -> ! { - unsafe { ::sys::abort_internal() }; + unsafe { crate::sys::abort_internal() }; } /// Returns the OS-assigned process identifier associated with this process. @@ -1561,7 +1561,7 @@ pub fn abort() -> ! { /// #[stable(feature = "getpid", since = "1.26.0")] pub fn id() -> u32 { - ::sys::os::getpid() + crate::sys::os::getpid() } /// A trait for implementing arbitrary return types in the `main` function. @@ -1623,10 +1623,10 @@ impl Termination for ExitCode { #[cfg(all(test, not(any(target_os = "cloudabi", target_os = "emscripten"))))] mod tests { - use io::prelude::*; + use crate::io::prelude::*; - use io::ErrorKind; - use str; + use crate::io::ErrorKind; + use crate::str; use super::{Command, Output, Stdio}; // FIXME(#10380) these tests should not all be ignored on android. @@ -1671,7 +1671,7 @@ mod tests { #[cfg(unix)] #[cfg_attr(target_os = "android", ignore)] fn signal_reported_right() { - use os::unix::process::ExitStatusExt; + use crate::os::unix::process::ExitStatusExt; let mut p = Command::new("/bin/sh") .arg("-c").arg("read a") @@ -1741,8 +1741,8 @@ mod tests { #[cfg_attr(target_os = "android", ignore)] #[cfg(unix)] fn uid_works() { - use os::unix::prelude::*; - use libc; + use crate::os::unix::prelude::*; + let mut p = Command::new("/bin/sh") .arg("-c").arg("true") .uid(unsafe { libc::getuid() }) @@ -1755,8 +1755,7 @@ mod tests { #[cfg_attr(target_os = "android", ignore)] #[cfg(unix)] fn uid_to_root_fails() { - use os::unix::prelude::*; - use libc; + use crate::os::unix::prelude::*; // if we're already root, this isn't a valid test. Most of the bots run // as non-root though (android is an exception). @@ -1881,7 +1880,7 @@ mod tests { #[test] fn test_override_env() { - use env; + use crate::env; // In some build environments (such as chrooted Nix builds), `env` can // only be found in the explicitly-provided PATH env variable, not in @@ -1910,7 +1909,7 @@ mod tests { #[test] fn test_capture_env_at_spawn() { - use env; + use crate::env; let mut cmd = env_cmd(); cmd.env("RUN_TEST_NEW_ENV1", "123"); @@ -1985,8 +1984,8 @@ mod tests { #[test] #[cfg(windows)] fn test_creation_flags() { - use os::windows::process::CommandExt; - use sys::c::{BOOL, DWORD, INFINITE}; + use crate::os::windows::process::CommandExt; + use crate::sys::c::{BOOL, DWORD, INFINITE}; #[repr(C, packed)] struct DEBUG_EVENT { pub event_code: DWORD, diff --git a/src/libstd/rt.rs b/src/libstd/rt.rs index 5ddb66b1897ee..cf45eb0daba39 100644 --- a/src/libstd/rt.rs +++ b/src/libstd/rt.rs @@ -14,18 +14,18 @@ // Re-export some of our utilities which are expected by other crates. -pub use panicking::{begin_panic, begin_panic_fmt, update_panic_count}; +pub use crate::panicking::{begin_panic, begin_panic_fmt, update_panic_count}; // To reduce the generated code of the new `lang_start`, this function is doing // the real work. #[cfg(not(test))] -fn lang_start_internal(main: &(dyn Fn() -> i32 + Sync + ::panic::RefUnwindSafe), +fn lang_start_internal(main: &(dyn Fn() -> i32 + Sync + crate::panic::RefUnwindSafe), argc: isize, argv: *const *const u8) -> isize { - use panic; - use sys; - use sys_common; - use sys_common::thread_info; - use thread::Thread; + use crate::panic; + use crate::sys; + use crate::sys_common; + use crate::sys_common::thread_info; + use crate::thread::Thread; sys::init(); @@ -46,7 +46,7 @@ fn lang_start_internal(main: &(dyn Fn() -> i32 + Sync + ::panic::RefUnwindSafe), // Let's run some code! #[cfg(feature = "backtrace")] let exit_code = panic::catch_unwind(|| { - ::sys_common::backtrace::__rust_begin_short_backtrace(move || main()) + sys_common::backtrace::__rust_begin_short_backtrace(move || main()) }); #[cfg(not(feature = "backtrace"))] let exit_code = panic::catch_unwind(move || main()); @@ -58,7 +58,7 @@ fn lang_start_internal(main: &(dyn Fn() -> i32 + Sync + ::panic::RefUnwindSafe), #[cfg(not(test))] #[lang = "start"] -fn lang_start +fn lang_start (main: fn() -> T, argc: isize, argv: *const *const u8) -> isize { lang_start_internal(&move || main().report(), argc, argv) diff --git a/src/libstd/sync/barrier.rs b/src/libstd/sync/barrier.rs index bc2e14d436a99..a4205daba8b6e 100644 --- a/src/libstd/sync/barrier.rs +++ b/src/libstd/sync/barrier.rs @@ -1,5 +1,5 @@ -use fmt; -use sync::{Mutex, Condvar}; +use crate::fmt; +use crate::sync::{Mutex, Condvar}; /// A barrier enables multiple threads to synchronize the beginning /// of some computation. @@ -181,9 +181,9 @@ impl BarrierWaitResult { #[cfg(test)] mod tests { - use sync::{Arc, Barrier}; - use sync::mpsc::{channel, TryRecvError}; - use thread; + use crate::sync::{Arc, Barrier}; + use crate::sync::mpsc::{channel, TryRecvError}; + use crate::thread; #[test] #[cfg_attr(target_os = "emscripten", ignore)] diff --git a/src/libstd/sync/condvar.rs b/src/libstd/sync/condvar.rs index 036aff090ead9..5ebb61754e1ff 100644 --- a/src/libstd/sync/condvar.rs +++ b/src/libstd/sync/condvar.rs @@ -1,10 +1,10 @@ -use fmt; -use sync::atomic::{AtomicUsize, Ordering}; -use sync::{mutex, MutexGuard, PoisonError}; -use sys_common::condvar as sys; -use sys_common::mutex as sys_mutex; -use sys_common::poison::{self, LockResult}; -use time::{Duration, Instant}; +use crate::fmt; +use crate::sync::atomic::{AtomicUsize, Ordering}; +use crate::sync::{mutex, MutexGuard, PoisonError}; +use crate::sys_common::condvar as sys; +use crate::sys_common::mutex as sys_mutex; +use crate::sys_common::poison::{self, LockResult}; +use crate::time::{Duration, Instant}; /// A type indicating whether a timed wait on a condition variable returned /// due to a time out or not. @@ -612,12 +612,12 @@ impl Drop for Condvar { #[cfg(test)] mod tests { /// #![feature(wait_until)] - use sync::mpsc::channel; - use sync::{Condvar, Mutex, Arc}; - use sync::atomic::{AtomicBool, Ordering}; - use thread; - use time::Duration; - use u64; + use crate::sync::mpsc::channel; + use crate::sync::{Condvar, Mutex, Arc}; + use crate::sync::atomic::{AtomicBool, Ordering}; + use crate::thread; + use crate::time::Duration; + use crate::u64; #[test] fn smoke() { diff --git a/src/libstd/sync/mod.rs b/src/libstd/sync/mod.rs index 3d11af7dc10e9..809ee8826981b 100644 --- a/src/libstd/sync/mod.rs +++ b/src/libstd/sync/mod.rs @@ -165,7 +165,7 @@ pub use self::mutex::{Mutex, MutexGuard}; #[stable(feature = "rust1", since = "1.0.0")] pub use self::once::{Once, OnceState, ONCE_INIT}; #[stable(feature = "rust1", since = "1.0.0")] -pub use sys_common::poison::{PoisonError, TryLockError, TryLockResult, LockResult}; +pub use crate::sys_common::poison::{PoisonError, TryLockError, TryLockResult, LockResult}; #[stable(feature = "rust1", since = "1.0.0")] pub use self::rwlock::{RwLock, RwLockReadGuard, RwLockWriteGuard}; diff --git a/src/libstd/sync/mpsc/blocking.rs b/src/libstd/sync/mpsc/blocking.rs index eaf09a16756b2..6eacfaec25358 100644 --- a/src/libstd/sync/mpsc/blocking.rs +++ b/src/libstd/sync/mpsc/blocking.rs @@ -1,10 +1,10 @@ //! Generic support for building blocking abstractions. -use thread::{self, Thread}; -use sync::atomic::{AtomicBool, Ordering}; -use sync::Arc; -use mem; -use time::Instant; +use crate::thread::{self, Thread}; +use crate::sync::atomic::{AtomicBool, Ordering}; +use crate::sync::Arc; +use crate::mem; +use crate::time::Instant; struct Inner { thread: Thread, diff --git a/src/libstd/sync/mpsc/cache_aligned.rs b/src/libstd/sync/mpsc/cache_aligned.rs index fb1177e03506c..b14a9e5d61bd9 100644 --- a/src/libstd/sync/mpsc/cache_aligned.rs +++ b/src/libstd/sync/mpsc/cache_aligned.rs @@ -1,4 +1,4 @@ -use ops::{Deref, DerefMut}; +use crate::ops::{Deref, DerefMut}; #[derive(Copy, Clone, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] #[repr(align(64))] diff --git a/src/libstd/sync/mpsc/mod.rs b/src/libstd/sync/mpsc/mod.rs index 5273345c6b4fd..90c5c50c23b9c 100644 --- a/src/libstd/sync/mpsc/mod.rs +++ b/src/libstd/sync/mpsc/mod.rs @@ -266,12 +266,12 @@ // And now that you've seen all the races that I found and attempted to fix, // here's the code for you to find some more! -use sync::Arc; -use error; -use fmt; -use mem; -use cell::UnsafeCell; -use time::{Duration, Instant}; +use crate::sync::Arc; +use crate::error; +use crate::fmt; +use crate::mem; +use crate::cell::UnsafeCell; +use crate::time::{Duration, Instant}; #[unstable(feature = "mpsc_select", issue = "27800")] pub use self::select::{Select, Handle}; @@ -1822,10 +1822,10 @@ impl From for RecvTimeoutError { #[cfg(all(test, not(target_os = "emscripten")))] mod tests { - use env; use super::*; - use thread; - use time::{Duration, Instant}; + use crate::env; + use crate::thread; + use crate::time::{Duration, Instant}; pub fn stress_factor() -> usize { match env::var("RUST_TEST_STRESS") { @@ -2514,10 +2514,10 @@ mod tests { #[cfg(all(test, not(target_os = "emscripten")))] mod sync_tests { - use env; - use thread; use super::*; - use time::Duration; + use crate::env; + use crate::thread; + use crate::time::Duration; pub fn stress_factor() -> usize { match env::var("RUST_TEST_STRESS") { diff --git a/src/libstd/sync/mpsc/mpsc_queue.rs b/src/libstd/sync/mpsc/mpsc_queue.rs index 794d11f1eac99..8f5681b97f44d 100644 --- a/src/libstd/sync/mpsc/mpsc_queue.rs +++ b/src/libstd/sync/mpsc/mpsc_queue.rs @@ -15,8 +15,9 @@ pub use self::PopResult::*; use core::ptr; use core::cell::UnsafeCell; -use boxed::Box; -use sync::atomic::{AtomicPtr, Ordering}; + +use crate::boxed::Box; +use crate::sync::atomic::{AtomicPtr, Ordering}; /// A result of the `pop` function. pub enum PopResult { @@ -120,10 +121,10 @@ impl Drop for Queue { #[cfg(all(test, not(target_os = "emscripten")))] mod tests { - use sync::mpsc::channel; use super::{Queue, Data, Empty, Inconsistent}; - use sync::Arc; - use thread; + use crate::sync::mpsc::channel; + use crate::sync::Arc; + use crate::thread; #[test] fn test_full() { diff --git a/src/libstd/sync/mpsc/oneshot.rs b/src/libstd/sync/mpsc/oneshot.rs index 36928c428e331..5c516d5de0f17 100644 --- a/src/libstd/sync/mpsc/oneshot.rs +++ b/src/libstd/sync/mpsc/oneshot.rs @@ -27,12 +27,12 @@ pub use self::UpgradeResult::*; pub use self::SelectionResult::*; use self::MyUpgrade::*; -use sync::mpsc::Receiver; -use sync::mpsc::blocking::{self, SignalToken}; -use cell::UnsafeCell; -use ptr; -use sync::atomic::{AtomicUsize, Ordering}; -use time::Instant; +use crate::sync::mpsc::Receiver; +use crate::sync::mpsc::blocking::{self, SignalToken}; +use crate::cell::UnsafeCell; +use crate::ptr; +use crate::sync::atomic::{AtomicUsize, Ordering}; +use crate::time::Instant; // Various states you can find a port in. const EMPTY: usize = 0; // initial state: no data, no blocked receiver diff --git a/src/libstd/sync/mpsc/select.rs b/src/libstd/sync/mpsc/select.rs index 8591b55dc58ee..19c9490864545 100644 --- a/src/libstd/sync/mpsc/select.rs +++ b/src/libstd/sync/mpsc/select.rs @@ -46,16 +46,14 @@ #![rustc_deprecated(since = "1.32.0", reason = "channel selection will be removed in a future release")] - -use fmt; - use core::cell::{Cell, UnsafeCell}; use core::marker; use core::ptr; use core::usize; -use sync::mpsc::{Receiver, RecvError}; -use sync::mpsc::blocking::{self, SignalToken}; +use crate::fmt; +use crate::sync::mpsc::{Receiver, RecvError}; +use crate::sync::mpsc::blocking::{self, SignalToken}; /// The "receiver set" of the select interface. This structure is used to manage /// a set of receivers which are being selected over. diff --git a/src/libstd/sync/mpsc/select_tests.rs b/src/libstd/sync/mpsc/select_tests.rs index be048511caaec..18d93462c78db 100644 --- a/src/libstd/sync/mpsc/select_tests.rs +++ b/src/libstd/sync/mpsc/select_tests.rs @@ -2,8 +2,8 @@ /// This file exists to hack around https://github.com/rust-lang/rust/issues/47238 -use thread; -use sync::mpsc::*; +use crate::thread; +use crate::sync::mpsc::*; // Don't use the libstd version so we can pull in the right Select structure // (std::comm points at the wrong one) diff --git a/src/libstd/sync/mpsc/shared.rs b/src/libstd/sync/mpsc/shared.rs index 3da73ac0b822e..6a5d861f0e9cd 100644 --- a/src/libstd/sync/mpsc/shared.rs +++ b/src/libstd/sync/mpsc/shared.rs @@ -14,16 +14,16 @@ use core::cmp; use core::intrinsics::abort; use core::isize; -use cell::UnsafeCell; -use ptr; -use sync::atomic::{AtomicUsize, AtomicIsize, AtomicBool, Ordering}; -use sync::mpsc::blocking::{self, SignalToken}; -use sync::mpsc::mpsc_queue as mpsc; -use sync::mpsc::select::StartResult::*; -use sync::mpsc::select::StartResult; -use sync::{Mutex, MutexGuard}; -use thread; -use time::Instant; +use crate::cell::UnsafeCell; +use crate::ptr; +use crate::sync::atomic::{AtomicUsize, AtomicIsize, AtomicBool, Ordering}; +use crate::sync::mpsc::blocking::{self, SignalToken}; +use crate::sync::mpsc::mpsc_queue as mpsc; +use crate::sync::mpsc::select::StartResult::*; +use crate::sync::mpsc::select::StartResult; +use crate::sync::{Mutex, MutexGuard}; +use crate::thread; +use crate::time::Instant; const DISCONNECTED: isize = isize::MIN; const FUDGE: isize = 1024; diff --git a/src/libstd/sync/mpsc/spsc_queue.rs b/src/libstd/sync/mpsc/spsc_queue.rs index b43ccf074a427..0edb1c24e8016 100644 --- a/src/libstd/sync/mpsc/spsc_queue.rs +++ b/src/libstd/sync/mpsc/spsc_queue.rs @@ -6,11 +6,11 @@ // http://www.1024cores.net/home/lock-free-algorithms/queues/unbounded-spsc-queue -use boxed::Box; use core::ptr; use core::cell::UnsafeCell; -use sync::atomic::{AtomicPtr, AtomicUsize, Ordering}; +use crate::boxed::Box; +use crate::sync::atomic::{AtomicPtr, AtomicUsize, Ordering}; use super::cache_aligned::CacheAligned; @@ -233,10 +233,10 @@ impl Drop for Queue(guard: &MutexGuard<'a, T>) -> &'a poison::Fla #[cfg(all(test, not(target_os = "emscripten")))] mod tests { - use sync::mpsc::channel; - use sync::{Arc, Mutex, Condvar}; - use sync::atomic::{AtomicUsize, Ordering}; - use thread; + use crate::sync::mpsc::channel; + use crate::sync::{Arc, Mutex, Condvar}; + use crate::sync::atomic::{AtomicUsize, Ordering}; + use crate::thread; struct Packet(Arc<(Mutex, Condvar)>); diff --git a/src/libstd/sync/once.rs b/src/libstd/sync/once.rs index e207d0170d7b8..a036c2666625c 100644 --- a/src/libstd/sync/once.rs +++ b/src/libstd/sync/once.rs @@ -52,11 +52,11 @@ // You'll find a few more details in the implementation, but that's the gist of // it! -use fmt; -use marker; -use ptr; -use sync::atomic::{AtomicUsize, AtomicBool, Ordering}; -use thread::{self, Thread}; +use crate::fmt; +use crate::marker; +use crate::ptr; +use crate::sync::atomic::{AtomicUsize, AtomicBool, Ordering}; +use crate::thread::{self, Thread}; /// A synchronization primitive which can be used to run a one-time global /// initialization. Useful for one-time initialization for FFI or related @@ -514,9 +514,9 @@ impl OnceState { #[cfg(all(test, not(target_os = "emscripten")))] mod tests { - use panic; - use sync::mpsc::channel; - use thread; + use crate::panic; + use crate::sync::mpsc::channel; + use crate::thread; use super::Once; #[test] diff --git a/src/libstd/sync/rwlock.rs b/src/libstd/sync/rwlock.rs index 7f3cb4f72c7b5..0be83c76d6259 100644 --- a/src/libstd/sync/rwlock.rs +++ b/src/libstd/sync/rwlock.rs @@ -1,10 +1,10 @@ -use cell::UnsafeCell; -use fmt; -use mem; -use ops::{Deref, DerefMut}; -use ptr; -use sys_common::poison::{self, LockResult, TryLockError, TryLockResult}; -use sys_common::rwlock as sys; +use crate::cell::UnsafeCell; +use crate::fmt; +use crate::mem; +use crate::ops::{Deref, DerefMut}; +use crate::ptr; +use crate::sys_common::poison::{self, LockResult, TryLockError, TryLockResult}; +use crate::sys_common::rwlock as sys; /// A reader-writer lock /// @@ -554,10 +554,10 @@ impl Drop for RwLockWriteGuard<'_, T> { #[cfg(all(test, not(target_os = "emscripten")))] mod tests { use rand::{self, Rng}; - use sync::mpsc::channel; - use thread; - use sync::{Arc, RwLock, TryLockError}; - use sync::atomic::{AtomicUsize, Ordering}; + use crate::sync::mpsc::channel; + use crate::thread; + use crate::sync::{Arc, RwLock, TryLockError}; + use crate::sync::atomic::{AtomicUsize, Ordering}; #[derive(Eq, PartialEq, Debug)] struct NonCopy(i32); diff --git a/src/libstd/sys/cloudabi/abi/bitflags.rs b/src/libstd/sys/cloudabi/abi/bitflags.rs index f764cc1df5a5c..306936213ed11 100644 --- a/src/libstd/sys/cloudabi/abi/bitflags.rs +++ b/src/libstd/sys/cloudabi/abi/bitflags.rs @@ -25,8 +25,7 @@ // ignore-license #[cfg(feature = "bitflags")] -#[macro_use] -extern crate bitflags; +use bitflags::bitflags; // Minimal implementation of bitflags! in case we can't depend on the bitflags // crate. Only implements `bits()` and a `from_bits_truncate()` that doesn't diff --git a/src/libstd/sys/cloudabi/abi/cloudabi.rs b/src/libstd/sys/cloudabi/abi/cloudabi.rs index 83d45b3547bc2..2307e2167c5c1 100644 --- a/src/libstd/sys/cloudabi/abi/cloudabi.rs +++ b/src/libstd/sys/cloudabi/abi/cloudabi.rs @@ -1090,10 +1090,10 @@ pub union auxv_union { #[test] #[cfg(target_pointer_width = "32")] fn auxv_layout_test_32() { - assert_eq!(::core::mem::size_of::(), 8); - assert_eq!(::core::mem::align_of::(), 4); + assert_eq!(core::mem::size_of::(), 8); + assert_eq!(core::mem::align_of::(), 4); unsafe { - let obj: auxv = ::core::mem::uninitialized(); + let obj: auxv = core::mem::uninitialized(); let base = &obj as *const _ as usize; assert_eq!(&obj.a_type as *const _ as usize - base, 0); assert_eq!(&obj.union.a_val as *const _ as usize - base, 4); @@ -1103,10 +1103,10 @@ fn auxv_layout_test_32() { #[test] #[cfg(target_pointer_width = "64")] fn auxv_layout_test_64() { - assert_eq!(::core::mem::size_of::(), 16); - assert_eq!(::core::mem::align_of::(), 8); + assert_eq!(core::mem::size_of::(), 16); + assert_eq!(core::mem::align_of::(), 8); unsafe { - let obj: auxv = ::core::mem::uninitialized(); + let obj: auxv = core::mem::uninitialized(); let base = &obj as *const _ as usize; assert_eq!(&obj.a_type as *const _ as usize - base, 0); assert_eq!(&obj.union.a_val as *const _ as usize - base, 8); @@ -1124,10 +1124,10 @@ pub struct ciovec { #[test] #[cfg(target_pointer_width = "32")] fn ciovec_layout_test_32() { - assert_eq!(::core::mem::size_of::(), 8); - assert_eq!(::core::mem::align_of::(), 4); + assert_eq!(core::mem::size_of::(), 8); + assert_eq!(core::mem::align_of::(), 4); unsafe { - let obj: ciovec = ::core::mem::uninitialized(); + let obj: ciovec = core::mem::uninitialized(); let base = &obj as *const _ as usize; assert_eq!(&obj.buf.0 as *const _ as usize - base, 0); assert_eq!(&obj.buf.1 as *const _ as usize - base, 4); @@ -1136,10 +1136,10 @@ fn ciovec_layout_test_32() { #[test] #[cfg(target_pointer_width = "64")] fn ciovec_layout_test_64() { - assert_eq!(::core::mem::size_of::(), 16); - assert_eq!(::core::mem::align_of::(), 8); + assert_eq!(core::mem::size_of::(), 16); + assert_eq!(core::mem::align_of::(), 8); unsafe { - let obj: ciovec = ::core::mem::uninitialized(); + let obj: ciovec = core::mem::uninitialized(); let base = &obj as *const _ as usize; assert_eq!(&obj.buf.0 as *const _ as usize - base, 0); assert_eq!(&obj.buf.1 as *const _ as usize - base, 8); @@ -1164,10 +1164,10 @@ pub struct dirent { } #[test] fn dirent_layout_test() { - assert_eq!(::core::mem::size_of::(), 24); - assert_eq!(::core::mem::align_of::(), 8); + assert_eq!(core::mem::size_of::(), 24); + assert_eq!(core::mem::align_of::(), 8); unsafe { - let obj: dirent = ::core::mem::uninitialized(); + let obj: dirent = core::mem::uninitialized(); let base = &obj as *const _ as usize; assert_eq!(&obj.d_next as *const _ as usize - base, 0); assert_eq!(&obj.d_ino as *const _ as usize - base, 8); @@ -1228,10 +1228,10 @@ pub struct event_proc_terminate { } #[test] fn event_layout_test() { - assert_eq!(::core::mem::size_of::(), 32); - assert_eq!(::core::mem::align_of::(), 8); + assert_eq!(core::mem::size_of::(), 32); + assert_eq!(core::mem::align_of::(), 8); unsafe { - let obj: event = ::core::mem::uninitialized(); + let obj: event = core::mem::uninitialized(); let base = &obj as *const _ as usize; assert_eq!(&obj.userdata as *const _ as usize - base, 0); assert_eq!(&obj.error as *const _ as usize - base, 8); @@ -1262,10 +1262,10 @@ pub struct fdstat { } #[test] fn fdstat_layout_test() { - assert_eq!(::core::mem::size_of::(), 24); - assert_eq!(::core::mem::align_of::(), 8); + assert_eq!(core::mem::size_of::(), 24); + assert_eq!(core::mem::align_of::(), 8); unsafe { - let obj: fdstat = ::core::mem::uninitialized(); + let obj: fdstat = core::mem::uninitialized(); let base = &obj as *const _ as usize; assert_eq!(&obj.fs_filetype as *const _ as usize - base, 0); assert_eq!(&obj.fs_flags as *const _ as usize - base, 2); @@ -1299,10 +1299,10 @@ pub struct filestat { } #[test] fn filestat_layout_test() { - assert_eq!(::core::mem::size_of::(), 56); - assert_eq!(::core::mem::align_of::(), 8); + assert_eq!(core::mem::size_of::(), 56); + assert_eq!(core::mem::align_of::(), 8); unsafe { - let obj: filestat = ::core::mem::uninitialized(); + let obj: filestat = core::mem::uninitialized(); let base = &obj as *const _ as usize; assert_eq!(&obj.st_dev as *const _ as usize - base, 0); assert_eq!(&obj.st_ino as *const _ as usize - base, 8); @@ -1325,10 +1325,10 @@ pub struct iovec { #[test] #[cfg(target_pointer_width = "32")] fn iovec_layout_test_32() { - assert_eq!(::core::mem::size_of::(), 8); - assert_eq!(::core::mem::align_of::(), 4); + assert_eq!(core::mem::size_of::(), 8); + assert_eq!(core::mem::align_of::(), 4); unsafe { - let obj: iovec = ::core::mem::uninitialized(); + let obj: iovec = core::mem::uninitialized(); let base = &obj as *const _ as usize; assert_eq!(&obj.buf.0 as *const _ as usize - base, 0); assert_eq!(&obj.buf.1 as *const _ as usize - base, 4); @@ -1337,10 +1337,10 @@ fn iovec_layout_test_32() { #[test] #[cfg(target_pointer_width = "64")] fn iovec_layout_test_64() { - assert_eq!(::core::mem::size_of::(), 16); - assert_eq!(::core::mem::align_of::(), 8); + assert_eq!(core::mem::size_of::(), 16); + assert_eq!(core::mem::align_of::(), 8); unsafe { - let obj: iovec = ::core::mem::uninitialized(); + let obj: iovec = core::mem::uninitialized(); let base = &obj as *const _ as usize; assert_eq!(&obj.buf.0 as *const _ as usize - base, 0); assert_eq!(&obj.buf.1 as *const _ as usize - base, 8); @@ -1360,10 +1360,10 @@ pub struct lookup { } #[test] fn lookup_layout_test() { - assert_eq!(::core::mem::size_of::(), 8); - assert_eq!(::core::mem::align_of::(), 4); + assert_eq!(core::mem::size_of::(), 8); + assert_eq!(core::mem::align_of::(), 4); unsafe { - let obj: lookup = ::core::mem::uninitialized(); + let obj: lookup = core::mem::uninitialized(); let base = &obj as *const _ as usize; assert_eq!(&obj.fd as *const _ as usize - base, 0); assert_eq!(&obj.flags as *const _ as usize - base, 4); @@ -1394,10 +1394,10 @@ pub struct recv_in { #[test] #[cfg(target_pointer_width = "32")] fn recv_in_layout_test_32() { - assert_eq!(::core::mem::size_of::(), 20); - assert_eq!(::core::mem::align_of::(), 4); + assert_eq!(core::mem::size_of::(), 20); + assert_eq!(core::mem::align_of::(), 4); unsafe { - let obj: recv_in = ::core::mem::uninitialized(); + let obj: recv_in = core::mem::uninitialized(); let base = &obj as *const _ as usize; assert_eq!(&obj.ri_data.0 as *const _ as usize - base, 0); assert_eq!(&obj.ri_data.1 as *const _ as usize - base, 4); @@ -1409,10 +1409,10 @@ fn recv_in_layout_test_32() { #[test] #[cfg(target_pointer_width = "64")] fn recv_in_layout_test_64() { - assert_eq!(::core::mem::size_of::(), 40); - assert_eq!(::core::mem::align_of::(), 8); + assert_eq!(core::mem::size_of::(), 40); + assert_eq!(core::mem::align_of::(), 8); unsafe { - let obj: recv_in = ::core::mem::uninitialized(); + let obj: recv_in = core::mem::uninitialized(); let base = &obj as *const _ as usize; assert_eq!(&obj.ri_data.0 as *const _ as usize - base, 0); assert_eq!(&obj.ri_data.1 as *const _ as usize - base, 8); @@ -1438,10 +1438,10 @@ pub struct recv_out { #[test] #[cfg(target_pointer_width = "32")] fn recv_out_layout_test_32() { - assert_eq!(::core::mem::size_of::(), 52); - assert_eq!(::core::mem::align_of::(), 4); + assert_eq!(core::mem::size_of::(), 52); + assert_eq!(core::mem::align_of::(), 4); unsafe { - let obj: recv_out = ::core::mem::uninitialized(); + let obj: recv_out = core::mem::uninitialized(); let base = &obj as *const _ as usize; assert_eq!(&obj.ro_datalen as *const _ as usize - base, 0); assert_eq!(&obj.ro_fdslen as *const _ as usize - base, 4); @@ -1452,10 +1452,10 @@ fn recv_out_layout_test_32() { #[test] #[cfg(target_pointer_width = "64")] fn recv_out_layout_test_64() { - assert_eq!(::core::mem::size_of::(), 64); - assert_eq!(::core::mem::align_of::(), 8); + assert_eq!(core::mem::size_of::(), 64); + assert_eq!(core::mem::align_of::(), 8); unsafe { - let obj: recv_out = ::core::mem::uninitialized(); + let obj: recv_out = core::mem::uninitialized(); let base = &obj as *const _ as usize; assert_eq!(&obj.ro_datalen as *const _ as usize - base, 0); assert_eq!(&obj.ro_fdslen as *const _ as usize - base, 8); @@ -1480,10 +1480,10 @@ pub struct send_in { #[test] #[cfg(target_pointer_width = "32")] fn send_in_layout_test_32() { - assert_eq!(::core::mem::size_of::(), 20); - assert_eq!(::core::mem::align_of::(), 4); + assert_eq!(core::mem::size_of::(), 20); + assert_eq!(core::mem::align_of::(), 4); unsafe { - let obj: send_in = ::core::mem::uninitialized(); + let obj: send_in = core::mem::uninitialized(); let base = &obj as *const _ as usize; assert_eq!(&obj.si_data.0 as *const _ as usize - base, 0); assert_eq!(&obj.si_data.1 as *const _ as usize - base, 4); @@ -1495,10 +1495,10 @@ fn send_in_layout_test_32() { #[test] #[cfg(target_pointer_width = "64")] fn send_in_layout_test_64() { - assert_eq!(::core::mem::size_of::(), 40); - assert_eq!(::core::mem::align_of::(), 8); + assert_eq!(core::mem::size_of::(), 40); + assert_eq!(core::mem::align_of::(), 8); unsafe { - let obj: send_in = ::core::mem::uninitialized(); + let obj: send_in = core::mem::uninitialized(); let base = &obj as *const _ as usize; assert_eq!(&obj.si_data.0 as *const _ as usize - base, 0); assert_eq!(&obj.si_data.1 as *const _ as usize - base, 8); @@ -1518,10 +1518,10 @@ pub struct send_out { #[test] #[cfg(target_pointer_width = "32")] fn send_out_layout_test_32() { - assert_eq!(::core::mem::size_of::(), 4); - assert_eq!(::core::mem::align_of::(), 4); + assert_eq!(core::mem::size_of::(), 4); + assert_eq!(core::mem::align_of::(), 4); unsafe { - let obj: send_out = ::core::mem::uninitialized(); + let obj: send_out = core::mem::uninitialized(); let base = &obj as *const _ as usize; assert_eq!(&obj.so_datalen as *const _ as usize - base, 0); } @@ -1529,10 +1529,10 @@ fn send_out_layout_test_32() { #[test] #[cfg(target_pointer_width = "64")] fn send_out_layout_test_64() { - assert_eq!(::core::mem::size_of::(), 8); - assert_eq!(::core::mem::align_of::(), 8); + assert_eq!(core::mem::size_of::(), 8); + assert_eq!(core::mem::align_of::(), 8); unsafe { - let obj: send_out = ::core::mem::uninitialized(); + let obj: send_out = core::mem::uninitialized(); let base = &obj as *const _ as usize; assert_eq!(&obj.so_datalen as *const _ as usize - base, 0); } @@ -1647,10 +1647,10 @@ pub struct subscription_proc_terminate { #[test] #[cfg(target_pointer_width = "32")] fn subscription_layout_test_32() { - assert_eq!(::core::mem::size_of::(), 56); - assert_eq!(::core::mem::align_of::(), 8); + assert_eq!(core::mem::size_of::(), 56); + assert_eq!(core::mem::align_of::(), 8); unsafe { - let obj: subscription = ::core::mem::uninitialized(); + let obj: subscription = core::mem::uninitialized(); let base = &obj as *const _ as usize; assert_eq!(&obj.userdata as *const _ as usize - base, 0); assert_eq!(&obj.unused as *const _ as usize - base, 8); @@ -1674,10 +1674,10 @@ fn subscription_layout_test_32() { #[test] #[cfg(target_pointer_width = "64")] fn subscription_layout_test_64() { - assert_eq!(::core::mem::size_of::(), 56); - assert_eq!(::core::mem::align_of::(), 8); + assert_eq!(core::mem::size_of::(), 56); + assert_eq!(core::mem::align_of::(), 8); unsafe { - let obj: subscription = ::core::mem::uninitialized(); + let obj: subscription = core::mem::uninitialized(); let base = &obj as *const _ as usize; assert_eq!(&obj.userdata as *const _ as usize - base, 0); assert_eq!(&obj.unused as *const _ as usize - base, 8); @@ -1728,10 +1728,10 @@ pub struct tcb { #[test] #[cfg(target_pointer_width = "32")] fn tcb_layout_test_32() { - assert_eq!(::core::mem::size_of::(), 4); - assert_eq!(::core::mem::align_of::(), 4); + assert_eq!(core::mem::size_of::(), 4); + assert_eq!(core::mem::align_of::(), 4); unsafe { - let obj: tcb = ::core::mem::uninitialized(); + let obj: tcb = core::mem::uninitialized(); let base = &obj as *const _ as usize; assert_eq!(&obj.parent as *const _ as usize - base, 0); } @@ -1739,10 +1739,10 @@ fn tcb_layout_test_32() { #[test] #[cfg(target_pointer_width = "64")] fn tcb_layout_test_64() { - assert_eq!(::core::mem::size_of::(), 8); - assert_eq!(::core::mem::align_of::(), 8); + assert_eq!(core::mem::size_of::(), 8); + assert_eq!(core::mem::align_of::(), 8); unsafe { - let obj: tcb = ::core::mem::uninitialized(); + let obj: tcb = core::mem::uninitialized(); let base = &obj as *const _ as usize; assert_eq!(&obj.parent as *const _ as usize - base, 0); } @@ -1773,10 +1773,10 @@ pub struct threadattr { #[test] #[cfg(target_pointer_width = "32")] fn threadattr_layout_test_32() { - assert_eq!(::core::mem::size_of::(), 16); - assert_eq!(::core::mem::align_of::(), 4); + assert_eq!(core::mem::size_of::(), 16); + assert_eq!(core::mem::align_of::(), 4); unsafe { - let obj: threadattr = ::core::mem::uninitialized(); + let obj: threadattr = core::mem::uninitialized(); let base = &obj as *const _ as usize; assert_eq!(&obj.entry_point as *const _ as usize - base, 0); assert_eq!(&obj.stack.0 as *const _ as usize - base, 4); @@ -1787,10 +1787,10 @@ fn threadattr_layout_test_32() { #[test] #[cfg(target_pointer_width = "64")] fn threadattr_layout_test_64() { - assert_eq!(::core::mem::size_of::(), 32); - assert_eq!(::core::mem::align_of::(), 8); + assert_eq!(core::mem::size_of::(), 32); + assert_eq!(core::mem::align_of::(), 8); unsafe { - let obj: threadattr = ::core::mem::uninitialized(); + let obj: threadattr = core::mem::uninitialized(); let base = &obj as *const _ as usize; assert_eq!(&obj.entry_point as *const _ as usize - base, 0); assert_eq!(&obj.stack.0 as *const _ as usize - base, 8); diff --git a/src/libstd/sys/cloudabi/args.rs b/src/libstd/sys/cloudabi/args.rs index 4147ffff87113..dea562abad3ff 100644 --- a/src/libstd/sys/cloudabi/args.rs +++ b/src/libstd/sys/cloudabi/args.rs @@ -1,4 +1,4 @@ -pub use sys::cloudabi::shims::args::*; +pub use crate::sys::cloudabi::shims::args::*; #[allow(dead_code)] pub fn init(_: isize, _: *const *const u8) {} diff --git a/src/libstd/sys/cloudabi/backtrace.rs b/src/libstd/sys/cloudabi/backtrace.rs index 72f28550435a1..a15d2238e5563 100644 --- a/src/libstd/sys/cloudabi/backtrace.rs +++ b/src/libstd/sys/cloudabi/backtrace.rs @@ -1,9 +1,10 @@ -use error::Error; -use ffi::CStr; -use intrinsics; -use io; -use libc; -use sys_common::backtrace::Frame; +use crate::error::Error; +use crate::ffi::CStr; +use crate::fmt; +use crate::intrinsics; +use crate::io; +use crate::sys_common::backtrace::Frame; + use unwind as uw; pub struct BacktraceContext; @@ -22,8 +23,8 @@ impl Error for UnwindError { } } -impl ::fmt::Display for UnwindError { - fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { +impl fmt::Display for UnwindError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}: {:?}", self.description(), self.0) } } diff --git a/src/libstd/sys/cloudabi/condvar.rs b/src/libstd/sys/cloudabi/condvar.rs index 758f29653aeb1..7aa0b0b6f4912 100644 --- a/src/libstd/sys/cloudabi/condvar.rs +++ b/src/libstd/sys/cloudabi/condvar.rs @@ -1,10 +1,10 @@ -use cell::UnsafeCell; -use mem; -use sync::atomic::{AtomicU32, Ordering}; -use sys::cloudabi::abi; -use sys::mutex::{self, Mutex}; -use sys::time::checked_dur2intervals; -use time::Duration; +use crate::cell::UnsafeCell; +use crate::mem; +use crate::sync::atomic::{AtomicU32, Ordering}; +use crate::sys::cloudabi::abi; +use crate::sys::mutex::{self, Mutex}; +use crate::sys::time::checked_dur2intervals; +use crate::time::Duration; extern "C" { #[thread_local] diff --git a/src/libstd/sys/cloudabi/mod.rs b/src/libstd/sys/cloudabi/mod.rs index d9bc21861c90d..47c90fddd867f 100644 --- a/src/libstd/sys/cloudabi/mod.rs +++ b/src/libstd/sys/cloudabi/mod.rs @@ -1,5 +1,5 @@ -use libc; -use mem; +use crate::io::ErrorKind; +use crate::mem; #[path = "../unix/alloc.rs"] pub mod alloc; @@ -32,29 +32,29 @@ pub use self::shims::*; #[allow(dead_code)] pub fn init() {} -pub fn decode_error_kind(errno: i32) -> ::io::ErrorKind { +pub fn decode_error_kind(errno: i32) -> ErrorKind { match errno { - x if x == abi::errno::ACCES as i32 => ::io::ErrorKind::PermissionDenied, - x if x == abi::errno::ADDRINUSE as i32 => ::io::ErrorKind::AddrInUse, - x if x == abi::errno::ADDRNOTAVAIL as i32 => ::io::ErrorKind::AddrNotAvailable, - x if x == abi::errno::AGAIN as i32 => ::io::ErrorKind::WouldBlock, - x if x == abi::errno::CONNABORTED as i32 => ::io::ErrorKind::ConnectionAborted, - x if x == abi::errno::CONNREFUSED as i32 => ::io::ErrorKind::ConnectionRefused, - x if x == abi::errno::CONNRESET as i32 => ::io::ErrorKind::ConnectionReset, - x if x == abi::errno::EXIST as i32 => ::io::ErrorKind::AlreadyExists, - x if x == abi::errno::INTR as i32 => ::io::ErrorKind::Interrupted, - x if x == abi::errno::INVAL as i32 => ::io::ErrorKind::InvalidInput, - x if x == abi::errno::NOENT as i32 => ::io::ErrorKind::NotFound, - x if x == abi::errno::NOTCONN as i32 => ::io::ErrorKind::NotConnected, - x if x == abi::errno::PERM as i32 => ::io::ErrorKind::PermissionDenied, - x if x == abi::errno::PIPE as i32 => ::io::ErrorKind::BrokenPipe, - x if x == abi::errno::TIMEDOUT as i32 => ::io::ErrorKind::TimedOut, - _ => ::io::ErrorKind::Other, + x if x == abi::errno::ACCES as i32 => ErrorKind::PermissionDenied, + x if x == abi::errno::ADDRINUSE as i32 => ErrorKind::AddrInUse, + x if x == abi::errno::ADDRNOTAVAIL as i32 => ErrorKind::AddrNotAvailable, + x if x == abi::errno::AGAIN as i32 => ErrorKind::WouldBlock, + x if x == abi::errno::CONNABORTED as i32 => ErrorKind::ConnectionAborted, + x if x == abi::errno::CONNREFUSED as i32 => ErrorKind::ConnectionRefused, + x if x == abi::errno::CONNRESET as i32 => ErrorKind::ConnectionReset, + x if x == abi::errno::EXIST as i32 => ErrorKind::AlreadyExists, + x if x == abi::errno::INTR as i32 => ErrorKind::Interrupted, + x if x == abi::errno::INVAL as i32 => ErrorKind::InvalidInput, + x if x == abi::errno::NOENT as i32 => ErrorKind::NotFound, + x if x == abi::errno::NOTCONN as i32 => ErrorKind::NotConnected, + x if x == abi::errno::PERM as i32 => ErrorKind::PermissionDenied, + x if x == abi::errno::PIPE as i32 => ErrorKind::BrokenPipe, + x if x == abi::errno::TIMEDOUT as i32 => ErrorKind::TimedOut, + _ => ErrorKind::Other, } } pub unsafe fn abort_internal() -> ! { - ::core::intrinsics::abort(); + core::intrinsics::abort(); } pub use libc::strlen; diff --git a/src/libstd/sys/cloudabi/mutex.rs b/src/libstd/sys/cloudabi/mutex.rs index ae62d8bfdb0c2..5e191e31d5fc4 100644 --- a/src/libstd/sys/cloudabi/mutex.rs +++ b/src/libstd/sys/cloudabi/mutex.rs @@ -1,8 +1,8 @@ -use cell::UnsafeCell; -use mem; -use sync::atomic::{AtomicU32, Ordering}; -use sys::cloudabi::abi; -use sys::rwlock::{self, RWLock}; +use crate::cell::UnsafeCell; +use crate::mem; +use crate::sync::atomic::{AtomicU32, Ordering}; +use crate::sys::cloudabi::abi; +use crate::sys::rwlock::{self, RWLock}; extern "C" { #[thread_local] diff --git a/src/libstd/sys/cloudabi/os.rs b/src/libstd/sys/cloudabi/os.rs index 8a6464125de68..7db7808a08783 100644 --- a/src/libstd/sys/cloudabi/os.rs +++ b/src/libstd/sys/cloudabi/os.rs @@ -1,8 +1,9 @@ -use ffi::CStr; -use libc::{self, c_int}; -use str; +use crate::ffi::CStr; +use crate::str; -pub use sys::cloudabi::shims::os::*; +use libc::c_int; + +pub use crate::sys::cloudabi::shims::os::*; pub fn errno() -> i32 { extern "C" { diff --git a/src/libstd/sys/cloudabi/rwlock.rs b/src/libstd/sys/cloudabi/rwlock.rs index 7f08c2c786919..6da3f3841b6c6 100644 --- a/src/libstd/sys/cloudabi/rwlock.rs +++ b/src/libstd/sys/cloudabi/rwlock.rs @@ -1,7 +1,7 @@ -use cell::UnsafeCell; -use mem; -use sync::atomic::{AtomicU32, Ordering}; -use sys::cloudabi::abi; +use crate::cell::UnsafeCell; +use crate::mem; +use crate::sync::atomic::{AtomicU32, Ordering}; +use crate::sys::cloudabi::abi; extern "C" { #[thread_local] diff --git a/src/libstd/sys/cloudabi/shims/args.rs b/src/libstd/sys/cloudabi/shims/args.rs index f924a434263f4..f5cf71caf6c04 100644 --- a/src/libstd/sys/cloudabi/shims/args.rs +++ b/src/libstd/sys/cloudabi/shims/args.rs @@ -1,4 +1,4 @@ -use ffi::OsString; +use crate::ffi::OsString; pub struct Args(()); diff --git a/src/libstd/sys/cloudabi/shims/fs.rs b/src/libstd/sys/cloudabi/shims/fs.rs index 3af10a74c7d45..56667bef00706 100644 --- a/src/libstd/sys/cloudabi/shims/fs.rs +++ b/src/libstd/sys/cloudabi/shims/fs.rs @@ -1,10 +1,10 @@ -use ffi::OsString; -use fmt; -use hash::{Hash, Hasher}; -use io::{self, SeekFrom}; -use path::{Path, PathBuf}; -use sys::time::SystemTime; -use sys::{unsupported, Void}; +use crate::ffi::OsString; +use crate::fmt; +use crate::hash::{Hash, Hasher}; +use crate::io::{self, SeekFrom}; +use crate::path::{Path, PathBuf}; +use crate::sys::time::SystemTime; +use crate::sys::{unsupported, Void}; pub struct File(Void); diff --git a/src/libstd/sys/cloudabi/shims/mod.rs b/src/libstd/sys/cloudabi/shims/mod.rs index 080eac19ceb0b..fbb5ff55f2224 100644 --- a/src/libstd/sys/cloudabi/shims/mod.rs +++ b/src/libstd/sys/cloudabi/shims/mod.rs @@ -1,4 +1,4 @@ -use io; +use crate::io; pub mod args; pub mod env; diff --git a/src/libstd/sys/cloudabi/shims/net.rs b/src/libstd/sys/cloudabi/shims/net.rs index 869a0ef87a70e..50d72dc7b240b 100644 --- a/src/libstd/sys/cloudabi/shims/net.rs +++ b/src/libstd/sys/cloudabi/shims/net.rs @@ -1,10 +1,11 @@ -use fmt; -use io::{self, IoVec, IoVecMut}; -use net::{Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr}; -use time::Duration; -use sys::{unsupported, Void}; -use convert::TryFrom; - +use crate::fmt; +use crate::io::{self, IoVec, IoVecMut}; +use crate::net::{Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr}; +use crate::time::Duration; +use crate::sys::{unsupported, Void}; +use crate::convert::TryFrom; + +#[allow(unused_extern_crates)] pub extern crate libc as netc; pub struct TcpStream(Void); diff --git a/src/libstd/sys/cloudabi/shims/os.rs b/src/libstd/sys/cloudabi/shims/os.rs index 31cb18ea5268b..0c4690e12b052 100644 --- a/src/libstd/sys/cloudabi/shims/os.rs +++ b/src/libstd/sys/cloudabi/shims/os.rs @@ -1,10 +1,10 @@ -use error::Error as StdError; -use ffi::{OsStr, OsString}; -use fmt; -use io; -use iter; -use path::{self, PathBuf}; -use sys::{unsupported, Void}; +use crate::error::Error as StdError; +use crate::ffi::{OsStr, OsString}; +use crate::fmt; +use crate::io; +use crate::iter; +use crate::path::{self, PathBuf}; +use crate::sys::{unsupported, Void}; pub fn getcwd() -> io::Result { unsupported() diff --git a/src/libstd/sys/cloudabi/shims/pipe.rs b/src/libstd/sys/cloudabi/shims/pipe.rs index 30ef79dd769b4..f3debb9504742 100644 --- a/src/libstd/sys/cloudabi/shims/pipe.rs +++ b/src/libstd/sys/cloudabi/shims/pipe.rs @@ -1,5 +1,5 @@ -use io; -use sys::Void; +use crate::io; +use crate::sys::Void; pub struct AnonPipe(Void); diff --git a/src/libstd/sys/cloudabi/shims/process.rs b/src/libstd/sys/cloudabi/shims/process.rs index 49b9d5e266ec4..710c42c114902 100644 --- a/src/libstd/sys/cloudabi/shims/process.rs +++ b/src/libstd/sys/cloudabi/shims/process.rs @@ -1,10 +1,10 @@ -use ffi::OsStr; -use fmt; -use io; -use sys::fs::File; -use sys::pipe::AnonPipe; -use sys::{unsupported, Void}; -use sys_common::process::{CommandEnv, DefaultEnvKey}; +use crate::ffi::OsStr; +use crate::fmt; +use crate::io; +use crate::sys::fs::File; +use crate::sys::pipe::AnonPipe; +use crate::sys::{unsupported, Void}; +use crate::sys_common::process::{CommandEnv, DefaultEnvKey}; //////////////////////////////////////////////////////////////////////////////// // Command diff --git a/src/libstd/sys/cloudabi/stdio.rs b/src/libstd/sys/cloudabi/stdio.rs index 81d79213f615c..601563c5b1fcb 100644 --- a/src/libstd/sys/cloudabi/stdio.rs +++ b/src/libstd/sys/cloudabi/stdio.rs @@ -1,5 +1,5 @@ -use io; -use sys::cloudabi::abi; +use crate::io; +use crate::sys::cloudabi::abi; pub struct Stdin(()); pub struct Stdout(()); @@ -59,7 +59,7 @@ pub fn is_ebadf(err: &io::Error) -> bool { err.raw_os_error() == Some(abi::errno::BADF as i32) } -pub const STDIN_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE; +pub const STDIN_BUF_SIZE: usize = crate::sys_common::io::DEFAULT_BUF_SIZE; pub fn panic_output() -> Option { Stderr::new().ok() diff --git a/src/libstd/sys/cloudabi/thread.rs b/src/libstd/sys/cloudabi/thread.rs index 950420420f09e..f853346e0e63c 100644 --- a/src/libstd/sys/cloudabi/thread.rs +++ b/src/libstd/sys/cloudabi/thread.rs @@ -1,14 +1,13 @@ -use boxed::FnBox; -use cmp; -use ffi::CStr; -use io; -use libc; -use mem; -use ptr; -use sys::cloudabi::abi; -use sys::time::checked_dur2intervals; -use sys_common::thread::*; -use time::Duration; +use crate::boxed::FnBox; +use crate::cmp; +use crate::ffi::CStr; +use crate::io; +use crate::mem; +use crate::ptr; +use crate::sys::cloudabi::abi; +use crate::sys::time::checked_dur2intervals; +use crate::sys_common::thread::*; +use crate::time::Duration; pub const DEFAULT_MIN_STACK_SIZE: usize = 2 * 1024 * 1024; diff --git a/src/libstd/sys/cloudabi/time.rs b/src/libstd/sys/cloudabi/time.rs index 545e3c0ce8455..d7502c61eff2c 100644 --- a/src/libstd/sys/cloudabi/time.rs +++ b/src/libstd/sys/cloudabi/time.rs @@ -1,6 +1,6 @@ -use mem; -use sys::cloudabi::abi; -use time::Duration; +use crate::mem; +use crate::sys::cloudabi::abi; +use crate::time::Duration; const NSEC_PER_SEC: abi::timestamp = 1_000_000_000; diff --git a/src/libstd/sys/mod.rs b/src/libstd/sys/mod.rs index 0a56f4fad6d15..5ba9304c09b99 100644 --- a/src/libstd/sys/mod.rs +++ b/src/libstd/sys/mod.rs @@ -67,7 +67,7 @@ cfg_if! { pub mod unix_ext {} } else { // On other platforms like Windows document the bare bones of unix - use os::linux as platform; + use crate::os::linux as platform; #[path = "unix/ext/mod.rs"] pub mod unix_ext; } diff --git a/src/libstd/sys/redox/args.rs b/src/libstd/sys/redox/args.rs index 4e51be03f6f02..f9e2f5ba311a0 100644 --- a/src/libstd/sys/redox/args.rs +++ b/src/libstd/sys/redox/args.rs @@ -5,9 +5,9 @@ #![allow(dead_code)] // runtime init functions not used during testing -use ffi::OsString; -use marker::PhantomData; -use vec; +use crate::ffi::OsString; +use crate::marker::PhantomData; +use crate::vec; /// One-time global initialization. pub unsafe fn init(argc: isize, argv: *const *const u8) { imp::init(argc, argv) } @@ -46,14 +46,13 @@ impl DoubleEndedIterator for Args { } mod imp { - use os::unix::prelude::*; - use mem; - use ffi::{CStr, OsString}; - use marker::PhantomData; - use libc; + use crate::os::unix::prelude::*; + use crate::mem; + use crate::ffi::{CStr, OsString}; + use crate::marker::PhantomData; use super::Args; - use sys_common::mutex::Mutex; + use crate::sys_common::mutex::Mutex; static mut GLOBAL_ARGS_PTR: usize = 0; static LOCK: Mutex = Mutex::new(); diff --git a/src/libstd/sys/redox/backtrace/mod.rs b/src/libstd/sys/redox/backtrace/mod.rs index 9a007241073c4..8ea2783580a47 100644 --- a/src/libstd/sys/redox/backtrace/mod.rs +++ b/src/libstd/sys/redox/backtrace/mod.rs @@ -9,13 +9,13 @@ mod tracing; mod printing; pub mod gnu { - use io; - use fs; + use crate::io; + use crate::fs; + use crate::vec::Vec; + use crate::ffi::OsStr; + use crate::os::unix::ffi::OsStrExt; + use crate::io::Read; use libc::c_char; - use vec::Vec; - use ffi::OsStr; - use os::unix::ffi::OsStrExt; - use io::Read; pub fn get_executable_filename() -> io::Result<(Vec, fs::File)> { let mut exefile = fs::File::open("sys:exe")?; diff --git a/src/libstd/sys/redox/backtrace/printing.rs b/src/libstd/sys/redox/backtrace/printing.rs index c50c7154f0cd2..489eed4562deb 100644 --- a/src/libstd/sys/redox/backtrace/printing.rs +++ b/src/libstd/sys/redox/backtrace/printing.rs @@ -1 +1 @@ -pub use sys_common::gnu::libbacktrace::{foreach_symbol_fileline, resolve_symname}; +pub use crate::sys_common::gnu::libbacktrace::{foreach_symbol_fileline, resolve_symname}; diff --git a/src/libstd/sys/redox/backtrace/tracing.rs b/src/libstd/sys/redox/backtrace/tracing.rs index 59a8c5fab3d44..e7a68eadbde3a 100644 --- a/src/libstd/sys/redox/backtrace/tracing.rs +++ b/src/libstd/sys/redox/backtrace/tracing.rs @@ -1,8 +1,8 @@ -use error::Error; -use io; -use libc; -use sys::backtrace::BacktraceContext; -use sys_common::backtrace::Frame; +use crate::error::Error; +use crate::fmt; +use crate::io; +use crate::sys::backtrace::BacktraceContext; +use crate::sys_common::backtrace::Frame; use unwind as uw; @@ -20,8 +20,8 @@ impl Error for UnwindError { } } -impl ::fmt::Display for UnwindError { - fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { +impl fmt::Display for UnwindError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}: {:?}", self.description(), self.0) } } diff --git a/src/libstd/sys/redox/condvar.rs b/src/libstd/sys/redox/condvar.rs index 5f9eee588c33e..a6365cac23ea7 100644 --- a/src/libstd/sys/redox/condvar.rs +++ b/src/libstd/sys/redox/condvar.rs @@ -1,10 +1,10 @@ -use cell::UnsafeCell; -use intrinsics::{atomic_cxchg, atomic_load, atomic_xadd, atomic_xchg}; -use ptr; -use time::Duration; +use crate::cell::UnsafeCell; +use crate::intrinsics::{atomic_cxchg, atomic_load, atomic_xadd, atomic_xchg}; +use crate::ptr; +use crate::time::Duration; -use sys::mutex::{mutex_unlock, Mutex}; -use sys::syscall::{futex, TimeSpec, FUTEX_WAIT, FUTEX_WAKE, FUTEX_REQUEUE}; +use crate::sys::mutex::{mutex_unlock, Mutex}; +use crate::sys::syscall::{futex, TimeSpec, FUTEX_WAIT, FUTEX_WAKE, FUTEX_REQUEUE}; pub struct Condvar { lock: UnsafeCell<*mut i32>, @@ -48,7 +48,7 @@ impl Condvar { atomic_xadd(seq, 1); - let _ = futex(seq, FUTEX_REQUEUE, 1, ::usize::MAX, *lock); + let _ = futex(seq, FUTEX_REQUEUE, 1, crate::usize::MAX, *lock); } } diff --git a/src/libstd/sys/redox/ext/ffi.rs b/src/libstd/sys/redox/ext/ffi.rs index 848880d26e89e..671498bc39037 100644 --- a/src/libstd/sys/redox/ext/ffi.rs +++ b/src/libstd/sys/redox/ext/ffi.rs @@ -2,10 +2,10 @@ #![stable(feature = "rust1", since = "1.0.0")] -use ffi::{OsStr, OsString}; -use mem; -use sys::os_str::Buf; -use sys_common::{FromInner, IntoInner, AsInner}; +use crate::ffi::{OsStr, OsString}; +use crate::mem; +use crate::sys::os_str::Buf; +use crate::sys_common::{FromInner, IntoInner, AsInner}; /// Redox-specific extensions to [`OsString`]. /// diff --git a/src/libstd/sys/redox/ext/fs.rs b/src/libstd/sys/redox/ext/fs.rs index 8b81273f201cf..53b9dd68f734f 100644 --- a/src/libstd/sys/redox/ext/fs.rs +++ b/src/libstd/sys/redox/ext/fs.rs @@ -2,11 +2,11 @@ #![stable(feature = "rust1", since = "1.0.0")] -use fs::{self, Permissions, OpenOptions}; -use io; -use path::Path; -use sys; -use sys_common::{FromInner, AsInner, AsInnerMut}; +use crate::fs::{self, Permissions, OpenOptions}; +use crate::io; +use crate::path::Path; +use crate::sys; +use crate::sys_common::{FromInner, AsInner, AsInnerMut}; /// Redox-specific extensions to [`fs::Permissions`]. /// diff --git a/src/libstd/sys/redox/ext/io.rs b/src/libstd/sys/redox/ext/io.rs index 3ee0c6010a7ad..f431f96c541f7 100644 --- a/src/libstd/sys/redox/ext/io.rs +++ b/src/libstd/sys/redox/ext/io.rs @@ -2,11 +2,11 @@ #![stable(feature = "rust1", since = "1.0.0")] -use fs; -use net; -use sys; -use io; -use sys_common::{self, AsInner, FromInner, IntoInner}; +use crate::fs; +use crate::net; +use crate::sys; +use crate::io; +use crate::sys_common::{self, AsInner, FromInner, IntoInner}; /// Raw file descriptors. #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libstd/sys/redox/ext/net.rs b/src/libstd/sys/redox/ext/net.rs index 7411b8e068f64..2c121787804d1 100644 --- a/src/libstd/sys/redox/ext/net.rs +++ b/src/libstd/sys/redox/ext/net.rs @@ -2,13 +2,13 @@ //! Unix-specific networking functionality -use fmt; -use io::{self, Error, ErrorKind, Initializer}; -use net::Shutdown; -use os::unix::io::{RawFd, AsRawFd, FromRawFd, IntoRawFd}; -use path::Path; -use time::Duration; -use sys::{cvt, fd::FileDesc, syscall}; +use crate::fmt; +use crate::io::{self, Error, ErrorKind, Initializer}; +use crate::net::Shutdown; +use crate::os::unix::io::{RawFd, AsRawFd, FromRawFd, IntoRawFd}; +use crate::path::Path; +use crate::time::Duration; +use crate::sys::{cvt, fd::FileDesc, syscall}; /// An address associated with a Unix socket. /// diff --git a/src/libstd/sys/redox/ext/process.rs b/src/libstd/sys/redox/ext/process.rs index 020075531dd0e..e981cb93d441f 100644 --- a/src/libstd/sys/redox/ext/process.rs +++ b/src/libstd/sys/redox/ext/process.rs @@ -2,11 +2,11 @@ #![stable(feature = "rust1", since = "1.0.0")] -use io; -use os::unix::io::{FromRawFd, RawFd, AsRawFd, IntoRawFd}; -use process; -use sys; -use sys_common::{AsInnerMut, AsInner, FromInner, IntoInner}; +use crate::io; +use crate::os::unix::io::{FromRawFd, RawFd, AsRawFd, IntoRawFd}; +use crate::process; +use crate::sys; +use crate::sys_common::{AsInnerMut, AsInner, FromInner, IntoInner}; /// Redox-specific extensions to the [`process::Command`] builder, /// diff --git a/src/libstd/sys/redox/ext/thread.rs b/src/libstd/sys/redox/ext/thread.rs index 21b140ad718ac..629eaef04ce36 100644 --- a/src/libstd/sys/redox/ext/thread.rs +++ b/src/libstd/sys/redox/ext/thread.rs @@ -2,8 +2,8 @@ #![stable(feature = "thread_extensions", since = "1.9.0")] -use sys_common::{AsInner, IntoInner}; -use thread::JoinHandle; +use crate::sys_common::{AsInner, IntoInner}; +use crate::thread::JoinHandle; #[stable(feature = "thread_extensions", since = "1.9.0")] #[allow(deprecated)] diff --git a/src/libstd/sys/redox/fast_thread_local.rs b/src/libstd/sys/redox/fast_thread_local.rs index 95263e6f5e312..1202708a4769a 100644 --- a/src/libstd/sys/redox/fast_thread_local.rs +++ b/src/libstd/sys/redox/fast_thread_local.rs @@ -1,9 +1,9 @@ #![cfg(target_thread_local)] #![unstable(feature = "thread_local_internals", issue = "0")] -use cell::{Cell, UnsafeCell}; -use mem; -use ptr; +use crate::cell::{Cell, UnsafeCell}; +use crate::mem; +use crate::ptr; pub struct Key { @@ -15,7 +15,7 @@ pub struct Key { dtor_running: Cell, } -unsafe impl ::marker::Sync for Key { } +unsafe impl Sync for Key { } impl Key { pub const fn new() -> Key { @@ -57,7 +57,7 @@ pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern fn(*mut u8)) { // *should* be the case that this loop always terminates because we // provide the guarantee that a TLS key cannot be set after it is // flagged for destruction. - use sys_common::thread_local as os; + use crate::sys_common::thread_local as os; static DTORS: os::StaticKey = os::StaticKey::new(Some(run_dtors)); type List = Vec<(*mut u8, unsafe extern fn(*mut u8))>; diff --git a/src/libstd/sys/redox/fd.rs b/src/libstd/sys/redox/fd.rs index fbf31aae2d0e6..a42e486db2239 100644 --- a/src/libstd/sys/redox/fd.rs +++ b/src/libstd/sys/redox/fd.rs @@ -1,9 +1,9 @@ #![unstable(reason = "not public", issue = "0", feature = "fd")] -use io::{self, Read}; -use mem; -use sys::{cvt, syscall}; -use sys_common::AsInner; +use crate::io::{self, Read}; +use crate::mem; +use crate::sys::{cvt, syscall}; +use crate::sys_common::AsInner; pub struct FileDesc { fd: usize, diff --git a/src/libstd/sys/redox/fs.rs b/src/libstd/sys/redox/fs.rs index 97e5dcebfeab6..159ee9911bd3a 100644 --- a/src/libstd/sys/redox/fs.rs +++ b/src/libstd/sys/redox/fs.rs @@ -1,14 +1,14 @@ -use os::unix::prelude::*; - -use ffi::{OsString, OsStr}; -use fmt; -use io::{self, Error, ErrorKind, SeekFrom}; -use path::{Path, PathBuf}; -use sync::Arc; -use sys::fd::FileDesc; -use sys::time::SystemTime; -use sys::{cvt, syscall}; -use sys_common::{AsInner, FromInner}; +use crate::os::unix::prelude::*; + +use crate::ffi::{OsString, OsStr}; +use crate::fmt; +use crate::io::{self, Error, ErrorKind, SeekFrom}; +use crate::path::{Path, PathBuf}; +use crate::sync::Arc; +use crate::sys::fd::FileDesc; +use crate::sys::time::SystemTime; +use crate::sys::{cvt, syscall}; +use crate::sys_common::{AsInner, FromInner}; pub struct File(FileDesc); @@ -457,7 +457,7 @@ pub fn canonicalize(p: &Path) -> io::Result { } pub fn copy(from: &Path, to: &Path) -> io::Result { - use fs::{File, set_permissions}; + use crate::fs::{File, set_permissions}; if !from.is_file() { return Err(Error::new(ErrorKind::InvalidInput, "the source path is not an existing regular file")) diff --git a/src/libstd/sys/redox/mod.rs b/src/libstd/sys/redox/mod.rs index c3878349bb329..7f3ac1f1bb5b3 100644 --- a/src/libstd/sys/redox/mod.rs +++ b/src/libstd/sys/redox/mod.rs @@ -1,6 +1,6 @@ #![allow(dead_code, missing_docs, nonstandard_style)] -use ::io::{ErrorKind}; +use crate::io::ErrorKind; pub use libc::strlen; pub use self::rand::hashmap_random_keys; @@ -64,8 +64,8 @@ pub fn decode_error_kind(errno: i32) -> ErrorKind { } } -pub fn cvt(result: Result) -> ::io::Result { - result.map_err(|err| ::io::Error::from_raw_os_error(err.errno)) +pub fn cvt(result: Result) -> crate::io::Result { + result.map_err(|err| crate::io::Error::from_raw_os_error(err.errno)) } #[doc(hidden)] @@ -83,9 +83,9 @@ macro_rules! impl_is_minus_one { impl_is_minus_one! { i8 i16 i32 i64 isize } -pub fn cvt_libc(t: T) -> ::io::Result { +pub fn cvt_libc(t: T) -> crate::io::Result { if t.is_minus_one() { - Err(::io::Error::last_os_error()) + Err(crate::io::Error::last_os_error()) } else { Ok(t) } @@ -93,5 +93,5 @@ pub fn cvt_libc(t: T) -> ::io::Result { /// On Redox, use an illegal instruction to abort pub unsafe fn abort_internal() -> ! { - ::core::intrinsics::abort(); + core::intrinsics::abort(); } diff --git a/src/libstd/sys/redox/mutex.rs b/src/libstd/sys/redox/mutex.rs index bf39cc485911b..59399df0294c8 100644 --- a/src/libstd/sys/redox/mutex.rs +++ b/src/libstd/sys/redox/mutex.rs @@ -1,8 +1,8 @@ -use cell::UnsafeCell; -use intrinsics::{atomic_cxchg, atomic_xchg}; -use ptr; +use crate::cell::UnsafeCell; +use crate::intrinsics::{atomic_cxchg, atomic_xchg}; +use crate::ptr; -use sys::syscall::{futex, getpid, FUTEX_WAIT, FUTEX_WAKE}; +use crate::sys::syscall::{futex, getpid, FUTEX_WAIT, FUTEX_WAKE}; pub unsafe fn mutex_try_lock(m: *mut i32) -> bool { atomic_cxchg(m, 0, 1).0 == 0 diff --git a/src/libstd/sys/redox/net/dns/answer.rs b/src/libstd/sys/redox/net/dns/answer.rs index c0450c11ed6b9..e9b406bc685a1 100644 --- a/src/libstd/sys/redox/net/dns/answer.rs +++ b/src/libstd/sys/redox/net/dns/answer.rs @@ -1,5 +1,5 @@ -use string::String; -use vec::Vec; +use crate::string::String; +use crate::vec::Vec; #[derive(Clone, Debug)] pub struct DnsAnswer { diff --git a/src/libstd/sys/redox/net/dns/mod.rs b/src/libstd/sys/redox/net/dns/mod.rs index 8f0a0610af5e3..6533e0d5efb77 100644 --- a/src/libstd/sys/redox/net/dns/mod.rs +++ b/src/libstd/sys/redox/net/dns/mod.rs @@ -1,10 +1,10 @@ pub use self::answer::DnsAnswer; pub use self::query::DnsQuery; -use slice; -use u16; -use string::String; -use vec::Vec; +use crate::slice; +use crate::u16; +use crate::string::String; +use crate::vec::Vec; mod answer; mod query; diff --git a/src/libstd/sys/redox/net/dns/query.rs b/src/libstd/sys/redox/net/dns/query.rs index dcb554d82debb..65fb241b03737 100644 --- a/src/libstd/sys/redox/net/dns/query.rs +++ b/src/libstd/sys/redox/net/dns/query.rs @@ -1,4 +1,4 @@ -use string::String; +use crate::string::String; #[derive(Clone, Debug)] pub struct DnsQuery { diff --git a/src/libstd/sys/redox/net/mod.rs b/src/libstd/sys/redox/net/mod.rs index 9e7599aebbbdb..a172763f61313 100644 --- a/src/libstd/sys/redox/net/mod.rs +++ b/src/libstd/sys/redox/net/mod.rs @@ -1,13 +1,13 @@ -use fs::File; -use io::{Error, Read, self}; -use iter::Iterator; -use net::{Ipv4Addr, SocketAddr, SocketAddrV4}; -use str::FromStr; -use string::{String, ToString}; -use sys::syscall::EINVAL; -use time::{self, Duration}; -use vec::{IntoIter, Vec}; -use convert::{TryFrom, TryInto}; +use crate::fs::File; +use crate::io::{Error, Read, self}; +use crate::iter::Iterator; +use crate::net::{Ipv4Addr, SocketAddr, SocketAddrV4}; +use crate::str::FromStr; +use crate::string::{String, ToString}; +use crate::sys::syscall::EINVAL; +use crate::time::{self, Duration}; +use crate::vec::{IntoIter, Vec}; +use crate::convert::{TryFrom, TryInto}; use self::dns::{Dns, DnsQuery}; diff --git a/src/libstd/sys/redox/net/tcp.rs b/src/libstd/sys/redox/net/tcp.rs index abb9f72c324b6..5081c3de73c5a 100644 --- a/src/libstd/sys/redox/net/tcp.rs +++ b/src/libstd/sys/redox/net/tcp.rs @@ -1,12 +1,12 @@ -use cmp; -use io::{self, Error, ErrorKind, Result, IoVec, IoVecMut}; -use mem; -use net::{SocketAddr, Shutdown}; -use path::Path; -use sys::fs::{File, OpenOptions}; -use sys::syscall::TimeSpec; -use sys_common::{AsInner, FromInner, IntoInner}; -use time::Duration; +use crate::cmp; +use crate::io::{self, Error, ErrorKind, Result, IoVec, IoVecMut}; +use crate::mem; +use crate::net::{SocketAddr, Shutdown}; +use crate::path::Path; +use crate::sys::fs::{File, OpenOptions}; +use crate::sys::syscall::TimeSpec; +use crate::sys_common::{AsInner, FromInner, IntoInner}; +use crate::time::Duration; use super::{path_to_peer_addr, path_to_local_addr}; diff --git a/src/libstd/sys/redox/net/udp.rs b/src/libstd/sys/redox/net/udp.rs index 2a59b44f09361..b1a60b1457083 100644 --- a/src/libstd/sys/redox/net/udp.rs +++ b/src/libstd/sys/redox/net/udp.rs @@ -1,13 +1,13 @@ -use cell::UnsafeCell; -use cmp; -use io::{self, Error, ErrorKind, Result}; -use mem; -use net::{SocketAddr, Ipv4Addr, Ipv6Addr}; -use path::Path; -use sys::fs::{File, OpenOptions}; -use sys::syscall::TimeSpec; -use sys_common::{AsInner, FromInner, IntoInner}; -use time::Duration; +use crate::cell::UnsafeCell; +use crate::cmp; +use crate::io::{self, Error, ErrorKind, Result}; +use crate::mem; +use crate::net::{SocketAddr, Ipv4Addr, Ipv6Addr}; +use crate::path::Path; +use crate::sys::fs::{File, OpenOptions}; +use crate::sys::syscall::TimeSpec; +use crate::sys_common::{AsInner, FromInner, IntoInner}; +use crate::time::Duration; use super::{path_to_peer_addr, path_to_local_addr}; diff --git a/src/libstd/sys/redox/os.rs b/src/libstd/sys/redox/os.rs index f7a26c9497025..76e43a83b7372 100644 --- a/src/libstd/sys/redox/os.rs +++ b/src/libstd/sys/redox/os.rs @@ -2,25 +2,25 @@ #![allow(unused_imports)] // lots of cfg code here -use libc::{self, c_char}; - -use os::unix::prelude::*; - -use error::Error as StdError; -use ffi::{CStr, CString, OsStr, OsString}; -use fmt; -use io::{self, Read, Write}; -use iter; -use marker::PhantomData; -use mem; -use memchr; -use path::{self, PathBuf}; -use ptr; -use slice; -use str; -use sys_common::mutex::Mutex; -use sys::{cvt, cvt_libc, fd, syscall}; -use vec; +use libc::c_char; + +use crate::os::unix::prelude::*; + +use crate::error::Error as StdError; +use crate::ffi::{CStr, CString, OsStr, OsString}; +use crate::fmt; +use crate::io::{self, Read, Write}; +use crate::iter; +use crate::marker::PhantomData; +use crate::mem; +use crate::memchr; +use crate::path::{self, PathBuf}; +use crate::ptr; +use crate::slice; +use crate::str; +use crate::sys_common::mutex::Mutex; +use crate::sys::{cvt, cvt_libc, fd, syscall}; +use crate::vec; extern { #[link_name = "__errno_location"] @@ -107,7 +107,7 @@ impl StdError for JoinPathsError { } pub fn current_exe() -> io::Result { - use fs::File; + use crate::fs::File; let mut file = File::open("sys:exe")?; @@ -218,13 +218,13 @@ pub fn page_size() -> usize { } pub fn temp_dir() -> PathBuf { - ::env::var_os("TMPDIR").map(PathBuf::from).unwrap_or_else(|| { + crate::env::var_os("TMPDIR").map(PathBuf::from).unwrap_or_else(|| { PathBuf::from("/tmp") }) } pub fn home_dir() -> Option { - return ::env::var_os("HOME").map(PathBuf::from); + return crate::env::var_os("HOME").map(PathBuf::from); } pub fn exit(code: i32) -> ! { diff --git a/src/libstd/sys/redox/os_str.rs b/src/libstd/sys/redox/os_str.rs index 9d5e084feb2d6..79b43458d00f3 100644 --- a/src/libstd/sys/redox/os_str.rs +++ b/src/libstd/sys/redox/os_str.rs @@ -1,14 +1,15 @@ /// The underlying OsString/OsStr implementation on Unix systems: just /// a `Vec`/`[u8]`. -use borrow::Cow; -use fmt; -use str; -use mem; -use rc::Rc; -use sync::Arc; -use sys_common::{AsInner, IntoInner}; -use sys_common::bytestring::debug_fmt_bytestring; +use crate::borrow::Cow; +use crate::fmt; +use crate::str; +use crate::mem; +use crate::rc::Rc; +use crate::sync::Arc; +use crate::sys_common::{AsInner, IntoInner}; +use crate::sys_common::bytestring::debug_fmt_bytestring; + use core::str::lossy::Utf8Lossy; #[derive(Clone, Hash)] diff --git a/src/libstd/sys/redox/path.rs b/src/libstd/sys/redox/path.rs index a7a8b03c8b1f6..618d61e6fcb45 100644 --- a/src/libstd/sys/redox/path.rs +++ b/src/libstd/sys/redox/path.rs @@ -1,5 +1,5 @@ -use ffi::OsStr; -use path::Prefix; +use crate::ffi::OsStr; +use crate::path::Prefix; #[inline] pub fn is_sep_byte(b: u8) -> bool { diff --git a/src/libstd/sys/redox/pipe.rs b/src/libstd/sys/redox/pipe.rs index 9e40eadb2370e..911ba9c3f6524 100644 --- a/src/libstd/sys/redox/pipe.rs +++ b/src/libstd/sys/redox/pipe.rs @@ -1,6 +1,6 @@ -use io; -use sys::{cvt, syscall}; -use sys::fd::FileDesc; +use crate::io; +use crate::sys::{cvt, syscall}; +use crate::sys::fd::FileDesc; //////////////////////////////////////////////////////////////////////////////// // Anonymous pipes diff --git a/src/libstd/sys/redox/process.rs b/src/libstd/sys/redox/process.rs index 81af8eb553d00..8830cdf333ef8 100644 --- a/src/libstd/sys/redox/process.rs +++ b/src/libstd/sys/redox/process.rs @@ -1,20 +1,21 @@ -use env::{split_paths}; -use ffi::{CStr, OsStr}; -use fmt; -use fs::File; -use io::{self, prelude::*, BufReader, Error, ErrorKind, SeekFrom}; +use crate::env::{self, split_paths}; +use crate::ffi::{CStr, OsStr}; +use crate::fmt; +use crate::fs::File; +use crate::io::{self, prelude::*, BufReader, Error, ErrorKind, SeekFrom}; +use crate::os::unix::ffi::OsStrExt; +use crate::path::{Path, PathBuf}; +use crate::ptr; +use crate::sys::ext::fs::MetadataExt; +use crate::sys::ext::io::AsRawFd; +use crate::sys::fd::FileDesc; +use crate::sys::fs::{File as SysFile, OpenOptions}; +use crate::sys::os::{ENV_LOCK, environ}; +use crate::sys::pipe::{self, AnonPipe}; +use crate::sys::{cvt, syscall}; +use crate::sys_common::process::{CommandEnv, DefaultEnvKey}; + use libc::{EXIT_SUCCESS, EXIT_FAILURE}; -use os::unix::ffi::OsStrExt; -use path::{Path, PathBuf}; -use ptr; -use sys::ext::fs::MetadataExt; -use sys::ext::io::AsRawFd; -use sys::fd::FileDesc; -use sys::fs::{File as SysFile, OpenOptions}; -use sys::os::{ENV_LOCK, environ}; -use sys::pipe::{self, AnonPipe}; -use sys::{cvt, syscall}; -use sys_common::process::{CommandEnv, DefaultEnvKey}; //////////////////////////////////////////////////////////////////////////////// // Command @@ -297,7 +298,7 @@ impl Command { let program = if self.program.contains(':') || self.program.contains('/') { Some(PathBuf::from(&self.program)) - } else if let Ok(path_env) = ::env::var("PATH") { + } else if let Ok(path_env) = env::var("PATH") { let mut program = None; for mut path in split_paths(&path_env) { path.push(&self.program); diff --git a/src/libstd/sys/redox/stdio.rs b/src/libstd/sys/redox/stdio.rs index 8571b38cefa1c..33f5bdbb5d358 100644 --- a/src/libstd/sys/redox/stdio.rs +++ b/src/libstd/sys/redox/stdio.rs @@ -1,6 +1,6 @@ -use io; -use sys::{cvt, syscall}; -use sys::fd::FileDesc; +use crate::io; +use crate::sys::{cvt, syscall}; +use crate::sys::fd::FileDesc; pub struct Stdin(()); pub struct Stdout(()); @@ -54,10 +54,10 @@ impl io::Write for Stderr { } pub fn is_ebadf(err: &io::Error) -> bool { - err.raw_os_error() == Some(::sys::syscall::EBADF as i32) + err.raw_os_error() == Some(crate::sys::syscall::EBADF as i32) } -pub const STDIN_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE; +pub const STDIN_BUF_SIZE: usize = crate::sys_common::io::DEFAULT_BUF_SIZE; pub fn panic_output() -> Option { Stderr::new().ok() diff --git a/src/libstd/sys/redox/thread.rs b/src/libstd/sys/redox/thread.rs index 18679a7871e24..ae0b91b4d6c7d 100644 --- a/src/libstd/sys/redox/thread.rs +++ b/src/libstd/sys/redox/thread.rs @@ -1,10 +1,10 @@ -use boxed::FnBox; -use ffi::CStr; -use io; -use mem; -use sys_common::thread::start_thread; -use sys::{cvt, syscall}; -use time::Duration; +use crate::boxed::FnBox; +use crate::ffi::CStr; +use crate::io; +use crate::mem; +use crate::sys_common::thread::start_thread; +use crate::sys::{cvt, syscall}; +use crate::time::Duration; pub const DEFAULT_MIN_STACK_SIZE: usize = 2 * 1024 * 1024; diff --git a/src/libstd/sys/redox/thread_local.rs b/src/libstd/sys/redox/thread_local.rs index a1929b941659d..4bc8c4d5883da 100644 --- a/src/libstd/sys/redox/thread_local.rs +++ b/src/libstd/sys/redox/thread_local.rs @@ -1,8 +1,8 @@ #![allow(dead_code)] // not used on all platforms -use collections::BTreeMap; -use ptr; -use sync::atomic::{AtomicUsize, Ordering}; +use crate::collections::BTreeMap; +use crate::ptr; +use crate::sync::atomic::{AtomicUsize, Ordering}; pub type Key = usize; diff --git a/src/libstd/sys/redox/time.rs b/src/libstd/sys/redox/time.rs index 401b7012aa7e9..9db3e85ca9c8b 100644 --- a/src/libstd/sys/redox/time.rs +++ b/src/libstd/sys/redox/time.rs @@ -1,8 +1,9 @@ -use cmp::Ordering; -use fmt; -use sys::{cvt, syscall}; -use time::Duration; -use convert::TryInto; +use crate::cmp::Ordering; +use crate::fmt; +use crate::sys::{cvt, syscall}; +use crate::time::Duration; +use crate::convert::TryInto; + use core::hash::{Hash, Hasher}; const NSEC_PER_SEC: u64 = 1_000_000_000; diff --git a/src/libstd/sys/sgx/abi/mod.rs b/src/libstd/sys/sgx/abi/mod.rs index 509a1990d978b..7426f7be9e961 100644 --- a/src/libstd/sys/sgx/abi/mod.rs +++ b/src/libstd/sys/sgx/abi/mod.rs @@ -1,5 +1,5 @@ use core::sync::atomic::{AtomicUsize, Ordering}; -use io::Write; +use crate::io::Write; // runtime features mod reloc; @@ -37,7 +37,7 @@ unsafe extern "C" fn tcs_init(secondary: bool) { }, // We need to wait until the initialization is done. BUSY => while RELOC_STATE.load(Ordering::Acquire) == BUSY { - ::core::arch::x86_64::_mm_pause() + core::arch::x86_64::_mm_pause() }, // Initialization is done. DONE => {}, diff --git a/src/libstd/sys/sgx/abi/panic.rs b/src/libstd/sys/sgx/abi/panic.rs index b2afacc70b82e..83411cb5b4c26 100644 --- a/src/libstd/sys/sgx/abi/panic.rs +++ b/src/libstd/sys/sgx/abi/panic.rs @@ -1,7 +1,7 @@ use super::usercalls::{alloc::UserRef, self}; -use cmp; -use io::{self, Write}; -use mem; +use crate::cmp; +use crate::io::{self, Write}; +use crate::mem; extern "C" { fn take_debug_panic_buf_ptr() -> *mut u8; diff --git a/src/libstd/sys/sgx/abi/reloc.rs b/src/libstd/sys/sgx/abi/reloc.rs index 4dd41d70bd703..a39841bc36f53 100644 --- a/src/libstd/sys/sgx/abi/reloc.rs +++ b/src/libstd/sys/sgx/abi/reloc.rs @@ -1,4 +1,4 @@ -use slice::from_raw_parts; +use crate::slice::from_raw_parts; use super::mem; const R_X86_64_RELATIVE: u32 = 8; diff --git a/src/libstd/sys/sgx/abi/tls.rs b/src/libstd/sys/sgx/abi/tls.rs index e1fc369684527..b2a812c7231da 100644 --- a/src/libstd/sys/sgx/abi/tls.rs +++ b/src/libstd/sys/sgx/abi/tls.rs @@ -1,8 +1,8 @@ -use sync::atomic::{AtomicUsize, Ordering}; -use ptr; -use mem; -use cell::Cell; -use num::NonZeroUsize; +use crate::sync::atomic::{AtomicUsize, Ordering}; +use crate::ptr; +use crate::mem; +use crate::cell::Cell; +use crate::num::NonZeroUsize; use self::sync_bitset::*; #[cfg(target_pointer_width="64")] @@ -152,9 +152,9 @@ impl Tls { } mod sync_bitset { - use sync::atomic::{AtomicUsize, Ordering}; - use iter::{Enumerate, Peekable}; - use slice::Iter; + use crate::sync::atomic::{AtomicUsize, Ordering}; + use crate::iter::{Enumerate, Peekable}; + use crate::slice::Iter; use super::{TLS_KEYS_BITSET_SIZE, USIZE_BITS}; /// A bitset that can be used synchronously. diff --git a/src/libstd/sys/sgx/abi/usercalls/alloc.rs b/src/libstd/sys/sgx/abi/usercalls/alloc.rs index 0ccbbbc65015d..b787bd1a5abac 100644 --- a/src/libstd/sys/sgx/abi/usercalls/alloc.rs +++ b/src/libstd/sys/sgx/abi/usercalls/alloc.rs @@ -1,11 +1,11 @@ #![allow(unused)] -use ptr::{self, NonNull}; -use mem; -use cell::UnsafeCell; -use slice; -use ops::{Deref, DerefMut, Index, IndexMut, CoerceUnsized}; -use slice::SliceIndex; +use crate::ptr::{self, NonNull}; +use crate::mem; +use crate::cell::UnsafeCell; +use crate::slice; +use crate::ops::{Deref, DerefMut, Index, IndexMut, CoerceUnsized}; +use crate::slice::SliceIndex; use fortanix_sgx_abi::*; use super::super::mem::is_user_range; diff --git a/src/libstd/sys/sgx/abi/usercalls/mod.rs b/src/libstd/sys/sgx/abi/usercalls/mod.rs index 511d6e9e9273a..d84b6154cbebf 100644 --- a/src/libstd/sys/sgx/abi/usercalls/mod.rs +++ b/src/libstd/sys/sgx/abi/usercalls/mod.rs @@ -1,5 +1,5 @@ -use io::{Error as IoError, Result as IoResult}; -use time::Duration; +use crate::io::{Error as IoError, Result as IoResult}; +use crate::time::Duration; pub(crate) mod alloc; #[macro_use] @@ -22,7 +22,7 @@ pub fn read(fd: Fd, buf: &mut [u8]) -> IoResult { #[unstable(feature = "sgx_platform", issue = "56975")] pub fn read_alloc(fd: Fd) -> IoResult> { unsafe { - let userbuf = ByteBuffer { data: ::ptr::null_mut(), len: 0 }; + let userbuf = ByteBuffer { data: crate::ptr::null_mut(), len: 0 }; let mut userbuf = alloc::User::new_from_enclave(&userbuf); raw::read_alloc(fd, userbuf.as_raw_mut_ptr()).from_sgx_result()?; Ok(userbuf.copy_user_buffer()) diff --git a/src/libstd/sys/sgx/abi/usercalls/raw.rs b/src/libstd/sys/sgx/abi/usercalls/raw.rs index 447f20584f859..ad0b6d7b3d8ec 100644 --- a/src/libstd/sys/sgx/abi/usercalls/raw.rs +++ b/src/libstd/sys/sgx/abi/usercalls/raw.rs @@ -3,8 +3,8 @@ #[unstable(feature = "sgx_platform", issue = "56975")] pub use fortanix_sgx_abi::*; -use ptr::NonNull; -use num::NonZeroU64; +use crate::ptr::NonNull; +use crate::num::NonZeroU64; #[repr(C)] struct UsercallReturn(u64, u64); @@ -35,7 +35,7 @@ pub unsafe fn do_usercall(nr: NonZeroU64, p1: u64, p2: u64, p3: u64, p4: u64, ab type Register = u64; trait RegisterArgument { - fn from_register(Register) -> Self; + fn from_register(_: Register) -> Self; fn into_register(self) -> Register; } diff --git a/src/libstd/sys/sgx/alloc.rs b/src/libstd/sys/sgx/alloc.rs index 95284190bddce..94dc8ec25b587 100644 --- a/src/libstd/sys/sgx/alloc.rs +++ b/src/libstd/sys/sgx/alloc.rs @@ -1,6 +1,4 @@ -extern crate dlmalloc; - -use alloc::{GlobalAlloc, Layout, System}; +use crate::alloc::{GlobalAlloc, Layout, System}; use super::waitqueue::SpinMutex; diff --git a/src/libstd/sys/sgx/args.rs b/src/libstd/sys/sgx/args.rs index bc138a64019a5..b73bf9213b772 100644 --- a/src/libstd/sys/sgx/args.rs +++ b/src/libstd/sys/sgx/args.rs @@ -1,9 +1,9 @@ -use ffi::OsString; use super::abi::usercalls::{alloc, raw::ByteBuffer}; -use sync::atomic::{AtomicUsize, Ordering}; -use sys::os_str::Buf; -use sys_common::FromInner; -use slice; +use crate::ffi::OsString; +use crate::sync::atomic::{AtomicUsize, Ordering}; +use crate::sys::os_str::Buf; +use crate::sys_common::FromInner; +use crate::slice; static ARGS: AtomicUsize = AtomicUsize::new(0); type ArgsStore = Vec; diff --git a/src/libstd/sys/sgx/backtrace.rs b/src/libstd/sys/sgx/backtrace.rs index 2b8e1da05791d..d0361574e39d6 100644 --- a/src/libstd/sys/sgx/backtrace.rs +++ b/src/libstd/sys/sgx/backtrace.rs @@ -1,9 +1,10 @@ -use io; -use error::Error; -use libc; -use sys_common::backtrace::Frame; +use crate::io; +use crate::error::Error; +use crate::fmt; +use crate::sys_common::backtrace::Frame; +use crate::sys::sgx::abi::mem::image_base; + use unwind as uw; -use sys::sgx::abi::mem::image_base; pub struct BacktraceContext; @@ -21,8 +22,8 @@ impl Error for UnwindError { } } -impl ::fmt::Display for UnwindError { - fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { +impl fmt::Display for UnwindError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}: {:?}", self.description(), self.0) } } diff --git a/src/libstd/sys/sgx/condvar.rs b/src/libstd/sys/sgx/condvar.rs index b42e5490c72dd..e9a7684f74d00 100644 --- a/src/libstd/sys/sgx/condvar.rs +++ b/src/libstd/sys/sgx/condvar.rs @@ -1,5 +1,5 @@ -use sys::mutex::Mutex; -use time::Duration; +use crate::sys::mutex::Mutex; +use crate::time::Duration; use super::waitqueue::{WaitVariable, WaitQueue, SpinMutex}; diff --git a/src/libstd/sys/sgx/ext/arch.rs b/src/libstd/sys/sgx/ext/arch.rs index 97f7d9181a539..53fb371947a99 100644 --- a/src/libstd/sys/sgx/ext/arch.rs +++ b/src/libstd/sys/sgx/ext/arch.rs @@ -4,7 +4,7 @@ //! Software Developer's Manual, Volume 3, Chapter 40. #![unstable(feature = "sgx_platform", issue = "56975")] -use mem::MaybeUninit; +use crate::mem::MaybeUninit; /// Wrapper struct to force 16-byte alignment. #[repr(align(16))] diff --git a/src/libstd/sys/sgx/ext/ffi.rs b/src/libstd/sys/sgx/ext/ffi.rs index 7b0ffea49ae7c..ad7ade9b17d81 100644 --- a/src/libstd/sys/sgx/ext/ffi.rs +++ b/src/libstd/sys/sgx/ext/ffi.rs @@ -2,10 +2,10 @@ #![unstable(feature = "sgx_platform", issue = "56975")] -use ffi::{OsStr, OsString}; -use mem; -use sys::os_str::Buf; -use sys_common::{FromInner, IntoInner, AsInner}; +use crate::ffi::{OsStr, OsString}; +use crate::mem; +use crate::sys::os_str::Buf; +use crate::sys_common::{FromInner, IntoInner, AsInner}; /// SGX-specific extensions to [`OsString`]. /// diff --git a/src/libstd/sys/sgx/ext/io.rs b/src/libstd/sys/sgx/ext/io.rs index 1eb269783c5ab..fc88d10d3eddb 100644 --- a/src/libstd/sys/sgx/ext/io.rs +++ b/src/libstd/sys/sgx/ext/io.rs @@ -4,9 +4,9 @@ //! description of [`TryIntoRawFd`](trait.TryIntoRawFd.html) for more details. #![unstable(feature = "sgx_platform", issue = "56975")] -pub use sys::abi::usercalls::raw::Fd as RawFd; -use net; -use sys::{self, AsInner, FromInner, IntoInner, TryIntoInner}; +pub use crate::sys::abi::usercalls::raw::Fd as RawFd; +use crate::net; +use crate::sys::{self, AsInner, FromInner, IntoInner, TryIntoInner}; /// A trait to extract the raw SGX file descriptor from an underlying /// object. diff --git a/src/libstd/sys/sgx/fd.rs b/src/libstd/sys/sgx/fd.rs index 69077728b1a9a..a9924f55f12b0 100644 --- a/src/libstd/sys/sgx/fd.rs +++ b/src/libstd/sys/sgx/fd.rs @@ -1,8 +1,8 @@ use fortanix_sgx_abi::Fd; -use io; -use mem; -use sys::{AsInner, FromInner, IntoInner}; +use crate::io; +use crate::mem; +use crate::sys::{AsInner, FromInner, IntoInner}; use super::abi::usercalls; #[derive(Debug)] diff --git a/src/libstd/sys/sgx/fs.rs b/src/libstd/sys/sgx/fs.rs index 8b1c4476bc417..485d2c87fbd2d 100644 --- a/src/libstd/sys/sgx/fs.rs +++ b/src/libstd/sys/sgx/fs.rs @@ -1,10 +1,10 @@ -use ffi::OsString; -use fmt; -use hash::{Hash, Hasher}; -use io::{self, SeekFrom}; -use path::{Path, PathBuf}; -use sys::time::SystemTime; -use sys::{unsupported, Void}; +use crate::ffi::OsString; +use crate::fmt; +use crate::hash::{Hash, Hasher}; +use crate::io::{self, SeekFrom}; +use crate::path::{Path, PathBuf}; +use crate::sys::time::SystemTime; +use crate::sys::{unsupported, Void}; pub struct File(Void); diff --git a/src/libstd/sys/sgx/mod.rs b/src/libstd/sys/sgx/mod.rs index 403dd61187fc3..325df7688f37b 100644 --- a/src/libstd/sys/sgx/mod.rs +++ b/src/libstd/sys/sgx/mod.rs @@ -3,8 +3,9 @@ //! This module contains the facade (aka platform-specific) implementations of //! OS level functionality for Fortanix SGX. -use os::raw::c_char; -use sync::atomic::{AtomicBool, Ordering}; +use crate::io::ErrorKind; +use crate::os::raw::c_char; +use crate::sync::atomic::{AtomicBool, Ordering}; pub mod abi; mod waitqueue; @@ -41,12 +42,12 @@ pub fn init() { /// This function is used to implement functionality that simply doesn't exist. /// Programs relying on this functionality will need to deal with the error. -pub fn unsupported() -> ::io::Result { +pub fn unsupported() -> crate::io::Result { Err(unsupported_err()) } -pub fn unsupported_err() -> ::io::Error { - ::io::Error::new(::io::ErrorKind::Other, +pub fn unsupported_err() -> crate::io::Error { + crate::io::Error::new(ErrorKind::Other, "operation not supported on SGX yet") } @@ -55,58 +56,58 @@ pub fn unsupported_err() -> ::io::Error { /// returned, the program might very well be able to function normally. This is /// what happens when `SGX_INEFFECTIVE_ERROR` is set to `true`. If it is /// `false`, the behavior is the same as `unsupported`. -pub fn sgx_ineffective(v: T) -> ::io::Result { +pub fn sgx_ineffective(v: T) -> crate::io::Result { static SGX_INEFFECTIVE_ERROR: AtomicBool = AtomicBool::new(false); if SGX_INEFFECTIVE_ERROR.load(Ordering::Relaxed) { - Err(::io::Error::new(::io::ErrorKind::Other, + Err(crate::io::Error::new(ErrorKind::Other, "operation can't be trusted to have any effect on SGX")) } else { Ok(v) } } -pub fn decode_error_kind(code: i32) -> ::io::ErrorKind { +pub fn decode_error_kind(code: i32) -> ErrorKind { use fortanix_sgx_abi::Error; // FIXME: not sure how to make sure all variants of Error are covered if code == Error::NotFound as _ { - ::io::ErrorKind::NotFound + ErrorKind::NotFound } else if code == Error::PermissionDenied as _ { - ::io::ErrorKind::PermissionDenied + ErrorKind::PermissionDenied } else if code == Error::ConnectionRefused as _ { - ::io::ErrorKind::ConnectionRefused + ErrorKind::ConnectionRefused } else if code == Error::ConnectionReset as _ { - ::io::ErrorKind::ConnectionReset + ErrorKind::ConnectionReset } else if code == Error::ConnectionAborted as _ { - ::io::ErrorKind::ConnectionAborted + ErrorKind::ConnectionAborted } else if code == Error::NotConnected as _ { - ::io::ErrorKind::NotConnected + ErrorKind::NotConnected } else if code == Error::AddrInUse as _ { - ::io::ErrorKind::AddrInUse + ErrorKind::AddrInUse } else if code == Error::AddrNotAvailable as _ { - ::io::ErrorKind::AddrNotAvailable + ErrorKind::AddrNotAvailable } else if code == Error::BrokenPipe as _ { - ::io::ErrorKind::BrokenPipe + ErrorKind::BrokenPipe } else if code == Error::AlreadyExists as _ { - ::io::ErrorKind::AlreadyExists + ErrorKind::AlreadyExists } else if code == Error::WouldBlock as _ { - ::io::ErrorKind::WouldBlock + ErrorKind::WouldBlock } else if code == Error::InvalidInput as _ { - ::io::ErrorKind::InvalidInput + ErrorKind::InvalidInput } else if code == Error::InvalidData as _ { - ::io::ErrorKind::InvalidData + ErrorKind::InvalidData } else if code == Error::TimedOut as _ { - ::io::ErrorKind::TimedOut + ErrorKind::TimedOut } else if code == Error::WriteZero as _ { - ::io::ErrorKind::WriteZero + ErrorKind::WriteZero } else if code == Error::Interrupted as _ { - ::io::ErrorKind::Interrupted + ErrorKind::Interrupted } else if code == Error::Other as _ { - ::io::ErrorKind::Other + ErrorKind::Other } else if code == Error::UnexpectedEof as _ { - ::io::ErrorKind::UnexpectedEof + ErrorKind::UnexpectedEof } else { - ::io::ErrorKind::Other + ErrorKind::Other } } @@ -131,9 +132,9 @@ pub unsafe fn abort_internal() -> ! { pub fn hashmap_random_keys() -> (u64, u64) { fn rdrand64() -> u64 { unsafe { - let mut ret: u64 = ::mem::uninitialized(); + let mut ret: u64 = crate::mem::uninitialized(); for _ in 0..10 { - if ::arch::x86_64::_rdrand64_step(&mut ret) == 1 { + if crate::arch::x86_64::_rdrand64_step(&mut ret) == 1 { return ret; } } @@ -143,7 +144,7 @@ pub fn hashmap_random_keys() -> (u64, u64) { (rdrand64(), rdrand64()) } -pub use sys_common::{AsInner, FromInner, IntoInner}; +pub use crate::sys_common::{AsInner, FromInner, IntoInner}; pub trait TryIntoInner: Sized { fn try_into_inner(self) -> Result; diff --git a/src/libstd/sys/sgx/net.rs b/src/libstd/sys/sgx/net.rs index c4c2de43ff7df..ab8b2681393f8 100644 --- a/src/libstd/sys/sgx/net.rs +++ b/src/libstd/sys/sgx/net.rs @@ -1,12 +1,12 @@ -use fmt; -use io::{self, IoVec, IoVecMut}; -use net::{SocketAddr, Shutdown, Ipv4Addr, Ipv6Addr, ToSocketAddrs}; -use time::Duration; -use sys::{unsupported, Void, sgx_ineffective, AsInner, FromInner, IntoInner, TryIntoInner}; -use sys::fd::FileDesc; -use convert::TryFrom; -use error; -use sync::Arc; +use crate::fmt; +use crate::io::{self, IoVec, IoVecMut}; +use crate::net::{SocketAddr, Shutdown, Ipv4Addr, Ipv6Addr, ToSocketAddrs}; +use crate::time::Duration; +use crate::sys::{unsupported, Void, sgx_ineffective, AsInner, FromInner, IntoInner, TryIntoInner}; +use crate::sys::fd::FileDesc; +use crate::convert::TryFrom; +use crate::error; +use crate::sync::Arc; use super::abi::usercalls; diff --git a/src/libstd/sys/sgx/os.rs b/src/libstd/sys/sgx/os.rs index b1e4d371a6779..2725e66ce5de4 100644 --- a/src/libstd/sys/sgx/os.rs +++ b/src/libstd/sys/sgx/os.rs @@ -1,17 +1,17 @@ use fortanix_sgx_abi::{Error, RESULT_SUCCESS}; -use error::Error as StdError; -use ffi::{OsString, OsStr}; -use fmt; -use io; -use path::{self, PathBuf}; -use str; -use sys::{unsupported, Void, sgx_ineffective, decode_error_kind}; -use collections::HashMap; -use vec; -use sync::Mutex; -use sync::atomic::{AtomicUsize, Ordering}; -use sync::Once; +use crate::error::Error as StdError; +use crate::ffi::{OsString, OsStr}; +use crate::fmt; +use crate::io; +use crate::path::{self, PathBuf}; +use crate::str; +use crate::sys::{unsupported, Void, sgx_ineffective, decode_error_kind}; +use crate::collections::HashMap; +use crate::vec; +use crate::sync::Mutex; +use crate::sync::atomic::{AtomicUsize, Ordering}; +use crate::sync::Once; pub fn errno() -> i32 { RESULT_SUCCESS diff --git a/src/libstd/sys/sgx/os_str.rs b/src/libstd/sys/sgx/os_str.rs index 9d5e084feb2d6..79b43458d00f3 100644 --- a/src/libstd/sys/sgx/os_str.rs +++ b/src/libstd/sys/sgx/os_str.rs @@ -1,14 +1,15 @@ /// The underlying OsString/OsStr implementation on Unix systems: just /// a `Vec`/`[u8]`. -use borrow::Cow; -use fmt; -use str; -use mem; -use rc::Rc; -use sync::Arc; -use sys_common::{AsInner, IntoInner}; -use sys_common::bytestring::debug_fmt_bytestring; +use crate::borrow::Cow; +use crate::fmt; +use crate::str; +use crate::mem; +use crate::rc::Rc; +use crate::sync::Arc; +use crate::sys_common::{AsInner, IntoInner}; +use crate::sys_common::bytestring::debug_fmt_bytestring; + use core::str::lossy::Utf8Lossy; #[derive(Clone, Hash)] diff --git a/src/libstd/sys/sgx/path.rs b/src/libstd/sys/sgx/path.rs index 90b1fa7c97b96..1115de1fbe5ba 100644 --- a/src/libstd/sys/sgx/path.rs +++ b/src/libstd/sys/sgx/path.rs @@ -1,5 +1,5 @@ -use path::Prefix; -use ffi::OsStr; +use crate::path::Prefix; +use crate::ffi::OsStr; #[inline] pub fn is_sep_byte(b: u8) -> bool { diff --git a/src/libstd/sys/sgx/pipe.rs b/src/libstd/sys/sgx/pipe.rs index ac48a6dc03323..2582b993b608e 100644 --- a/src/libstd/sys/sgx/pipe.rs +++ b/src/libstd/sys/sgx/pipe.rs @@ -1,5 +1,5 @@ -use io; -use sys::Void; +use crate::io; +use crate::sys::Void; pub struct AnonPipe(Void); diff --git a/src/libstd/sys/sgx/process.rs b/src/libstd/sys/sgx/process.rs index 5357d931c7367..c49daaa16320e 100644 --- a/src/libstd/sys/sgx/process.rs +++ b/src/libstd/sys/sgx/process.rs @@ -1,10 +1,10 @@ -use ffi::OsStr; -use fmt; -use io; -use sys::fs::File; -use sys::pipe::AnonPipe; -use sys::{unsupported, Void}; -use sys_common::process::{CommandEnv, DefaultEnvKey}; +use crate::ffi::OsStr; +use crate::fmt; +use crate::io; +use crate::sys::fs::File; +use crate::sys::pipe::AnonPipe; +use crate::sys::{unsupported, Void}; +use crate::sys_common::process::{CommandEnv, DefaultEnvKey}; //////////////////////////////////////////////////////////////////////////////// // Command diff --git a/src/libstd/sys/sgx/rwlock.rs b/src/libstd/sys/sgx/rwlock.rs index 4dfbe86d14f4d..372760bbf26b4 100644 --- a/src/libstd/sys/sgx/rwlock.rs +++ b/src/libstd/sys/sgx/rwlock.rs @@ -1,12 +1,12 @@ -use alloc::{self, Layout}; -use num::NonZeroUsize; -use slice; -use str; +use crate::alloc::{self, Layout}; +use crate::num::NonZeroUsize; +use crate::slice; +use crate::str; use super::waitqueue::{ try_lock_or_false, NotifiedTcs, SpinMutex, SpinMutexGuard, WaitQueue, WaitVariable, }; -use mem; +use crate::mem; pub struct RWLock { readers: SpinMutex>>, @@ -206,7 +206,7 @@ pub unsafe extern "C" fn __rust_print_err(m: *mut u8, s: i32) { #[no_mangle] // NB. used by both libunwind and libpanic_abort pub unsafe extern "C" fn __rust_abort() { - ::sys::abort_internal(); + crate::sys::abort_internal(); } #[no_mangle] @@ -224,8 +224,8 @@ mod tests { use super::*; use core::array::FixedSizeArray; - use mem::MaybeUninit; - use {mem, ptr}; + use crate::mem::MaybeUninit; + use crate::{mem, ptr}; // The below test verifies that the bytes of initialized RWLock are the ones // we use in libunwind. diff --git a/src/libstd/sys/sgx/stdio.rs b/src/libstd/sys/sgx/stdio.rs index 57d66ed9a853c..f2c6892bfb7fd 100644 --- a/src/libstd/sys/sgx/stdio.rs +++ b/src/libstd/sys/sgx/stdio.rs @@ -1,7 +1,7 @@ use fortanix_sgx_abi as abi; -use io; -use sys::fd::FileDesc; +use crate::io; +use crate::sys::fd::FileDesc; pub struct Stdin(()); pub struct Stdout(()); @@ -52,7 +52,7 @@ impl io::Write for Stderr { } } -pub const STDIN_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE; +pub const STDIN_BUF_SIZE: usize = crate::sys_common::io::DEFAULT_BUF_SIZE; pub fn is_ebadf(err: &io::Error) -> bool { // FIXME: Rust normally maps Unix EBADF to `Other` diff --git a/src/libstd/sys/sgx/thread.rs b/src/libstd/sys/sgx/thread.rs index b4bdb03e61af6..13569062ac184 100644 --- a/src/libstd/sys/sgx/thread.rs +++ b/src/libstd/sys/sgx/thread.rs @@ -1,7 +1,7 @@ -use boxed::FnBox; -use ffi::CStr; -use io; -use time::Duration; +use crate::boxed::FnBox; +use crate::ffi::CStr; +use crate::io; +use crate::time::Duration; use super::abi::usercalls; @@ -10,9 +10,9 @@ pub struct Thread(task_queue::JoinHandle); pub const DEFAULT_MIN_STACK_SIZE: usize = 4096; mod task_queue { - use sync::{Mutex, MutexGuard, Once}; - use sync::mpsc; - use boxed::FnBox; + use crate::sync::{Mutex, MutexGuard, Once}; + use crate::sync::mpsc; + use crate::boxed::FnBox; pub type JoinHandle = mpsc::Receiver<()>; diff --git a/src/libstd/sys/sgx/time.rs b/src/libstd/sys/sgx/time.rs index 407fe72b0e623..e4f789c3e3656 100644 --- a/src/libstd/sys/sgx/time.rs +++ b/src/libstd/sys/sgx/time.rs @@ -1,4 +1,4 @@ -use time::Duration; +use crate::time::Duration; use super::abi::usercalls; #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)] diff --git a/src/libstd/sys/sgx/waitqueue.rs b/src/libstd/sys/sgx/waitqueue.rs index aec643b3175b4..1dbf2afbf4987 100644 --- a/src/libstd/sys/sgx/waitqueue.rs +++ b/src/libstd/sys/sgx/waitqueue.rs @@ -10,8 +10,8 @@ /// recorded in the enclave. The wakeup event state is protected by a spinlock. /// The queue and associated wait state are stored in a `WaitVariable`. -use ops::{Deref, DerefMut}; -use num::NonZeroUsize; +use crate::ops::{Deref, DerefMut}; +use crate::num::NonZeroUsize; use fortanix_sgx_abi::{Tcs, EV_UNPARK, WAIT_INDEFINITE}; use super::abi::usercalls; @@ -211,8 +211,8 @@ impl WaitQueue { /// A doubly-linked list where callers are in charge of memory allocation /// of the nodes in the list. mod unsafe_list { - use ptr::NonNull; - use mem; + use crate::ptr::NonNull; + use crate::mem; pub struct UnsafeListEntry { next: NonNull>, @@ -341,7 +341,7 @@ mod unsafe_list { #[cfg(test)] mod tests { use super::*; - use cell::Cell; + use crate::cell::Cell; unsafe fn assert_empty(list: &mut UnsafeList) { assert!(list.pop().is_none(), "assertion failed: list is not empty"); @@ -404,9 +404,9 @@ mod unsafe_list { /// Trivial spinlock-based implementation of `sync::Mutex`. // FIXME: Perhaps use Intel TSX to avoid locking? mod spin_mutex { - use cell::UnsafeCell; - use sync::atomic::{AtomicBool, Ordering, spin_loop_hint}; - use ops::{Deref, DerefMut}; + use crate::cell::UnsafeCell; + use crate::sync::atomic::{AtomicBool, Ordering, spin_loop_hint}; + use crate::ops::{Deref, DerefMut}; #[derive(Default)] pub struct SpinMutex { @@ -496,8 +496,8 @@ mod spin_mutex { #![allow(deprecated)] use super::*; - use sync::Arc; - use thread; + use crate::sync::Arc; + use crate::thread; #[test] fn sleep() { @@ -519,8 +519,8 @@ mod spin_mutex { #[cfg(test)] mod tests { use super::*; - use sync::Arc; - use thread; + use crate::sync::Arc; + use crate::thread; #[test] fn queue() { diff --git a/src/libstd/sys/unix/alloc.rs b/src/libstd/sys/unix/alloc.rs index 93e8e0e669671..8e8f5017da75a 100644 --- a/src/libstd/sys/unix/alloc.rs +++ b/src/libstd/sys/unix/alloc.rs @@ -1,7 +1,6 @@ -use ptr; -use libc; -use sys_common::alloc::{MIN_ALIGN, realloc_fallback}; -use alloc::{GlobalAlloc, Layout, System}; +use crate::ptr; +use crate::sys_common::alloc::{MIN_ALIGN, realloc_fallback}; +use crate::alloc::{GlobalAlloc, Layout, System}; #[stable(feature = "alloc_system_type", since = "1.28.0")] unsafe impl GlobalAlloc for System { diff --git a/src/libstd/sys/unix/android.rs b/src/libstd/sys/unix/android.rs index 986fa27ede666..6774160bb2561 100644 --- a/src/libstd/sys/unix/android.rs +++ b/src/libstd/sys/unix/android.rs @@ -21,7 +21,7 @@ use libc::{c_int, c_void, sighandler_t, size_t, ssize_t}; use libc::{ftruncate, pread, pwrite}; -use io; +use crate::io; use super::{cvt, cvt_r}; // The `log2` and `log2f` functions apparently appeared in android-18, or at @@ -49,12 +49,12 @@ use super::{cvt, cvt_r}; #[cfg(not(test))] pub fn log2f32(f: f32) -> f32 { - f.ln() * ::f32::consts::LOG2_E + f.ln() * crate::f32::consts::LOG2_E } #[cfg(not(test))] pub fn log2f64(f: f64) -> f64 { - f.ln() * ::f64::consts::LOG2_E + f.ln() * crate::f64::consts::LOG2_E } // Back in the day [1] the `signal` function was just an inline wrapper @@ -117,7 +117,7 @@ pub fn ftruncate64(fd: c_int, size: u64) -> io::Result<()> { pub unsafe fn cvt_pread64(fd: c_int, buf: *mut c_void, count: size_t, offset: i64) -> io::Result { - use convert::TryInto; + use crate::convert::TryInto; weak!(fn pread64(c_int, *mut c_void, size_t, i64) -> ssize_t); pread64.get().map(|f| cvt(f(fd, buf, count, offset))).unwrap_or_else(|| { if let Ok(o) = offset.try_into() { @@ -133,7 +133,7 @@ pub unsafe fn cvt_pread64(fd: c_int, buf: *mut c_void, count: size_t, offset: i6 pub unsafe fn cvt_pwrite64(fd: c_int, buf: *const c_void, count: size_t, offset: i64) -> io::Result { - use convert::TryInto; + use crate::convert::TryInto; weak!(fn pwrite64(c_int, *const c_void, size_t, i64) -> ssize_t); pwrite64.get().map(|f| cvt(f(fd, buf, count, offset))).unwrap_or_else(|| { if let Ok(o) = offset.try_into() { diff --git a/src/libstd/sys/unix/args.rs b/src/libstd/sys/unix/args.rs index db1c5f4fea54c..18de1096df2a2 100644 --- a/src/libstd/sys/unix/args.rs +++ b/src/libstd/sys/unix/args.rs @@ -5,9 +5,9 @@ #![allow(dead_code)] // runtime init functions not used during testing -use ffi::OsString; -use marker::PhantomData; -use vec; +use crate::ffi::OsString; +use crate::marker::PhantomData; +use crate::vec; /// One-time global initialization. pub unsafe fn init(argc: isize, argv: *const *const u8) { imp::init(argc, argv) } @@ -59,14 +59,13 @@ impl DoubleEndedIterator for Args { target_os = "fuchsia", target_os = "hermit"))] mod imp { - use os::unix::prelude::*; - use ptr; - use ffi::{CStr, OsString}; - use marker::PhantomData; - use libc; + use crate::os::unix::prelude::*; + use crate::ptr; + use crate::ffi::{CStr, OsString}; + use crate::marker::PhantomData; use super::Args; - use sys_common::mutex::Mutex; + use crate::sys_common::mutex::Mutex; static mut ARGC: isize = 0; static mut ARGV: *const *const u8 = ptr::null(); @@ -107,9 +106,8 @@ mod imp { #[cfg(any(target_os = "macos", target_os = "ios"))] mod imp { - use ffi::CStr; - use marker::PhantomData; - use libc; + use crate::ffi::CStr; + use crate::marker::PhantomData; use super::Args; pub unsafe fn init(_argc: isize, _argv: *const *const u8) { @@ -120,7 +118,7 @@ mod imp { #[cfg(target_os = "macos")] pub fn args() -> Args { - use os::unix::prelude::*; + use crate::os::unix::prelude::*; extern { // These functions are in crt_externs.h. fn _NSGetArgc() -> *mut libc::c_int; @@ -155,9 +153,9 @@ mod imp { // res #[cfg(target_os = "ios")] pub fn args() -> Args { - use ffi::OsString; - use mem; - use str; + use crate::ffi::OsString; + use crate::mem; + use crate::str; extern { fn sel_registerName(name: *const libc::c_uchar) -> Sel; diff --git a/src/libstd/sys/unix/backtrace/mod.rs b/src/libstd/sys/unix/backtrace/mod.rs index 79c3e39d8f8dd..0887e5a4df937 100644 --- a/src/libstd/sys/unix/backtrace/mod.rs +++ b/src/libstd/sys/unix/backtrace/mod.rs @@ -83,8 +83,9 @@ mod printing; #[cfg(not(target_os = "emscripten"))] pub mod gnu { - use io; - use fs; + use crate::io; + use crate::fs; + use libc::c_char; #[cfg(not(any(target_os = "macos", target_os = "ios")))] @@ -94,8 +95,8 @@ pub mod gnu { #[cfg(any(target_os = "macos", target_os = "ios"))] pub fn get_executable_filename() -> io::Result<(Vec, fs::File)> { - use env; - use os::unix::ffi::OsStrExt; + use crate::env; + use crate::os::unix::ffi::OsStrExt; let filename = env::current_exe()?; let file = fs::File::open(&filename)?; diff --git a/src/libstd/sys/unix/backtrace/printing/dladdr.rs b/src/libstd/sys/unix/backtrace/printing/dladdr.rs index 09715db8c1a34..cf3bda640e92b 100644 --- a/src/libstd/sys/unix/backtrace/printing/dladdr.rs +++ b/src/libstd/sys/unix/backtrace/printing/dladdr.rs @@ -1,9 +1,8 @@ -use io; -use intrinsics; -use ffi::CStr; -use libc; -use sys::backtrace::BacktraceContext; -use sys_common::backtrace::Frame; +use crate::io; +use crate::intrinsics; +use crate::ffi::CStr; +use crate::sys::backtrace::BacktraceContext; +use crate::sys_common::backtrace::Frame; pub fn resolve_symname(frame: Frame, callback: F, diff --git a/src/libstd/sys/unix/backtrace/printing/mod.rs b/src/libstd/sys/unix/backtrace/printing/mod.rs index d0303e6995f8b..d090caede437a 100644 --- a/src/libstd/sys/unix/backtrace/printing/mod.rs +++ b/src/libstd/sys/unix/backtrace/printing/mod.rs @@ -1,8 +1,8 @@ mod dladdr; -use sys::backtrace::BacktraceContext; -use sys_common::backtrace::Frame; -use io; +use crate::sys::backtrace::BacktraceContext; +use crate::sys_common::backtrace::Frame; +use crate::io; #[cfg(target_os = "emscripten")] pub use self::dladdr::resolve_symname; @@ -16,14 +16,14 @@ where } #[cfg(not(target_os = "emscripten"))] -pub use sys_common::gnu::libbacktrace::foreach_symbol_fileline; +pub use crate::sys_common::gnu::libbacktrace::foreach_symbol_fileline; #[cfg(not(target_os = "emscripten"))] pub fn resolve_symname(frame: Frame, callback: F, bc: &BacktraceContext) -> io::Result<()> where F: FnOnce(Option<&str>) -> io::Result<()> { - ::sys_common::gnu::libbacktrace::resolve_symname(frame, |symname| { + crate::sys_common::gnu::libbacktrace::resolve_symname(frame, |symname| { if symname.is_some() { callback(symname) } else { diff --git a/src/libstd/sys/unix/backtrace/tracing/backtrace_fn.rs b/src/libstd/sys/unix/backtrace/tracing/backtrace_fn.rs index 236762c5eb5df..a628d107ad6fb 100644 --- a/src/libstd/sys/unix/backtrace/tracing/backtrace_fn.rs +++ b/src/libstd/sys/unix/backtrace/tracing/backtrace_fn.rs @@ -8,10 +8,10 @@ /// simple to use it should be used only on iOS devices as the only viable /// option. -use io; -use libc; -use sys::backtrace::BacktraceContext; -use sys_common::backtrace::Frame; +use crate::io; +use crate::ptr; +use crate::sys::backtrace::BacktraceContext; +use crate::sys_common::backtrace::Frame; #[inline(never)] // if we know this is a function call, we can skip it when // tracing @@ -20,7 +20,7 @@ pub fn unwind_backtrace(frames: &mut [Frame]) { const FRAME_LEN: usize = 100; assert!(FRAME_LEN >= frames.len()); - let mut raw_frames = [::ptr::null_mut(); FRAME_LEN]; + let mut raw_frames = [ptr::null_mut(); FRAME_LEN]; let nb_frames = unsafe { backtrace(raw_frames.as_mut_ptr(), raw_frames.len() as libc::c_int) } as usize; diff --git a/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs b/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs index 72a7968c514ca..abbeca0fde6e7 100644 --- a/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs +++ b/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs @@ -1,8 +1,8 @@ -use error::Error; -use io; -use libc; -use sys::backtrace::BacktraceContext; -use sys_common::backtrace::Frame; +use crate::error::Error; +use crate::fmt; +use crate::io; +use crate::sys::backtrace::BacktraceContext; +use crate::sys_common::backtrace::Frame; use unwind as uw; @@ -20,8 +20,8 @@ impl Error for UnwindError { } } -impl ::fmt::Display for UnwindError { - fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { +impl fmt::Display for UnwindError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}: {:?}", self.description(), self.0) } } diff --git a/src/libstd/sys/unix/condvar.rs b/src/libstd/sys/unix/condvar.rs index 3e048d5c6e4f3..47fb6792f08ae 100644 --- a/src/libstd/sys/unix/condvar.rs +++ b/src/libstd/sys/unix/condvar.rs @@ -1,7 +1,6 @@ -use cell::UnsafeCell; -use libc; -use sys::mutex::{self, Mutex}; -use time::Duration; +use crate::cell::UnsafeCell; +use crate::sys::mutex::{self, Mutex}; +use crate::time::Duration; pub struct Condvar { inner: UnsafeCell } @@ -41,7 +40,7 @@ impl Condvar { target_os = "android", target_os = "hermit")))] pub unsafe fn init(&mut self) { - use mem; + use crate::mem; let mut attr: libc::pthread_condattr_t = mem::uninitialized(); let r = libc::pthread_condattr_init(&mut attr); assert_eq!(r, 0); @@ -80,7 +79,7 @@ impl Condvar { target_os = "android", target_os = "hermit")))] pub unsafe fn wait_timeout(&self, mutex: &Mutex, dur: Duration) -> bool { - use mem; + use crate::mem; let mut now: libc::timespec = mem::zeroed(); let r = libc::clock_gettime(libc::CLOCK_MONOTONIC, &mut now); @@ -110,8 +109,8 @@ impl Condvar { // https://github.com/llvm-mirror/libcxx/blob/release_35/include/__mutex_base#L367 #[cfg(any(target_os = "macos", target_os = "ios", target_os = "android", target_os = "hermit"))] pub unsafe fn wait_timeout(&self, mutex: &Mutex, mut dur: Duration) -> bool { - use ptr; - use time::Instant; + use crate::ptr; + use crate::time::Instant; // 1000 years let max_dur = Duration::from_secs(1000 * 365 * 86400); diff --git a/src/libstd/sys/unix/ext/ffi.rs b/src/libstd/sys/unix/ext/ffi.rs index d1c3cd82ac514..0c02323981521 100644 --- a/src/libstd/sys/unix/ext/ffi.rs +++ b/src/libstd/sys/unix/ext/ffi.rs @@ -2,10 +2,10 @@ #![stable(feature = "rust1", since = "1.0.0")] -use ffi::{OsStr, OsString}; -use mem; -use sys::os_str::Buf; -use sys_common::{FromInner, IntoInner, AsInner}; +use crate::ffi::{OsStr, OsString}; +use crate::mem; +use crate::sys::os_str::Buf; +use crate::sys_common::{FromInner, IntoInner, AsInner}; /// Unix-specific extensions to [`OsString`]. /// diff --git a/src/libstd/sys/unix/ext/fs.rs b/src/libstd/sys/unix/ext/fs.rs index abcce3ab82962..d9baac993c42c 100644 --- a/src/libstd/sys/unix/ext/fs.rs +++ b/src/libstd/sys/unix/ext/fs.rs @@ -2,13 +2,12 @@ #![stable(feature = "rust1", since = "1.0.0")] -use fs::{self, Permissions, OpenOptions}; -use io; -use libc; -use path::Path; -use sys; -use sys_common::{FromInner, AsInner, AsInnerMut}; -use sys::platform::fs::MetadataExt as UnixMetadataExt; +use crate::fs::{self, Permissions, OpenOptions}; +use crate::io; +use crate::path::Path; +use crate::sys; +use crate::sys_common::{FromInner, AsInner, AsInnerMut}; +use crate::sys::platform::fs::MetadataExt as UnixMetadataExt; /// Unix-specific extensions to [`File`]. /// diff --git a/src/libstd/sys/unix/ext/io.rs b/src/libstd/sys/unix/ext/io.rs index 73f4879e4e434..1a0b3b8962bd1 100644 --- a/src/libstd/sys/unix/ext/io.rs +++ b/src/libstd/sys/unix/ext/io.rs @@ -2,12 +2,11 @@ #![stable(feature = "rust1", since = "1.0.0")] -use fs; -use os::raw; -use sys; -use io; -use sys_common::{AsInner, FromInner, IntoInner}; -use libc; +use crate::fs; +use crate::os::raw; +use crate::sys; +use crate::io; +use crate::sys_common::{AsInner, FromInner, IntoInner}; /// Raw file descriptors. #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libstd/sys/unix/ext/net.rs b/src/libstd/sys/unix/ext/net.rs index 4b60ea654c1f1..4fc79efe7ceb5 100644 --- a/src/libstd/sys/unix/ext/net.rs +++ b/src/libstd/sys/unix/ext/net.rs @@ -15,19 +15,19 @@ mod libc { pub struct sockaddr_un; } -use ascii; -use ffi::OsStr; -use fmt; -use io::{self, Initializer, IoVec, IoVecMut}; -use mem; -use net::{self, Shutdown}; -use os::unix::ffi::OsStrExt; -use os::unix::io::{RawFd, AsRawFd, FromRawFd, IntoRawFd}; -use path::Path; -use time::Duration; -use sys::{self, cvt}; -use sys::net::Socket; -use sys_common::{self, AsInner, FromInner, IntoInner}; +use crate::ascii; +use crate::ffi::OsStr; +use crate::fmt; +use crate::io::{self, Initializer, IoVec, IoVecMut}; +use crate::mem; +use crate::net::{self, Shutdown}; +use crate::os::unix::ffi::OsStrExt; +use crate::os::unix::io::{RawFd, AsRawFd, FromRawFd, IntoRawFd}; +use crate::path::Path; +use crate::time::Duration; +use crate::sys::{self, cvt}; +use crate::sys::net::Socket; +use crate::sys_common::{self, AsInner, FromInner, IntoInner}; #[cfg(any(target_os = "linux", target_os = "android", target_os = "dragonfly", target_os = "freebsd", @@ -1481,11 +1481,11 @@ impl IntoRawFd for UnixDatagram { #[cfg(all(test, not(target_os = "emscripten")))] mod test { - use thread; - use io::{self, ErrorKind}; - use io::prelude::*; - use time::Duration; - use sys_common::io::test::tmpdir; + use crate::thread; + use crate::io::{self, ErrorKind}; + use crate::io::prelude::*; + use crate::time::Duration; + use crate::sys_common::io::test::tmpdir; use super::*; diff --git a/src/libstd/sys/unix/ext/process.rs b/src/libstd/sys/unix/ext/process.rs index b487bb889bafa..7ace95edef9fb 100644 --- a/src/libstd/sys/unix/ext/process.rs +++ b/src/libstd/sys/unix/ext/process.rs @@ -2,11 +2,11 @@ #![stable(feature = "rust1", since = "1.0.0")] -use io; -use os::unix::io::{FromRawFd, RawFd, AsRawFd, IntoRawFd}; -use process; -use sys; -use sys_common::{AsInnerMut, AsInner, FromInner, IntoInner}; +use crate::io; +use crate::os::unix::io::{FromRawFd, RawFd, AsRawFd, IntoRawFd}; +use crate::process; +use crate::sys; +use crate::sys_common::{AsInnerMut, AsInner, FromInner, IntoInner}; /// Unix-specific extensions to the [`process::Command`] builder. /// @@ -209,5 +209,5 @@ impl IntoRawFd for process::ChildStderr { /// Returns the OS-assigned process identifier associated with this process's parent. #[stable(feature = "unix_ppid", since = "1.27.0")] pub fn parent_id() -> u32 { - ::sys::os::getppid() + crate::sys::os::getppid() } diff --git a/src/libstd/sys/unix/ext/raw.rs b/src/libstd/sys/unix/ext/raw.rs index eabb4b0250308..75ae54a919ab3 100644 --- a/src/libstd/sys/unix/ext/raw.rs +++ b/src/libstd/sys/unix/ext/raw.rs @@ -14,10 +14,10 @@ #[doc(inline)] #[stable(feature = "pthread_t", since = "1.8.0")] -pub use sys::platform::raw::pthread_t; +pub use crate::sys::platform::raw::pthread_t; #[doc(inline)] #[stable(feature = "raw_ext", since = "1.1.0")] -pub use sys::platform::raw::{dev_t, ino_t, mode_t, nlink_t, off_t, blksize_t}; +pub use crate::sys::platform::raw::{dev_t, ino_t, mode_t, nlink_t, off_t, blksize_t}; #[doc(inline)] #[stable(feature = "raw_ext", since = "1.1.0")] -pub use sys::platform::raw::{blkcnt_t, time_t}; +pub use crate::sys::platform::raw::{blkcnt_t, time_t}; diff --git a/src/libstd/sys/unix/ext/thread.rs b/src/libstd/sys/unix/ext/thread.rs index 4b3d5e31848f1..759ef6236e804 100644 --- a/src/libstd/sys/unix/ext/thread.rs +++ b/src/libstd/sys/unix/ext/thread.rs @@ -3,9 +3,9 @@ #![stable(feature = "thread_extensions", since = "1.9.0")] #[allow(deprecated)] -use os::unix::raw::pthread_t; -use sys_common::{AsInner, IntoInner}; -use thread::JoinHandle; +use crate::os::unix::raw::pthread_t; +use crate::sys_common::{AsInner, IntoInner}; +use crate::thread::JoinHandle; #[stable(feature = "thread_extensions", since = "1.9.0")] #[allow(deprecated)] diff --git a/src/libstd/sys/unix/fast_thread_local.rs b/src/libstd/sys/unix/fast_thread_local.rs index 742ffd12b883d..17478dce4fe51 100644 --- a/src/libstd/sys/unix/fast_thread_local.rs +++ b/src/libstd/sys/unix/fast_thread_local.rs @@ -12,9 +12,8 @@ // Due to rust-lang/rust#18804, make sure this is not generic! #[cfg(any(target_os = "linux", target_os = "fuchsia", target_os = "hermit"))] pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern fn(*mut u8)) { - use libc; - use mem; - use sys_common::thread_local::register_dtor_fallback; + use crate::mem; + use crate::sys_common::thread_local::register_dtor_fallback; extern { #[linkage = "extern_weak"] @@ -45,8 +44,8 @@ pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern fn(*mut u8)) { // _tlv_atexit. #[cfg(target_os = "macos")] pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern fn(*mut u8)) { - use cell::Cell; - use ptr; + use crate::cell::Cell; + use crate::ptr; #[thread_local] static REGISTERED: Cell = Cell::new(false); diff --git a/src/libstd/sys/unix/fd.rs b/src/libstd/sys/unix/fd.rs index 6946b7b5dfa48..c274ad26cb1fe 100644 --- a/src/libstd/sys/unix/fd.rs +++ b/src/libstd/sys/unix/fd.rs @@ -1,12 +1,13 @@ #![unstable(reason = "not public", issue = "0", feature = "fd")] -use cmp; -use io::{self, Read, Initializer, IoVec, IoVecMut}; -use libc::{self, c_int, c_void, ssize_t}; -use mem; -use sync::atomic::{AtomicBool, Ordering}; -use sys::cvt; -use sys_common::AsInner; +use crate::cmp; +use crate::io::{self, Read, Initializer, IoVec, IoVecMut}; +use crate::mem; +use crate::sync::atomic::{AtomicBool, Ordering}; +use crate::sys::cvt; +use crate::sys_common::AsInner; + +use libc::{c_int, c_void, ssize_t}; #[derive(Debug)] pub struct FileDesc { @@ -74,7 +75,7 @@ impl FileDesc { unsafe fn cvt_pread64(fd: c_int, buf: *mut c_void, count: usize, offset: i64) -> io::Result { - use convert::TryInto; + use crate::convert::TryInto; use libc::pread64; // pread64 on emscripten actually takes a 32 bit offset if let Ok(o) = offset.try_into() { @@ -131,7 +132,7 @@ impl FileDesc { unsafe fn cvt_pwrite64(fd: c_int, buf: *const c_void, count: usize, offset: i64) -> io::Result { - use convert::TryInto; + use crate::convert::TryInto; use libc::pwrite64; // pwrite64 on emscripten actually takes a 32 bit offset if let Ok(o) = offset.try_into() { diff --git a/src/libstd/sys/unix/fs.rs b/src/libstd/sys/unix/fs.rs index 5183d6fadd218..3b80b475a93db 100644 --- a/src/libstd/sys/unix/fs.rs +++ b/src/libstd/sys/unix/fs.rs @@ -1,17 +1,18 @@ -use os::unix::prelude::*; - -use ffi::{CString, CStr, OsString, OsStr}; -use fmt; -use io::{self, Error, ErrorKind, SeekFrom}; -use libc::{self, c_int, mode_t}; -use mem; -use path::{Path, PathBuf}; -use ptr; -use sync::Arc; -use sys::fd::FileDesc; -use sys::time::SystemTime; -use sys::{cvt, cvt_r}; -use sys_common::{AsInner, FromInner}; +use crate::os::unix::prelude::*; + +use crate::ffi::{CString, CStr, OsString, OsStr}; +use crate::fmt; +use crate::io::{self, Error, ErrorKind, SeekFrom}; +use crate::mem; +use crate::path::{Path, PathBuf}; +use crate::ptr; +use crate::sync::Arc; +use crate::sys::fd::FileDesc; +use crate::sys::time::SystemTime; +use crate::sys::{cvt, cvt_r}; +use crate::sys_common::{AsInner, FromInner}; + +use libc::{c_int, mode_t}; #[cfg(any(target_os = "linux", target_os = "emscripten", target_os = "l4re"))] use libc::{stat64, fstat64, lstat64, off64_t, ftruncate64, lseek64, dirent64, readdir64_r, open64}; @@ -217,6 +218,8 @@ impl Iterator for ReadDir { #[cfg(any(target_os = "solaris", target_os = "fuchsia"))] fn next(&mut self) -> Option> { + use crate::slice; + unsafe { loop { // Although readdir_r(3) would be a correct function to use here because @@ -239,8 +242,8 @@ impl Iterator for ReadDir { let ret = DirEntry { entry: *entry_ptr, - name: ::slice::from_raw_parts(name as *const u8, - namelen as usize).to_owned().into_boxed_slice(), + name: slice::from_raw_parts(name as *const u8, + namelen as usize).to_owned().into_boxed_slice(), dir: self.clone() }; if ret.name_bytes() != b"." && ret.name_bytes() != b".." { @@ -365,9 +368,10 @@ impl DirEntry { target_os = "dragonfly", target_os = "bitrig"))] fn name_bytes(&self) -> &[u8] { + use crate::slice; unsafe { - ::slice::from_raw_parts(self.entry.d_name.as_ptr() as *const u8, - self.entry.d_namlen as usize) + slice::from_raw_parts(self.entry.d_name.as_ptr() as *const u8, + self.entry.d_namlen as usize) } } #[cfg(any(target_os = "android", @@ -475,7 +479,7 @@ impl File { // that we support, so we only do this on Linux currently. #[cfg(target_os = "linux")] fn ensure_cloexec(fd: &FileDesc) -> io::Result<()> { - use sync::atomic::{AtomicUsize, Ordering}; + use crate::sync::atomic::{AtomicUsize, Ordering}; const OPEN_CLOEXEC_UNKNOWN: usize = 0; const OPEN_CLOEXEC_SUPPORTED: usize = 1; @@ -542,7 +546,7 @@ impl File { pub fn truncate(&self, size: u64) -> io::Result<()> { #[cfg(target_os = "android")] - return ::sys::android::ftruncate64(self.0.raw(), size); + return crate::sys::android::ftruncate64(self.0.raw(), size); #[cfg(not(target_os = "android"))] return cvt_r(|| unsafe { @@ -825,7 +829,7 @@ pub fn canonicalize(p: &Path) -> io::Result { #[cfg(not(any(target_os = "linux", target_os = "android")))] pub fn copy(from: &Path, to: &Path) -> io::Result { - use fs::File; + use crate::fs::File; if !from.is_file() { return Err(Error::new(ErrorKind::InvalidInput, "the source path is not an existing regular file")) @@ -842,9 +846,9 @@ pub fn copy(from: &Path, to: &Path) -> io::Result { #[cfg(any(target_os = "linux", target_os = "android"))] pub fn copy(from: &Path, to: &Path) -> io::Result { - use cmp; - use fs::File; - use sync::atomic::{AtomicBool, Ordering}; + use crate::cmp; + use crate::fs::File; + use crate::sync::atomic::{AtomicBool, Ordering}; // Kernel prior to 4.5 don't have copy_file_range // We store the availability in a global to avoid unnecessary syscalls diff --git a/src/libstd/sys/unix/io.rs b/src/libstd/sys/unix/io.rs index 65e4c6e057750..eb3fa470a6525 100644 --- a/src/libstd/sys/unix/io.rs +++ b/src/libstd/sys/unix/io.rs @@ -1,6 +1,7 @@ -use marker::PhantomData; +use crate::marker::PhantomData; +use crate::slice; + use libc::{iovec, c_void}; -use slice; #[repr(transparent)] pub struct IoVec<'a> { diff --git a/src/libstd/sys/unix/l4re.rs b/src/libstd/sys/unix/l4re.rs index 4775e29fb5709..b6e8cc738946b 100644 --- a/src/libstd/sys/unix/l4re.rs +++ b/src/libstd/sys/unix/l4re.rs @@ -4,15 +4,15 @@ macro_rules! unimpl { pub mod net { #![allow(warnings)] - use fmt; - use io::{self, IoVec, IoVecMut}; - use libc; - use net::{SocketAddr, Shutdown, Ipv4Addr, Ipv6Addr}; - use sys_common::{AsInner, FromInner, IntoInner}; - use sys::fd::FileDesc; - use time::Duration; - use convert::TryFrom; - + use crate::fmt; + use crate::io::{self, IoVec, IoVecMut}; + use crate::net::{SocketAddr, Shutdown, Ipv4Addr, Ipv6Addr}; + use crate::sys_common::{AsInner, FromInner, IntoInner}; + use crate::sys::fd::FileDesc; + use crate::time::Duration; + use crate::convert::TryFrom; + + #[allow(unused_extern_crates)] pub extern crate libc as netc; pub struct Socket(FileDesc); diff --git a/src/libstd/sys/unix/memchr.rs b/src/libstd/sys/unix/memchr.rs index ec04a22a0d2e8..1984678bdde4e 100644 --- a/src/libstd/sys/unix/memchr.rs +++ b/src/libstd/sys/unix/memchr.rs @@ -2,8 +2,6 @@ // Copyright 2015 Andrew Gallant, bluss and Nicolas Koch pub fn memchr(needle: u8, haystack: &[u8]) -> Option { - use libc; - let p = unsafe { libc::memchr( haystack.as_ptr() as *const libc::c_void, @@ -21,8 +19,6 @@ pub fn memrchr(needle: u8, haystack: &[u8]) -> Option { #[cfg(target_os = "linux")] fn memrchr_specific(needle: u8, haystack: &[u8]) -> Option { - use libc; - // GNU's memrchr() will - unlike memchr() - error if haystack is empty. if haystack.is_empty() {return None} let p = unsafe { @@ -40,7 +36,7 @@ pub fn memrchr(needle: u8, haystack: &[u8]) -> Option { #[cfg(not(target_os = "linux"))] fn memrchr_specific(needle: u8, haystack: &[u8]) -> Option { - ::core::slice::memchr::memrchr(needle, haystack) + core::slice::memchr::memrchr(needle, haystack) } memrchr_specific(needle, haystack) diff --git a/src/libstd/sys/unix/mod.rs b/src/libstd/sys/unix/mod.rs index 0de1a223fbd12..fbe3444311e5f 100644 --- a/src/libstd/sys/unix/mod.rs +++ b/src/libstd/sys/unix/mod.rs @@ -1,24 +1,23 @@ #![allow(missing_docs, nonstandard_style)] -use io::ErrorKind; -use libc; - -#[cfg(any(rustdoc, target_os = "linux"))] pub use os::linux as platform; - -#[cfg(all(not(rustdoc), target_os = "android"))] pub use os::android as platform; -#[cfg(all(not(rustdoc), target_os = "bitrig"))] pub use os::bitrig as platform; -#[cfg(all(not(rustdoc), target_os = "dragonfly"))] pub use os::dragonfly as platform; -#[cfg(all(not(rustdoc), target_os = "freebsd"))] pub use os::freebsd as platform; -#[cfg(all(not(rustdoc), target_os = "haiku"))] pub use os::haiku as platform; -#[cfg(all(not(rustdoc), target_os = "ios"))] pub use os::ios as platform; -#[cfg(all(not(rustdoc), target_os = "macos"))] pub use os::macos as platform; -#[cfg(all(not(rustdoc), target_os = "netbsd"))] pub use os::netbsd as platform; -#[cfg(all(not(rustdoc), target_os = "openbsd"))] pub use os::openbsd as platform; -#[cfg(all(not(rustdoc), target_os = "solaris"))] pub use os::solaris as platform; -#[cfg(all(not(rustdoc), target_os = "emscripten"))] pub use os::emscripten as platform; -#[cfg(all(not(rustdoc), target_os = "fuchsia"))] pub use os::fuchsia as platform; -#[cfg(all(not(rustdoc), target_os = "l4re"))] pub use os::linux as platform; -#[cfg(all(not(rustdoc), target_os = "hermit"))] pub use os::hermit as platform; +use crate::io::ErrorKind; + +#[cfg(any(rustdoc, target_os = "linux"))] pub use crate::os::linux as platform; + +#[cfg(all(not(rustdoc), target_os = "android"))] pub use crate::os::android as platform; +#[cfg(all(not(rustdoc), target_os = "bitrig"))] pub use crate::os::bitrig as platform; +#[cfg(all(not(rustdoc), target_os = "dragonfly"))] pub use crate::os::dragonfly as platform; +#[cfg(all(not(rustdoc), target_os = "freebsd"))] pub use crate::os::freebsd as platform; +#[cfg(all(not(rustdoc), target_os = "haiku"))] pub use crate::os::haiku as platform; +#[cfg(all(not(rustdoc), target_os = "ios"))] pub use crate::os::ios as platform; +#[cfg(all(not(rustdoc), target_os = "macos"))] pub use crate::os::macos as platform; +#[cfg(all(not(rustdoc), target_os = "netbsd"))] pub use crate::os::netbsd as platform; +#[cfg(all(not(rustdoc), target_os = "openbsd"))] pub use crate::os::openbsd as platform; +#[cfg(all(not(rustdoc), target_os = "solaris"))] pub use crate::os::solaris as platform; +#[cfg(all(not(rustdoc), target_os = "emscripten"))] pub use crate::os::emscripten as platform; +#[cfg(all(not(rustdoc), target_os = "fuchsia"))] pub use crate::os::fuchsia as platform; +#[cfg(all(not(rustdoc), target_os = "l4re"))] pub use crate::os::linux as platform; +#[cfg(all(not(rustdoc), target_os = "hermit"))] pub use crate::os::hermit as platform; pub use self::rand::hashmap_random_keys; pub use libc::strlen; @@ -82,7 +81,7 @@ pub fn init() { } #[cfg(target_os = "android")] -pub use sys::android::signal; +pub use crate::sys::android::signal; #[cfg(not(target_os = "android"))] pub use libc::signal; @@ -127,15 +126,15 @@ macro_rules! impl_is_minus_one { impl_is_minus_one! { i8 i16 i32 i64 isize } -pub fn cvt(t: T) -> ::io::Result { +pub fn cvt(t: T) -> crate::io::Result { if t.is_minus_one() { - Err(::io::Error::last_os_error()) + Err(crate::io::Error::last_os_error()) } else { Ok(t) } } -pub fn cvt_r(mut f: F) -> ::io::Result +pub fn cvt_r(mut f: F) -> crate::io::Result where T: IsMinusOne, F: FnMut() -> T { @@ -155,5 +154,5 @@ pub fn cvt_r(mut f: F) -> ::io::Result // instruction" that intrinsics::abort would cause, as intrinsics::abort is // implemented as an illegal instruction. pub unsafe fn abort_internal() -> ! { - ::libc::abort() + libc::abort() } diff --git a/src/libstd/sys/unix/mutex.rs b/src/libstd/sys/unix/mutex.rs index 54429dc84b6b3..b6a22e1962ab8 100644 --- a/src/libstd/sys/unix/mutex.rs +++ b/src/libstd/sys/unix/mutex.rs @@ -1,6 +1,5 @@ -use cell::UnsafeCell; -use libc; -use mem; +use crate::cell::UnsafeCell; +use crate::mem; pub struct Mutex { inner: UnsafeCell } @@ -74,7 +73,6 @@ impl Mutex { #[inline] #[cfg(target_os = "dragonfly")] pub unsafe fn destroy(&self) { - use libc; let r = libc::pthread_mutex_destroy(self.inner.get()); // On DragonFly pthread_mutex_destroy() returns EINVAL if called on a // mutex that was just initialized with libc::PTHREAD_MUTEX_INITIALIZER. diff --git a/src/libstd/sys/unix/net.rs b/src/libstd/sys/unix/net.rs index 521d9b425179b..7712a41ded46f 100644 --- a/src/libstd/sys/unix/net.rs +++ b/src/libstd/sys/unix/net.rs @@ -1,16 +1,19 @@ -use ffi::CStr; -use io::{self, IoVec, IoVecMut}; -use libc::{self, c_int, c_void, size_t, sockaddr, socklen_t, EAI_SYSTEM, MSG_PEEK}; -use mem; -use net::{SocketAddr, Shutdown}; -use str; -use sys::fd::FileDesc; -use sys_common::{AsInner, FromInner, IntoInner}; -use sys_common::net::{getsockopt, setsockopt, sockaddr_to_addr}; -use time::{Duration, Instant}; -use cmp; - -pub use sys::{cvt, cvt_r}; +use crate::ffi::CStr; +use crate::io::{self, IoVec, IoVecMut}; +use crate::mem; +use crate::net::{SocketAddr, Shutdown}; +use crate::str; +use crate::sys::fd::FileDesc; +use crate::sys_common::{AsInner, FromInner, IntoInner}; +use crate::sys_common::net::{getsockopt, setsockopt, sockaddr_to_addr}; +use crate::time::{Duration, Instant}; +use crate::cmp; + +use libc::{c_int, c_void, size_t, sockaddr, socklen_t, EAI_SYSTEM, MSG_PEEK}; + +pub use crate::sys::{cvt, cvt_r}; + +#[allow(unused_extern_crates)] pub extern crate libc as netc; pub type wrlen_t = size_t; @@ -384,7 +387,7 @@ impl IntoInner for Socket { // believe it's thread-safe). #[cfg(target_env = "gnu")] fn on_resolver_failure() { - use sys; + use crate::sys; // If the version fails to parse, we treat it the same as "not glibc". if let Some(version) = sys::os::glibc_version() { diff --git a/src/libstd/sys/unix/os.rs b/src/libstd/sys/unix/os.rs index 58ea190fcc004..e16d50d437b22 100644 --- a/src/libstd/sys/unix/os.rs +++ b/src/libstd/sys/unix/os.rs @@ -2,25 +2,26 @@ #![allow(unused_imports)] // lots of cfg code here -use os::unix::prelude::*; - -use error::Error as StdError; -use ffi::{CString, CStr, OsString, OsStr}; -use fmt; -use io; -use iter; -use libc::{self, c_int, c_char, c_void}; -use marker::PhantomData; -use mem; -use memchr; -use path::{self, PathBuf}; -use ptr; -use slice; -use str; -use sys_common::mutex::{Mutex, MutexGuard}; -use sys::cvt; -use sys::fd; -use vec; +use crate::os::unix::prelude::*; + +use crate::error::Error as StdError; +use crate::ffi::{CString, CStr, OsString, OsStr}; +use crate::fmt; +use crate::io; +use crate::iter; +use crate::marker::PhantomData; +use crate::mem; +use crate::memchr; +use crate::path::{self, PathBuf}; +use crate::ptr; +use crate::slice; +use crate::str; +use crate::sys_common::mutex::{Mutex, MutexGuard}; +use crate::sys::cvt; +use crate::sys::fd; +use crate::vec; + +use libc::{c_int, c_char, c_void}; const TMPBUF_SZ: usize = 128; @@ -207,13 +208,13 @@ pub fn current_exe() -> io::Result { libc::KERN_PROC_PATHNAME as c_int, -1 as c_int]; let mut sz = 0; - cvt(libc::sysctl(mib.as_mut_ptr(), mib.len() as ::libc::c_uint, + cvt(libc::sysctl(mib.as_mut_ptr(), mib.len() as libc::c_uint, ptr::null_mut(), &mut sz, ptr::null_mut(), 0))?; if sz == 0 { return Err(io::Error::last_os_error()) } let mut v: Vec = Vec::with_capacity(sz); - cvt(libc::sysctl(mib.as_mut_ptr(), mib.len() as ::libc::c_uint, + cvt(libc::sysctl(mib.as_mut_ptr(), mib.len() as libc::c_uint, v.as_mut_ptr() as *mut libc::c_void, &mut sz, ptr::null_mut(), 0))?; if sz == 0 { @@ -230,7 +231,7 @@ pub fn current_exe() -> io::Result { unsafe { let mib = [libc::CTL_KERN, libc::KERN_PROC_ARGS, -1, libc::KERN_PROC_PATHNAME]; let mut path_len: usize = 0; - cvt(libc::sysctl(mib.as_ptr(), mib.len() as ::libc::c_uint, + cvt(libc::sysctl(mib.as_ptr(), mib.len() as libc::c_uint, ptr::null_mut(), &mut path_len, ptr::null(), 0))?; if path_len <= 1 { @@ -238,7 +239,7 @@ pub fn current_exe() -> io::Result { "KERN_PROC_PATHNAME sysctl returned zero-length string")) } let mut path: Vec = Vec::with_capacity(path_len); - cvt(libc::sysctl(mib.as_ptr(), mib.len() as ::libc::c_uint, + cvt(libc::sysctl(mib.as_ptr(), mib.len() as libc::c_uint, path.as_ptr() as *mut libc::c_void, &mut path_len, ptr::null(), 0))?; path.set_len(path_len - 1); // chop off NUL @@ -248,7 +249,7 @@ pub fn current_exe() -> io::Result { fn procfs() -> io::Result { let curproc_exe = path::Path::new("/proc/curproc/exe"); if curproc_exe.is_file() { - return ::fs::read_link(curproc_exe); + return crate::fs::read_link(curproc_exe); } Err(io::Error::new(io::ErrorKind::Other, "/proc/curproc/exe doesn't point to regular file.")) @@ -277,7 +278,7 @@ pub fn current_exe() -> io::Result { } let argv0 = CStr::from_ptr(argv[0]).to_bytes(); if argv0[0] == b'.' || argv0.iter().any(|b| *b == b'/') { - ::fs::canonicalize(OsStr::from_bytes(argv0)) + crate::fs::canonicalize(OsStr::from_bytes(argv0)) } else { Ok(PathBuf::from(OsStr::from_bytes(argv0))) } @@ -286,7 +287,7 @@ pub fn current_exe() -> io::Result { #[cfg(any(target_os = "linux", target_os = "android", target_os = "emscripten"))] pub fn current_exe() -> io::Result { - match ::fs::read_link("/proc/self/exe") { + match crate::fs::read_link("/proc/self/exe") { Err(ref e) if e.kind() == io::ErrorKind::NotFound => { Err(io::Error::new( io::ErrorKind::Other, @@ -373,7 +374,7 @@ pub fn current_exe() -> io::Result { let result = _get_next_image_info(0, &mut cookie, &mut info, mem::size_of::() as i32); if result != 0 { - use io::ErrorKind; + use crate::io::ErrorKind; Err(io::Error::new(ErrorKind::Other, "Error getting executable path")) } else { let name = CStr::from_ptr(info.name.as_ptr()).to_bytes(); @@ -384,7 +385,7 @@ pub fn current_exe() -> io::Result { #[cfg(any(target_os = "fuchsia", target_os = "l4re", target_os = "hermit"))] pub fn current_exe() -> io::Result { - use io::ErrorKind; + use crate::io::ErrorKind; Err(io::Error::new(ErrorKind::Other, "Not yet implemented!")) } @@ -495,7 +496,7 @@ pub fn page_size() -> usize { } pub fn temp_dir() -> PathBuf { - ::env::var_os("TMPDIR").map(PathBuf::from).unwrap_or_else(|| { + crate::env::var_os("TMPDIR").map(PathBuf::from).unwrap_or_else(|| { if cfg!(target_os = "android") { PathBuf::from("/data/local/tmp") } else { @@ -505,7 +506,7 @@ pub fn temp_dir() -> PathBuf { } pub fn home_dir() -> Option { - return ::env::var_os("HOME").or_else(|| unsafe { + return crate::env::var_os("HOME").or_else(|| unsafe { fallback() }).map(PathBuf::from); diff --git a/src/libstd/sys/unix/os_str.rs b/src/libstd/sys/unix/os_str.rs index 9d5e084feb2d6..79b43458d00f3 100644 --- a/src/libstd/sys/unix/os_str.rs +++ b/src/libstd/sys/unix/os_str.rs @@ -1,14 +1,15 @@ /// The underlying OsString/OsStr implementation on Unix systems: just /// a `Vec`/`[u8]`. -use borrow::Cow; -use fmt; -use str; -use mem; -use rc::Rc; -use sync::Arc; -use sys_common::{AsInner, IntoInner}; -use sys_common::bytestring::debug_fmt_bytestring; +use crate::borrow::Cow; +use crate::fmt; +use crate::str; +use crate::mem; +use crate::rc::Rc; +use crate::sync::Arc; +use crate::sys_common::{AsInner, IntoInner}; +use crate::sys_common::bytestring::debug_fmt_bytestring; + use core::str::lossy::Utf8Lossy; #[derive(Clone, Hash)] diff --git a/src/libstd/sys/unix/path.rs b/src/libstd/sys/unix/path.rs index 2ef78fb2f86dc..5c062e7c97cd3 100644 --- a/src/libstd/sys/unix/path.rs +++ b/src/libstd/sys/unix/path.rs @@ -1,5 +1,5 @@ -use path::Prefix; -use ffi::OsStr; +use crate::path::Prefix; +use crate::ffi::OsStr; #[inline] pub fn is_sep_byte(b: u8) -> bool { diff --git a/src/libstd/sys/unix/pipe.rs b/src/libstd/sys/unix/pipe.rs index a746d982c6ca9..bc3c026adab8f 100644 --- a/src/libstd/sys/unix/pipe.rs +++ b/src/libstd/sys/unix/pipe.rs @@ -1,9 +1,10 @@ -use io; -use libc::{self, c_int}; -use mem; -use sync::atomic::{AtomicBool, Ordering}; -use sys::fd::FileDesc; -use sys::{cvt, cvt_r}; +use crate::io; +use crate::mem; +use crate::sync::atomic::{AtomicBool, Ordering}; +use crate::sys::fd::FileDesc; +use crate::sys::{cvt, cvt_r}; + +use libc::c_int; //////////////////////////////////////////////////////////////////////////////// // Anonymous pipes diff --git a/src/libstd/sys/unix/process/process_common.rs b/src/libstd/sys/unix/process/process_common.rs index 7fa256e59b2db..856d202be03f3 100644 --- a/src/libstd/sys/unix/process/process_common.rs +++ b/src/libstd/sys/unix/process/process_common.rs @@ -1,15 +1,16 @@ -use os::unix::prelude::*; - -use ffi::{OsString, OsStr, CString, CStr}; -use fmt; -use io; -use libc::{self, c_int, gid_t, uid_t, c_char, EXIT_SUCCESS, EXIT_FAILURE}; -use ptr; -use sys::fd::FileDesc; -use sys::fs::{File, OpenOptions}; -use sys::pipe::{self, AnonPipe}; -use sys_common::process::{CommandEnv, DefaultEnvKey}; -use collections::BTreeMap; +use crate::os::unix::prelude::*; + +use crate::ffi::{OsString, OsStr, CString, CStr}; +use crate::fmt; +use crate::io; +use crate::ptr; +use crate::sys::fd::FileDesc; +use crate::sys::fs::{File, OpenOptions}; +use crate::sys::pipe::{self, AnonPipe}; +use crate::sys_common::process::{CommandEnv, DefaultEnvKey}; +use crate::collections::BTreeMap; + +use libc::{c_int, gid_t, uid_t, c_char, EXIT_SUCCESS, EXIT_FAILURE}; //////////////////////////////////////////////////////////////////////////////// // Command @@ -406,11 +407,10 @@ impl ExitCode { mod tests { use super::*; - use ffi::OsStr; - use mem; - use ptr; - use libc; - use sys::cvt; + use crate::ffi::OsStr; + use crate::mem; + use crate::ptr; + use crate::sys::cvt; macro_rules! t { ($e:expr) => { @@ -443,7 +443,7 @@ mod tests { #[cfg(target_os = "android")] unsafe fn sigaddset(set: *mut libc::sigset_t, signum: libc::c_int) -> libc::c_int { - use slice; + use crate::slice; let raw = slice::from_raw_parts_mut(set as *mut u8, mem::size_of::()); let bit = (signum - 1) as usize; diff --git a/src/libstd/sys/unix/process/process_fuchsia.rs b/src/libstd/sys/unix/process/process_fuchsia.rs index 5582310adbf74..7c6be9b0a6047 100644 --- a/src/libstd/sys/unix/process/process_fuchsia.rs +++ b/src/libstd/sys/unix/process/process_fuchsia.rs @@ -1,10 +1,11 @@ -use io; -use libc::{self, size_t}; -use mem; -use ptr; +use crate::io; +use crate::mem; +use crate::ptr; -use sys::process::zircon::{Handle, zx_handle_t}; -use sys::process::process_common::*; +use crate::sys::process::zircon::{Handle, zx_handle_t}; +use crate::sys::process::process_common::*; + +use libc::size_t; //////////////////////////////////////////////////////////////////////////////// // Command @@ -44,7 +45,7 @@ impl Command { unsafe fn do_exec(&mut self, stdio: ChildPipes, maybe_envp: Option<&CStringArray>) -> io::Result { - use sys::process::zircon::*; + use crate::sys::process::zircon::*; let envp = match maybe_envp { Some(envp) => envp.as_ptr(), @@ -109,7 +110,7 @@ impl Process { } pub fn kill(&mut self) -> io::Result<()> { - use sys::process::zircon::*; + use crate::sys::process::zircon::*; unsafe { zx_cvt(zx_task_kill(self.handle.raw()))?; } @@ -117,8 +118,8 @@ impl Process { } pub fn wait(&mut self) -> io::Result { - use default::Default; - use sys::process::zircon::*; + use crate::default::Default; + use crate::sys::process::zircon::*; let mut proc_info: zx_info_process_t = Default::default(); let mut actual: size_t = 0; @@ -140,8 +141,8 @@ impl Process { } pub fn try_wait(&mut self) -> io::Result> { - use default::Default; - use sys::process::zircon::*; + use crate::default::Default; + use crate::sys::process::zircon::*; let mut proc_info: zx_info_process_t = Default::default(); let mut actual: size_t = 0; diff --git a/src/libstd/sys/unix/process/process_unix.rs b/src/libstd/sys/unix/process/process_unix.rs index 6fbbbb349b171..220b1fd453131 100644 --- a/src/libstd/sys/unix/process/process_unix.rs +++ b/src/libstd/sys/unix/process/process_unix.rs @@ -1,9 +1,10 @@ -use io::{self, Error, ErrorKind}; -use libc::{self, c_int, gid_t, pid_t, uid_t}; -use ptr; -use sys::cvt; -use sys::process::process_common::*; -use sys; +use crate::io::{self, Error, ErrorKind}; +use crate::ptr; +use crate::sys::cvt; +use crate::sys::process::process_common::*; +use crate::sys; + +use libc::{c_int, gid_t, pid_t, uid_t}; //////////////////////////////////////////////////////////////////////////////// // Command @@ -164,7 +165,7 @@ impl Command { stdio: ChildPipes, maybe_envp: Option<&CStringArray> ) -> io::Error { - use sys::{self, cvt_r}; + use crate::sys::{self, cvt_r}; macro_rules! t { ($e:expr) => (match $e { @@ -207,7 +208,7 @@ impl Command { // emscripten has no signal support. #[cfg(not(any(target_os = "emscripten")))] { - use mem; + use crate::mem; // Reset signal handling so the child process starts in a // standardized state. libstd ignores SIGPIPE, and signal-handling // libraries often set a mask. Child processes inherit ignored @@ -278,8 +279,8 @@ impl Command { fn posix_spawn(&mut self, stdio: &ChildPipes, envp: Option<&CStringArray>) -> io::Result> { - use mem; - use sys; + use crate::mem; + use crate::sys; if self.get_gid().is_some() || self.get_uid().is_some() || @@ -427,7 +428,7 @@ impl Process { } pub fn wait(&mut self) -> io::Result { - use sys::cvt_r; + use crate::sys::cvt_r; if let Some(status) = self.status { return Ok(status) } diff --git a/src/libstd/sys/unix/process/zircon.rs b/src/libstd/sys/unix/process/zircon.rs index 690c745218b64..ec715d5490f6f 100644 --- a/src/libstd/sys/unix/process/zircon.rs +++ b/src/libstd/sys/unix/process/zircon.rs @@ -1,9 +1,9 @@ #![allow(non_camel_case_types, unused)] -use convert::TryInto; -use io; -use os::raw::c_char; -use u64; +use crate::convert::TryInto; +use crate::io; +use crate::os::raw::c_char; +use crate::u64; use libc::{c_int, c_void, size_t}; diff --git a/src/libstd/sys/unix/rand.rs b/src/libstd/sys/unix/rand.rs index f2e17c36738fc..122f22b37a26b 100644 --- a/src/libstd/sys/unix/rand.rs +++ b/src/libstd/sys/unix/rand.rs @@ -1,5 +1,5 @@ -use mem; -use slice; +use crate::mem; +use crate::slice; pub fn hashmap_random_keys() -> (u64, u64) { let mut v = (0, 0); @@ -17,10 +17,8 @@ pub fn hashmap_random_keys() -> (u64, u64) { not(target_os = "freebsd"), not(target_os = "fuchsia")))] mod imp { - use fs::File; - use io::Read; - #[cfg(any(target_os = "linux", target_os = "android"))] - use libc; + use crate::fs::File; + use crate::io::Read; #[cfg(any(target_os = "linux", target_os = "android"))] fn getrandom(buf: &mut [u8]) -> libc::c_long { @@ -34,8 +32,8 @@ mod imp { #[cfg(any(target_os = "linux", target_os = "android"))] fn getrandom_fill_bytes(v: &mut [u8]) -> bool { - use sync::atomic::{AtomicBool, Ordering}; - use sys::os::errno; + use crate::sync::atomic::{AtomicBool, Ordering}; + use crate::sys::os::errno; static GETRANDOM_UNAVAILABLE: AtomicBool = AtomicBool::new(false); if GETRANDOM_UNAVAILABLE.load(Ordering::Relaxed) { @@ -86,8 +84,7 @@ mod imp { #[cfg(target_os = "openbsd")] mod imp { - use libc; - use sys::os::errno; + use crate::sys::os::errno; pub fn fill_bytes(v: &mut [u8]) { // getentropy(2) permits a maximum buffer size of 256 bytes @@ -104,9 +101,9 @@ mod imp { #[cfg(target_os = "ios")] mod imp { - use io; + use crate::io; + use crate::ptr; use libc::{c_int, size_t}; - use ptr; enum SecRandom {} @@ -134,8 +131,7 @@ mod imp { #[cfg(target_os = "freebsd")] mod imp { - use libc; - use ptr; + use crate::ptr; pub fn fill_bytes(v: &mut [u8]) { let mib = [libc::CTL_KERN, libc::KERN_ARND]; diff --git a/src/libstd/sys/unix/rwlock.rs b/src/libstd/sys/unix/rwlock.rs index a068a11993e36..e48bfdae61047 100644 --- a/src/libstd/sys/unix/rwlock.rs +++ b/src/libstd/sys/unix/rwlock.rs @@ -1,6 +1,5 @@ -use libc; -use cell::UnsafeCell; -use sync::atomic::{AtomicUsize, Ordering}; +use crate::cell::UnsafeCell; +use crate::sync::atomic::{AtomicUsize, Ordering}; pub struct RWLock { inner: UnsafeCell, diff --git a/src/libstd/sys/unix/stack_overflow.rs b/src/libstd/sys/unix/stack_overflow.rs index d6a219a6d5759..8c60bddc23839 100644 --- a/src/libstd/sys/unix/stack_overflow.rs +++ b/src/libstd/sys/unix/stack_overflow.rs @@ -1,6 +1,5 @@ #![cfg_attr(test, allow(dead_code))] -use libc; use self::imp::{make_handler, drop_handler}; pub use self::imp::cleanup; @@ -34,17 +33,17 @@ impl Drop for Handler { target_os = "openbsd"))] mod imp { use super::Handler; - use mem; - use ptr; + use crate::mem; + use crate::ptr; + use libc::{sigaltstack, SIGSTKSZ, SS_DISABLE}; use libc::{sigaction, SIGBUS, SIG_DFL, SA_SIGINFO, SA_ONSTACK, sighandler_t}; - use libc; use libc::{mmap, munmap}; use libc::{SIGSEGV, PROT_READ, PROT_WRITE, MAP_PRIVATE, MAP_ANON}; use libc::MAP_FAILED; - use sys_common::thread_info; + use crate::sys_common::thread_info; #[cfg(any(target_os = "linux", target_os = "android"))] @@ -87,7 +86,7 @@ mod imp { unsafe extern fn signal_handler(signum: libc::c_int, info: *mut libc::siginfo_t, _data: *mut libc::c_void) { - use sys_common::util::report_overflow; + use crate::sys_common::util::report_overflow; let guard = thread_info::stack_guard().unwrap_or(0..0); let addr = siginfo_si_addr(info); @@ -193,7 +192,7 @@ mod imp { all(target_os = "netbsd", not(target_vendor = "rumprun")), target_os = "openbsd")))] mod imp { - use ptr; + use crate::ptr; pub unsafe fn init() { } diff --git a/src/libstd/sys/unix/stdio.rs b/src/libstd/sys/unix/stdio.rs index 56b75bf9f7931..35f163bbdb10f 100644 --- a/src/libstd/sys/unix/stdio.rs +++ b/src/libstd/sys/unix/stdio.rs @@ -1,6 +1,5 @@ -use io; -use libc; -use sys::fd::FileDesc; +use crate::io; +use crate::sys::fd::FileDesc; pub struct Stdin(()); pub struct Stdout(()); @@ -57,7 +56,7 @@ pub fn is_ebadf(err: &io::Error) -> bool { err.raw_os_error() == Some(libc::EBADF as i32) } -pub const STDIN_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE; +pub const STDIN_BUF_SIZE: usize = crate::sys_common::io::DEFAULT_BUF_SIZE; pub fn panic_output() -> Option { Stderr::new().ok() diff --git a/src/libstd/sys/unix/thread.rs b/src/libstd/sys/unix/thread.rs index e29557f1ba29b..feb15e8f585ab 100644 --- a/src/libstd/sys/unix/thread.rs +++ b/src/libstd/sys/unix/thread.rs @@ -1,14 +1,13 @@ -use boxed::FnBox; -use cmp; -use ffi::CStr; -use io; -use libc; -use mem; -use ptr; -use sys::os; -use time::Duration; - -use sys_common::thread::*; +use crate::boxed::FnBox; +use crate::cmp; +use crate::ffi::CStr; +use crate::io; +use crate::mem; +use crate::ptr; +use crate::sys::os; +use crate::time::Duration; + +use crate::sys_common::thread::*; #[cfg(not(target_os = "l4re"))] pub const DEFAULT_MIN_STACK_SIZE: usize = 2 * 1024 * 1024; @@ -118,7 +117,7 @@ impl Thread { #[cfg(target_os = "netbsd")] pub fn set_name(name: &CStr) { - use ffi::CString; + use crate::ffi::CString; let cname = CString::new(&b"%s"[..]).unwrap(); unsafe { libc::pthread_setname_np(libc::pthread_self(), cname.as_ptr(), @@ -197,7 +196,7 @@ impl Drop for Thread { not(target_os = "solaris")))] #[cfg_attr(test, allow(dead_code))] pub mod guard { - use ops::Range; + use crate::ops::Range; pub type Guard = Range; pub unsafe fn current() -> Option { None } pub unsafe fn init() -> Option { None } @@ -213,11 +212,11 @@ pub mod guard { target_os = "solaris"))] #[cfg_attr(test, allow(dead_code))] pub mod guard { - use libc; use libc::{mmap, mprotect}; use libc::{PROT_NONE, PROT_READ, PROT_WRITE, MAP_PRIVATE, MAP_ANON, MAP_FAILED, MAP_FIXED}; - use ops::Range; - use sys::os; + + use crate::ops::Range; + use crate::sys::os; // This is initialized in init() and only read from after static mut PAGE_SIZE: usize = 0; @@ -226,7 +225,7 @@ pub mod guard { #[cfg(target_os = "solaris")] unsafe fn get_stack_start() -> Option<*mut libc::c_void> { - let mut current_stack: libc::stack_t = ::mem::zeroed(); + let mut current_stack: libc::stack_t = crate::mem::zeroed(); assert_eq!(libc::stack_getbounds(&mut current_stack), 0); Some(current_stack.ss_sp) } @@ -240,7 +239,7 @@ pub mod guard { #[cfg(any(target_os = "openbsd", target_os = "bitrig"))] unsafe fn get_stack_start() -> Option<*mut libc::c_void> { - let mut current_stack: libc::stack_t = ::mem::zeroed(); + let mut current_stack: libc::stack_t = crate::mem::zeroed(); assert_eq!(libc::pthread_stackseg_np(libc::pthread_self(), &mut current_stack), 0); @@ -259,14 +258,14 @@ pub mod guard { target_os = "linux", target_os = "netbsd", target_os = "l4re"))] unsafe fn get_stack_start() -> Option<*mut libc::c_void> { let mut ret = None; - let mut attr: libc::pthread_attr_t = ::mem::zeroed(); + let mut attr: libc::pthread_attr_t = crate::mem::zeroed(); assert_eq!(libc::pthread_attr_init(&mut attr), 0); #[cfg(target_os = "freebsd")] let e = libc::pthread_attr_get_np(libc::pthread_self(), &mut attr); #[cfg(not(target_os = "freebsd"))] let e = libc::pthread_getattr_np(libc::pthread_self(), &mut attr); if e == 0 { - let mut stackaddr = ::ptr::null_mut(); + let mut stackaddr = crate::ptr::null_mut(); let mut stacksize = 0; assert_eq!(libc::pthread_attr_getstack(&attr, &mut stackaddr, &mut stacksize), 0); @@ -357,7 +356,7 @@ pub mod guard { target_os = "linux", target_os = "netbsd", target_os = "l4re"))] pub unsafe fn current() -> Option { let mut ret = None; - let mut attr: libc::pthread_attr_t = ::mem::zeroed(); + let mut attr: libc::pthread_attr_t = crate::mem::zeroed(); assert_eq!(libc::pthread_attr_init(&mut attr), 0); #[cfg(target_os = "freebsd")] let e = libc::pthread_attr_get_np(libc::pthread_self(), &mut attr); @@ -369,7 +368,7 @@ pub mod guard { if guardsize == 0 { panic!("there is no guard page"); } - let mut stackaddr = ::ptr::null_mut(); + let mut stackaddr = crate::ptr::null_mut(); let mut size = 0; assert_eq!(libc::pthread_attr_getstack(&attr, &mut stackaddr, &mut size), 0); diff --git a/src/libstd/sys/unix/thread_local.rs b/src/libstd/sys/unix/thread_local.rs index c171fbce237ff..ac615b76b3624 100644 --- a/src/libstd/sys/unix/thread_local.rs +++ b/src/libstd/sys/unix/thread_local.rs @@ -1,7 +1,6 @@ #![allow(dead_code)] // not used on all platforms -use mem; -use libc; +use crate::mem; pub type Key = libc::pthread_key_t; diff --git a/src/libstd/sys/unix/time.rs b/src/libstd/sys/unix/time.rs index 4a655714f991c..cbb0615911adf 100644 --- a/src/libstd/sys/unix/time.rs +++ b/src/libstd/sys/unix/time.rs @@ -1,10 +1,10 @@ -use cmp::Ordering; -use libc; -use time::Duration; +use crate::cmp::Ordering; +use crate::time::Duration; + use core::hash::{Hash, Hasher}; pub use self::inner::{Instant, SystemTime, UNIX_EPOCH}; -use convert::TryInto; +use crate::convert::TryInto; const NSEC_PER_SEC: u64 = 1_000_000_000; @@ -113,12 +113,11 @@ impl Hash for Timespec { #[cfg(any(target_os = "macos", target_os = "ios"))] mod inner { - use fmt; - use libc; - use sync::Once; - use sys::cvt; - use sys_common::mul_div_u64; - use time::Duration; + use crate::fmt; + use crate::sync::Once; + use crate::sys::cvt; + use crate::sys_common::mul_div_u64; + use crate::time::Duration; use super::NSEC_PER_SEC; use super::Timespec; @@ -173,7 +172,7 @@ mod inner { impl SystemTime { pub fn now() -> SystemTime { - use ptr; + use crate::ptr; let mut s = libc::timeval { tv_sec: 0, @@ -249,10 +248,9 @@ mod inner { #[cfg(not(any(target_os = "macos", target_os = "ios")))] mod inner { - use fmt; - use libc; - use sys::cvt; - use time::Duration; + use crate::fmt; + use crate::sys::cvt; + use crate::time::Duration; use super::Timespec; diff --git a/src/libstd/sys/unix/weak.rs b/src/libstd/sys/unix/weak.rs index b60e241f10cee..9a7691e54bc1a 100644 --- a/src/libstd/sys/unix/weak.rs +++ b/src/libstd/sys/unix/weak.rs @@ -16,17 +16,15 @@ //! symbol, but that caused Debian to detect an unnecessarily strict versioned //! dependency on libc6 (#23628). -use libc; - -use ffi::CStr; -use marker; -use mem; -use sync::atomic::{AtomicUsize, Ordering}; +use crate::ffi::CStr; +use crate::marker; +use crate::mem; +use crate::sync::atomic::{AtomicUsize, Ordering}; macro_rules! weak { (fn $name:ident($($t:ty),*) -> $ret:ty) => ( - static $name: ::sys::weak::Weak $ret> = - ::sys::weak::Weak::new(concat!(stringify!($name), '\0')); + static $name: crate::sys::weak::Weak $ret> = + crate::sys::weak::Weak::new(concat!(stringify!($name), '\0')); ) } @@ -71,7 +69,6 @@ unsafe fn fetch(name: &str) -> usize { macro_rules! syscall { (fn $name:ident($($arg_name:ident: $t:ty),*) -> $ret:ty) => ( unsafe fn $name($($arg_name: $t),*) -> $ret { - use libc; use super::os; weak! { fn $name($($t),*) -> $ret } diff --git a/src/libstd/sys/wasm/alloc.rs b/src/libstd/sys/wasm/alloc.rs index f082887ce205a..b9098548b9c1e 100644 --- a/src/libstd/sys/wasm/alloc.rs +++ b/src/libstd/sys/wasm/alloc.rs @@ -16,9 +16,7 @@ //! The crate itself provides a global allocator which on wasm has no //! synchronization as there are no threads! -extern crate dlmalloc; - -use alloc::{GlobalAlloc, Layout, System}; +use crate::alloc::{GlobalAlloc, Layout, System}; static mut DLMALLOC: dlmalloc::Dlmalloc = dlmalloc::DLMALLOC_INIT; @@ -51,8 +49,8 @@ unsafe impl GlobalAlloc for System { #[cfg(target_feature = "atomics")] mod lock { - use arch::wasm32; - use sync::atomic::{AtomicI32, Ordering::SeqCst}; + use crate::arch::wasm32; + use crate::sync::atomic::{AtomicI32, Ordering::SeqCst}; static LOCKED: AtomicI32 = AtomicI32::new(0); diff --git a/src/libstd/sys/wasm/args.rs b/src/libstd/sys/wasm/args.rs index cea56091adcba..b3c77b8699563 100644 --- a/src/libstd/sys/wasm/args.rs +++ b/src/libstd/sys/wasm/args.rs @@ -1,7 +1,7 @@ -use ffi::OsString; -use marker::PhantomData; -use vec; -use sys::ArgsSysCall; +use crate::ffi::OsString; +use crate::marker::PhantomData; +use crate::vec; +use crate::sys::ArgsSysCall; pub unsafe fn init(_argc: isize, _argv: *const *const u8) { // On wasm these should always be null, so there's nothing for us to do here diff --git a/src/libstd/sys/wasm/backtrace.rs b/src/libstd/sys/wasm/backtrace.rs index 52d4a63bb6384..7d56b298997aa 100644 --- a/src/libstd/sys/wasm/backtrace.rs +++ b/src/libstd/sys/wasm/backtrace.rs @@ -1,6 +1,6 @@ -use io; -use sys::unsupported; -use sys_common::backtrace::Frame; +use crate::io; +use crate::sys::unsupported; +use crate::sys_common::backtrace::Frame; pub struct BacktraceContext; diff --git a/src/libstd/sys/wasm/condvar.rs b/src/libstd/sys/wasm/condvar.rs index 22df0f60db5a1..9c7cc3c63b15f 100644 --- a/src/libstd/sys/wasm/condvar.rs +++ b/src/libstd/sys/wasm/condvar.rs @@ -1,5 +1,5 @@ -use sys::mutex::Mutex; -use time::Duration; +use crate::sys::mutex::Mutex; +use crate::time::Duration; pub struct Condvar { } diff --git a/src/libstd/sys/wasm/condvar_atomics.rs b/src/libstd/sys/wasm/condvar_atomics.rs index 099404c75d42d..580d21218445f 100644 --- a/src/libstd/sys/wasm/condvar_atomics.rs +++ b/src/libstd/sys/wasm/condvar_atomics.rs @@ -1,9 +1,9 @@ -use arch::wasm32; -use cmp; -use mem; -use sync::atomic::{AtomicUsize, Ordering::SeqCst}; -use sys::mutex::Mutex; -use time::Duration; +use crate::arch::wasm32; +use crate::cmp; +use crate::mem; +use crate::sync::atomic::{AtomicUsize, Ordering::SeqCst}; +use crate::sys::mutex::Mutex; +use crate::time::Duration; pub struct Condvar { cnt: AtomicUsize, diff --git a/src/libstd/sys/wasm/fs.rs b/src/libstd/sys/wasm/fs.rs index 8b1c4476bc417..485d2c87fbd2d 100644 --- a/src/libstd/sys/wasm/fs.rs +++ b/src/libstd/sys/wasm/fs.rs @@ -1,10 +1,10 @@ -use ffi::OsString; -use fmt; -use hash::{Hash, Hasher}; -use io::{self, SeekFrom}; -use path::{Path, PathBuf}; -use sys::time::SystemTime; -use sys::{unsupported, Void}; +use crate::ffi::OsString; +use crate::fmt; +use crate::hash::{Hash, Hasher}; +use crate::io::{self, SeekFrom}; +use crate::path::{Path, PathBuf}; +use crate::sys::time::SystemTime; +use crate::sys::{unsupported, Void}; pub struct File(Void); diff --git a/src/libstd/sys/wasm/mod.rs b/src/libstd/sys/wasm/mod.rs index e71c6bcd7fe76..1828cce4e520e 100644 --- a/src/libstd/sys/wasm/mod.rs +++ b/src/libstd/sys/wasm/mod.rs @@ -14,12 +14,12 @@ //! compiling for wasm. That way it's a compile time error for something that's //! guaranteed to be a runtime error! -use os::raw::c_char; -use ptr; -use sys::os_str::Buf; -use sys_common::{AsInner, FromInner}; -use ffi::{OsString, OsStr}; -use time::Duration; +use crate::os::raw::c_char; +use crate::ptr; +use crate::sys::os_str::Buf; +use crate::sys_common::{AsInner, FromInner}; +use crate::ffi::{OsString, OsStr}; +use crate::time::Duration; pub mod alloc; pub mod args; @@ -63,17 +63,17 @@ cfg_if! { pub fn init() { } -pub fn unsupported() -> ::io::Result { +pub fn unsupported() -> crate::io::Result { Err(unsupported_err()) } -pub fn unsupported_err() -> ::io::Error { - ::io::Error::new(::io::ErrorKind::Other, +pub fn unsupported_err() -> crate::io::Error { + crate::io::Error::new(crate::io::ErrorKind::Other, "operation not supported on wasm yet") } -pub fn decode_error_kind(_code: i32) -> ::io::ErrorKind { - ::io::ErrorKind::Other +pub fn decode_error_kind(_code: i32) -> crate::io::ErrorKind { + crate::io::ErrorKind::Other } // This enum is used as the storage for a bunch of types which can't actually @@ -168,7 +168,7 @@ impl ExitSysCall { }; unsafe { syscall(SysCallIndex::Exit, &mut call_record); - ::intrinsics::abort(); + crate::intrinsics::abort(); } } } diff --git a/src/libstd/sys/wasm/mutex.rs b/src/libstd/sys/wasm/mutex.rs index cf0a0a8638b13..9d713e9b43903 100644 --- a/src/libstd/sys/wasm/mutex.rs +++ b/src/libstd/sys/wasm/mutex.rs @@ -1,4 +1,4 @@ -use cell::UnsafeCell; +use crate::cell::UnsafeCell; pub struct Mutex { locked: UnsafeCell, diff --git a/src/libstd/sys/wasm/mutex_atomics.rs b/src/libstd/sys/wasm/mutex_atomics.rs index da03e8fa23f18..0e4f3d80aa938 100644 --- a/src/libstd/sys/wasm/mutex_atomics.rs +++ b/src/libstd/sys/wasm/mutex_atomics.rs @@ -1,8 +1,8 @@ -use arch::wasm32; -use cell::UnsafeCell; -use mem; -use sync::atomic::{AtomicUsize, AtomicU32, Ordering::SeqCst}; -use sys::thread; +use crate::arch::wasm32; +use crate::cell::UnsafeCell; +use crate::mem; +use crate::sync::atomic::{AtomicUsize, AtomicU32, Ordering::SeqCst}; +use crate::sys::thread; pub struct Mutex { locked: AtomicUsize, diff --git a/src/libstd/sys/wasm/net.rs b/src/libstd/sys/wasm/net.rs index d9f5d53843205..1249832fb09d2 100644 --- a/src/libstd/sys/wasm/net.rs +++ b/src/libstd/sys/wasm/net.rs @@ -1,9 +1,9 @@ -use fmt; -use io::{self, IoVec, IoVecMut}; -use net::{SocketAddr, Shutdown, Ipv4Addr, Ipv6Addr}; -use time::Duration; -use sys::{unsupported, Void}; -use convert::TryFrom; +use crate::fmt; +use crate::io::{self, IoVec, IoVecMut}; +use crate::net::{SocketAddr, Shutdown, Ipv4Addr, Ipv6Addr}; +use crate::time::Duration; +use crate::sys::{unsupported, Void}; +use crate::convert::TryFrom; pub struct TcpStream(Void); diff --git a/src/libstd/sys/wasm/os.rs b/src/libstd/sys/wasm/os.rs index 9b278dfb9f8b2..145f9ccd73a8f 100644 --- a/src/libstd/sys/wasm/os.rs +++ b/src/libstd/sys/wasm/os.rs @@ -1,10 +1,10 @@ -use error::Error as StdError; -use ffi::{OsString, OsStr}; -use fmt; -use io; -use path::{self, PathBuf}; -use str; -use sys::{unsupported, Void, ExitSysCall, GetEnvSysCall, SetEnvSysCall}; +use crate::error::Error as StdError; +use crate::ffi::{OsString, OsStr}; +use crate::fmt; +use crate::io; +use crate::path::{self, PathBuf}; +use crate::str; +use crate::sys::{unsupported, Void, ExitSysCall, GetEnvSysCall, SetEnvSysCall}; pub fn errno() -> i32 { 0 diff --git a/src/libstd/sys/wasm/os_str.rs b/src/libstd/sys/wasm/os_str.rs index 9d5e084feb2d6..79b43458d00f3 100644 --- a/src/libstd/sys/wasm/os_str.rs +++ b/src/libstd/sys/wasm/os_str.rs @@ -1,14 +1,15 @@ /// The underlying OsString/OsStr implementation on Unix systems: just /// a `Vec`/`[u8]`. -use borrow::Cow; -use fmt; -use str; -use mem; -use rc::Rc; -use sync::Arc; -use sys_common::{AsInner, IntoInner}; -use sys_common::bytestring::debug_fmt_bytestring; +use crate::borrow::Cow; +use crate::fmt; +use crate::str; +use crate::mem; +use crate::rc::Rc; +use crate::sync::Arc; +use crate::sys_common::{AsInner, IntoInner}; +use crate::sys_common::bytestring::debug_fmt_bytestring; + use core::str::lossy::Utf8Lossy; #[derive(Clone, Hash)] diff --git a/src/libstd/sys/wasm/path.rs b/src/libstd/sys/wasm/path.rs index 2ef78fb2f86dc..5c062e7c97cd3 100644 --- a/src/libstd/sys/wasm/path.rs +++ b/src/libstd/sys/wasm/path.rs @@ -1,5 +1,5 @@ -use path::Prefix; -use ffi::OsStr; +use crate::path::Prefix; +use crate::ffi::OsStr; #[inline] pub fn is_sep_byte(b: u8) -> bool { diff --git a/src/libstd/sys/wasm/pipe.rs b/src/libstd/sys/wasm/pipe.rs index ac48a6dc03323..2582b993b608e 100644 --- a/src/libstd/sys/wasm/pipe.rs +++ b/src/libstd/sys/wasm/pipe.rs @@ -1,5 +1,5 @@ -use io; -use sys::Void; +use crate::io; +use crate::sys::Void; pub struct AnonPipe(Void); diff --git a/src/libstd/sys/wasm/process.rs b/src/libstd/sys/wasm/process.rs index 5357d931c7367..c49daaa16320e 100644 --- a/src/libstd/sys/wasm/process.rs +++ b/src/libstd/sys/wasm/process.rs @@ -1,10 +1,10 @@ -use ffi::OsStr; -use fmt; -use io; -use sys::fs::File; -use sys::pipe::AnonPipe; -use sys::{unsupported, Void}; -use sys_common::process::{CommandEnv, DefaultEnvKey}; +use crate::ffi::OsStr; +use crate::fmt; +use crate::io; +use crate::sys::fs::File; +use crate::sys::pipe::AnonPipe; +use crate::sys::{unsupported, Void}; +use crate::sys_common::process::{CommandEnv, DefaultEnvKey}; //////////////////////////////////////////////////////////////////////////////// // Command diff --git a/src/libstd/sys/wasm/rwlock.rs b/src/libstd/sys/wasm/rwlock.rs index 9f172859b7e65..a2b07c7fa1fc0 100644 --- a/src/libstd/sys/wasm/rwlock.rs +++ b/src/libstd/sys/wasm/rwlock.rs @@ -1,4 +1,4 @@ -use cell::UnsafeCell; +use crate::cell::UnsafeCell; pub struct RWLock { mode: UnsafeCell, diff --git a/src/libstd/sys/wasm/rwlock_atomics.rs b/src/libstd/sys/wasm/rwlock_atomics.rs index 404b33bca41b4..c705568cec992 100644 --- a/src/libstd/sys/wasm/rwlock_atomics.rs +++ b/src/libstd/sys/wasm/rwlock_atomics.rs @@ -1,6 +1,6 @@ -use cell::UnsafeCell; -use sys::mutex::Mutex; -use sys::condvar::Condvar; +use crate::cell::UnsafeCell; +use crate::sys::mutex::Mutex; +use crate::sys::condvar::Condvar; pub struct RWLock { lock: Mutex, diff --git a/src/libstd/sys/wasm/stdio.rs b/src/libstd/sys/wasm/stdio.rs index d7540fd815c98..b8899a9c84746 100644 --- a/src/libstd/sys/wasm/stdio.rs +++ b/src/libstd/sys/wasm/stdio.rs @@ -1,5 +1,5 @@ -use io; -use sys::{ReadSysCall, WriteSysCall}; +use crate::io; +use crate::sys::{ReadSysCall, WriteSysCall}; pub struct Stdin; pub struct Stdout; diff --git a/src/libstd/sys/wasm/thread.rs b/src/libstd/sys/wasm/thread.rs index c2322088e8e5a..a65c413119f8c 100644 --- a/src/libstd/sys/wasm/thread.rs +++ b/src/libstd/sys/wasm/thread.rs @@ -1,8 +1,8 @@ -use boxed::FnBox; -use ffi::CStr; -use io; -use sys::{unsupported, Void}; -use time::Duration; +use crate::boxed::FnBox; +use crate::ffi::CStr; +use crate::io; +use crate::sys::{unsupported, Void}; +use crate::time::Duration; pub struct Thread(Void); @@ -31,8 +31,8 @@ impl Thread { #[cfg(target_feature = "atomics")] pub fn sleep(dur: Duration) { - use arch::wasm32; - use cmp; + use crate::arch::wasm32; + use crate::cmp; // Use an atomic wait to block the current thread artificially with a // timeout listed. Note that we should never be notified (return value @@ -76,7 +76,7 @@ cfg_if! { // you'd like to use them be sure to update that and make sure everyone // agrees what's what. pub fn tcb_get() -> *mut u8 { - use mem; + use crate::mem; assert_eq!(mem::size_of::<*mut u8>(), mem::size_of::()); unsafe { __wbindgen_tcb_get() as *mut u8 } } diff --git a/src/libstd/sys/wasm/thread_local.rs b/src/libstd/sys/wasm/thread_local.rs index c7c385da8c376..29e9854bcfccb 100644 --- a/src/libstd/sys/wasm/thread_local.rs +++ b/src/libstd/sys/wasm/thread_local.rs @@ -1,5 +1,5 @@ -use boxed::Box; -use ptr; +use crate::boxed::Box; +use crate::ptr; pub type Key = usize; diff --git a/src/libstd/sys/wasm/thread_local_atomics.rs b/src/libstd/sys/wasm/thread_local_atomics.rs index d1d0af252c8c0..b408ad0d5c1f8 100644 --- a/src/libstd/sys/wasm/thread_local_atomics.rs +++ b/src/libstd/sys/wasm/thread_local_atomics.rs @@ -1,5 +1,5 @@ -use sys::thread; -use sync::atomic::{AtomicUsize, Ordering::SeqCst}; +use crate::sys::thread; +use crate::sync::atomic::{AtomicUsize, Ordering::SeqCst}; const MAX_KEYS: usize = 128; static NEXT_KEY: AtomicUsize = AtomicUsize::new(0); diff --git a/src/libstd/sys/wasm/time.rs b/src/libstd/sys/wasm/time.rs index 31798466fed2a..c1228a1b75e39 100644 --- a/src/libstd/sys/wasm/time.rs +++ b/src/libstd/sys/wasm/time.rs @@ -1,5 +1,5 @@ -use time::Duration; -use sys::{TimeSysCall, TimeClock}; +use crate::time::Duration; +use crate::sys::{TimeSysCall, TimeClock}; #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)] pub struct Instant(Duration); diff --git a/src/libstd/sys/windows/alloc.rs b/src/libstd/sys/windows/alloc.rs index 0d7f803c7eef6..a33c4019a2e6b 100644 --- a/src/libstd/sys/windows/alloc.rs +++ b/src/libstd/sys/windows/alloc.rs @@ -1,6 +1,6 @@ -use alloc::{GlobalAlloc, Layout, System}; -use sys::c; -use sys_common::alloc::{MIN_ALIGN, realloc_fallback}; +use crate::alloc::{GlobalAlloc, Layout, System}; +use crate::sys::c; +use crate::sys_common::alloc::{MIN_ALIGN, realloc_fallback}; #[repr(C)] struct Header(*mut u8); diff --git a/src/libstd/sys/windows/args.rs b/src/libstd/sys/windows/args.rs index f67280691097c..3f10e6e5983eb 100644 --- a/src/libstd/sys/windows/args.rs +++ b/src/libstd/sys/windows/args.rs @@ -1,14 +1,15 @@ #![allow(dead_code)] // runtime init functions not used during testing -use os::windows::prelude::*; -use sys::windows::os::current_exe; -use sys::c; -use ffi::OsString; -use fmt; -use vec; +use crate::os::windows::prelude::*; +use crate::sys::windows::os::current_exe; +use crate::sys::c; +use crate::ffi::OsString; +use crate::fmt; +use crate::vec; +use crate::slice; +use crate::path::PathBuf; + use core::iter; -use slice; -use path::PathBuf; pub unsafe fn init(_argc: isize, _argv: *const *const u8) { } @@ -80,7 +81,7 @@ unsafe fn parse_lp_cmd_line OsString>(lp_cmd_line: *const u16, exe_na // "However, if lpCmdLine starts with any amount of whitespace, CommandLineToArgvW // will consider the first argument to be an empty string. Excess whitespace at the // end of lpCmdLine is ignored." - 0...SPACE => { + 0..=SPACE => { ret_val.push(OsString::new()); &cmd_line[1..] }, @@ -192,8 +193,8 @@ impl ExactSizeIterator for Args { #[cfg(test)] mod tests { - use sys::windows::args::*; - use ffi::OsString; + use crate::sys::windows::args::*; + use crate::ffi::OsString; fn chk(string: &str, parts: &[&str]) { let mut wide: Vec = OsString::from(string).encode_wide().collect(); diff --git a/src/libstd/sys/windows/backtrace/backtrace_gnu.rs b/src/libstd/sys/windows/backtrace/backtrace_gnu.rs index e8aa939974232..7ac1f8122f781 100644 --- a/src/libstd/sys/windows/backtrace/backtrace_gnu.rs +++ b/src/libstd/sys/windows/backtrace/backtrace_gnu.rs @@ -1,10 +1,11 @@ -use io; -use sys::c; +use crate::io; +use crate::sys::c; +use crate::path::PathBuf; +use crate::fs::{OpenOptions, File}; +use crate::sys::ext::fs::OpenOptionsExt; +use crate::sys::handle::Handle; + use libc::c_char; -use path::PathBuf; -use fs::{OpenOptions, File}; -use sys::ext::fs::OpenOptionsExt; -use sys::handle::Handle; use super::super::{fill_utf16_buf, os2path, to_u16s, wide_char_to_multi_byte}; fn query_full_process_image_name() -> io::Result { diff --git a/src/libstd/sys/windows/backtrace/mod.rs b/src/libstd/sys/windows/backtrace/mod.rs index 4bda8ac91da62..c5b0cc8721087 100644 --- a/src/libstd/sys/windows/backtrace/mod.rs +++ b/src/libstd/sys/windows/backtrace/mod.rs @@ -14,13 +14,14 @@ #![allow(deprecated)] // dynamic_lib -use io; +use crate::io; +use crate::mem; +use crate::ptr; +use crate::sys::c; +use crate::sys::dynamic_lib::DynamicLibrary; +use crate::sys_common::backtrace::Frame; + use libc::c_void; -use mem; -use ptr; -use sys::c; -use sys::dynamic_lib::DynamicLibrary; -use sys_common::backtrace::Frame; macro_rules! sym { ($lib:expr, $e:expr, $t:ident) => ( diff --git a/src/libstd/sys/windows/backtrace/printing/mod.rs b/src/libstd/sys/windows/backtrace/printing/mod.rs index d44df7e5f248c..9497d51ac1799 100644 --- a/src/libstd/sys/windows/backtrace/printing/mod.rs +++ b/src/libstd/sys/windows/backtrace/printing/mod.rs @@ -4,11 +4,11 @@ mod printing; #[cfg(target_env = "gnu")] mod printing { - pub use sys_common::gnu::libbacktrace::{foreach_symbol_fileline, resolve_symname}; + pub use crate::sys_common::gnu::libbacktrace::{foreach_symbol_fileline, resolve_symname}; // dummy functions to mirror those present in msvc version. - use sys::dynamic_lib::DynamicLibrary; - use io; + use crate::sys::dynamic_lib::DynamicLibrary; + use crate::io; pub struct PrintingFnsEx {} pub struct PrintingFns64 {} pub fn load_printing_fns_ex(_: &DynamicLibrary) -> io::Result { diff --git a/src/libstd/sys/windows/backtrace/printing/msvc.rs b/src/libstd/sys/windows/backtrace/printing/msvc.rs index b186bb423345c..13a1512d0eb39 100644 --- a/src/libstd/sys/windows/backtrace/printing/msvc.rs +++ b/src/libstd/sys/windows/backtrace/printing/msvc.rs @@ -1,12 +1,13 @@ -use ffi::CStr; -use io; +use crate::ffi::CStr; +use crate::io; +use crate::mem; +use crate::sys::backtrace::BacktraceContext; +use crate::sys::backtrace::StackWalkVariant; +use crate::sys::c; +use crate::sys::dynamic_lib::DynamicLibrary; +use crate::sys_common::backtrace::Frame; + use libc::{c_char, c_ulong}; -use mem; -use sys::backtrace::BacktraceContext; -use sys::backtrace::StackWalkVariant; -use sys::c; -use sys::dynamic_lib::DynamicLibrary; -use sys_common::backtrace::Frame; // Structs holding printing functions and loaders for them // Two versions depending on whether dbghelp.dll has StackWalkEx or not @@ -190,7 +191,7 @@ where { unsafe { let mut line: c::IMAGEHLP_LINE64 = mem::zeroed(); - line.SizeOfStruct = ::mem::size_of::() as u32; + line.SizeOfStruct = mem::size_of::() as u32; let ret = line_getter( context.handle, diff --git a/src/libstd/sys/windows/c.rs b/src/libstd/sys/windows/c.rs index a78b599204b20..518eccf754cff 100644 --- a/src/libstd/sys/windows/c.rs +++ b/src/libstd/sys/windows/c.rs @@ -4,11 +4,12 @@ #![cfg_attr(test, allow(dead_code))] #![unstable(issue = "0", feature = "windows_c")] -use os::raw::{c_int, c_uint, c_ulong, c_long, c_longlong, c_ushort, c_char}; +use crate::os::raw::{c_int, c_uint, c_ulong, c_long, c_longlong, c_ushort, c_char}; #[cfg(target_arch = "x86_64")] -use os::raw::c_ulonglong; +use crate::os::raw::c_ulonglong; +use crate::ptr; + use libc::{wchar_t, size_t, c_void}; -use ptr; pub use self::FILE_INFO_BY_HANDLE_CLASS::*; pub use self::EXCEPTION_DISPOSITION::*; @@ -65,7 +66,7 @@ pub type PCONDITION_VARIABLE = *mut CONDITION_VARIABLE; pub type PLARGE_INTEGER = *mut c_longlong; pub type PSRWLOCK = *mut SRWLOCK; -pub type SOCKET = ::os::windows::raw::SOCKET; +pub type SOCKET = crate::os::windows::raw::SOCKET; pub type socklen_t = c_int; pub type ADDRESS_FAMILY = USHORT; @@ -450,7 +451,7 @@ pub struct MOUNT_POINT_REPARSE_BUFFER { pub PathBuffer: WCHAR, } -pub type LPPROGRESS_ROUTINE = ::option::Option Option { let mut module: Vec = module.encode_utf16().collect(); @@ -44,14 +44,14 @@ macro_rules! compat_fn { )*) => ($( #[allow(unused_variables)] pub unsafe fn $symbol($($argname: $argtype),*) -> $rettype { - use sync::atomic::{AtomicUsize, Ordering}; - use mem; + use crate::sync::atomic::{AtomicUsize, Ordering}; + use crate::mem; type F = unsafe extern "system" fn($($argtype),*) -> $rettype; static PTR: AtomicUsize = AtomicUsize::new(0); fn load() -> usize { - ::sys::compat::store_func(&PTR, + crate::sys::compat::store_func(&PTR, stringify!($module), stringify!($symbol), fallback as usize) diff --git a/src/libstd/sys/windows/condvar.rs b/src/libstd/sys/windows/condvar.rs index 48d8af7391308..62835ea7c94f3 100644 --- a/src/libstd/sys/windows/condvar.rs +++ b/src/libstd/sys/windows/condvar.rs @@ -1,8 +1,8 @@ -use cell::UnsafeCell; -use sys::c; -use sys::mutex::{self, Mutex}; -use sys::os; -use time::Duration; +use crate::cell::UnsafeCell; +use crate::sys::c; +use crate::sys::mutex::{self, Mutex}; +use crate::sys::os; +use crate::time::Duration; pub struct Condvar { inner: UnsafeCell } diff --git a/src/libstd/sys/windows/dynamic_lib.rs b/src/libstd/sys/windows/dynamic_lib.rs index fa3c5ecb97761..b9d5105cb7307 100644 --- a/src/libstd/sys/windows/dynamic_lib.rs +++ b/src/libstd/sys/windows/dynamic_lib.rs @@ -1,8 +1,8 @@ -use os::windows::prelude::*; +use crate::os::windows::prelude::*; -use ffi::{CString, OsStr}; -use io; -use sys::c; +use crate::ffi::{CString, OsStr}; +use crate::io; +use crate::sys::c; pub struct DynamicLibrary { handle: c::HMODULE, diff --git a/src/libstd/sys/windows/ext/ffi.rs b/src/libstd/sys/windows/ext/ffi.rs index 6508c0cf447d1..547b1ef796b4a 100644 --- a/src/libstd/sys/windows/ext/ffi.rs +++ b/src/libstd/sys/windows/ext/ffi.rs @@ -59,13 +59,13 @@ #![stable(feature = "rust1", since = "1.0.0")] -use ffi::{OsString, OsStr}; -use sys::os_str::Buf; -use sys_common::wtf8::Wtf8Buf; -use sys_common::{FromInner, AsInner}; +use crate::ffi::{OsString, OsStr}; +use crate::sys::os_str::Buf; +use crate::sys_common::wtf8::Wtf8Buf; +use crate::sys_common::{FromInner, AsInner}; #[stable(feature = "rust1", since = "1.0.0")] -pub use sys_common::wtf8::EncodeWide; +pub use crate::sys_common::wtf8::EncodeWide; /// Windows-specific extensions to [`OsString`]. /// diff --git a/src/libstd/sys/windows/ext/fs.rs b/src/libstd/sys/windows/ext/fs.rs index 89038da6295f2..b6da59502806b 100644 --- a/src/libstd/sys/windows/ext/fs.rs +++ b/src/libstd/sys/windows/ext/fs.rs @@ -2,11 +2,11 @@ #![stable(feature = "rust1", since = "1.0.0")] -use fs::{self, OpenOptions, Metadata}; -use io; -use path::Path; -use sys; -use sys_common::{AsInnerMut, AsInner}; +use crate::fs::{self, OpenOptions, Metadata}; +use crate::io; +use crate::path::Path; +use crate::sys; +use crate::sys_common::{AsInnerMut, AsInner}; /// Windows-specific extensions to [`File`]. /// diff --git a/src/libstd/sys/windows/ext/io.rs b/src/libstd/sys/windows/ext/io.rs index fbe0426ce5a8c..1a7d734b89e4b 100644 --- a/src/libstd/sys/windows/ext/io.rs +++ b/src/libstd/sys/windows/ext/io.rs @@ -1,12 +1,12 @@ #![stable(feature = "rust1", since = "1.0.0")] -use fs; -use os::windows::raw; -use net; -use sys_common::{self, AsInner, FromInner, IntoInner}; -use sys; -use io; -use sys::c; +use crate::fs; +use crate::os::windows::raw; +use crate::net; +use crate::sys_common::{self, AsInner, FromInner, IntoInner}; +use crate::sys; +use crate::sys::c; +use crate::io; /// Raw HANDLEs. #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libstd/sys/windows/ext/process.rs b/src/libstd/sys/windows/ext/process.rs index 15f0fd4e11f43..b2e6cdead4f3b 100644 --- a/src/libstd/sys/windows/ext/process.rs +++ b/src/libstd/sys/windows/ext/process.rs @@ -2,10 +2,10 @@ #![stable(feature = "process_extensions", since = "1.2.0")] -use os::windows::io::{FromRawHandle, RawHandle, AsRawHandle, IntoRawHandle}; -use process; -use sys; -use sys_common::{AsInnerMut, AsInner, FromInner, IntoInner}; +use crate::os::windows::io::{FromRawHandle, RawHandle, AsRawHandle, IntoRawHandle}; +use crate::process; +use crate::sys; +use crate::sys_common::{AsInnerMut, AsInner, FromInner, IntoInner}; #[stable(feature = "process_extensions", since = "1.2.0")] impl FromRawHandle for process::Stdio { diff --git a/src/libstd/sys/windows/ext/raw.rs b/src/libstd/sys/windows/ext/raw.rs index 77428d9e7747e..d2bab2720369f 100644 --- a/src/libstd/sys/windows/ext/raw.rs +++ b/src/libstd/sys/windows/ext/raw.rs @@ -2,7 +2,7 @@ #![stable(feature = "raw_ext", since = "1.1.0")] -use os::raw::c_void; +use crate::os::raw::c_void; #[stable(feature = "raw_ext", since = "1.1.0")] pub type HANDLE = *mut c_void; #[cfg(target_pointer_width = "32")] diff --git a/src/libstd/sys/windows/ext/thread.rs b/src/libstd/sys/windows/ext/thread.rs index 29d612fedc0f0..fdc7e7fa32f0e 100644 --- a/src/libstd/sys/windows/ext/thread.rs +++ b/src/libstd/sys/windows/ext/thread.rs @@ -2,9 +2,9 @@ #![stable(feature = "thread_extensions", since = "1.9.0")] -use os::windows::io::{RawHandle, AsRawHandle, IntoRawHandle}; -use thread; -use sys_common::{AsInner, IntoInner}; +use crate::os::windows::io::{RawHandle, AsRawHandle, IntoRawHandle}; +use crate::thread; +use crate::sys_common::{AsInner, IntoInner}; #[stable(feature = "thread_extensions", since = "1.9.0")] impl AsRawHandle for thread::JoinHandle { diff --git a/src/libstd/sys/windows/fast_thread_local.rs b/src/libstd/sys/windows/fast_thread_local.rs index f8b936b481038..0ccc67e3fd54e 100644 --- a/src/libstd/sys/windows/fast_thread_local.rs +++ b/src/libstd/sys/windows/fast_thread_local.rs @@ -1,7 +1,7 @@ #![unstable(feature = "thread_local_internals", issue = "0")] #![cfg(target_thread_local)] -pub use sys_common::thread_local::register_dtor_fallback as register_dtor; +pub use crate::sys_common::thread_local::register_dtor_fallback as register_dtor; pub fn requires_move_before_drop() -> bool { false diff --git a/src/libstd/sys/windows/fs.rs b/src/libstd/sys/windows/fs.rs index 533b8ae9ba2c0..f19c111f09aa2 100644 --- a/src/libstd/sys/windows/fs.rs +++ b/src/libstd/sys/windows/fs.rs @@ -1,17 +1,17 @@ -use os::windows::prelude::*; - -use ffi::OsString; -use fmt; -use io::{self, Error, SeekFrom}; -use mem; -use path::{Path, PathBuf}; -use ptr; -use slice; -use sync::Arc; -use sys::handle::Handle; -use sys::time::SystemTime; -use sys::{c, cvt}; -use sys_common::FromInner; +use crate::os::windows::prelude::*; + +use crate::ffi::OsString; +use crate::fmt; +use crate::io::{self, Error, SeekFrom}; +use crate::mem; +use crate::path::{Path, PathBuf}; +use crate::ptr; +use crate::slice; +use crate::sync::Arc; +use crate::sys::handle::Handle; +use crate::sys::time::SystemTime; +use crate::sys::{c, cvt}; +use crate::sys_common::FromInner; use super::to_u16s; diff --git a/src/libstd/sys/windows/handle.rs b/src/libstd/sys/windows/handle.rs index 855efbd3eb5d6..02549088c8704 100644 --- a/src/libstd/sys/windows/handle.rs +++ b/src/libstd/sys/windows/handle.rs @@ -1,13 +1,12 @@ #![unstable(issue = "0", feature = "windows_handle")] -use cmp; -use io::{ErrorKind, Read}; -use io; -use mem; -use ops::Deref; -use ptr; -use sys::c; -use sys::cvt; +use crate::cmp; +use crate::io::{self, ErrorKind, Read}; +use crate::mem; +use crate::ops::Deref; +use crate::ptr; +use crate::sys::c; +use crate::sys::cvt; /// An owned container for `HANDLE` object, closing them on Drop. /// diff --git a/src/libstd/sys/windows/io.rs b/src/libstd/sys/windows/io.rs index 662e304792386..54dd271c9d666 100644 --- a/src/libstd/sys/windows/io.rs +++ b/src/libstd/sys/windows/io.rs @@ -1,6 +1,6 @@ -use marker::PhantomData; -use slice; -use sys::c; +use crate::marker::PhantomData; +use crate::slice; +use crate::sys::c; #[repr(transparent)] pub struct IoVec<'a> { diff --git a/src/libstd/sys/windows/mod.rs b/src/libstd/sys/windows/mod.rs index 56c76a169feb8..1425254a2e126 100644 --- a/src/libstd/sys/windows/mod.rs +++ b/src/libstd/sys/windows/mod.rs @@ -1,11 +1,11 @@ #![allow(missing_docs, nonstandard_style)] -use ptr; -use ffi::{OsStr, OsString}; -use io::ErrorKind; -use os::windows::ffi::{OsStrExt, OsStringExt}; -use path::PathBuf; -use time::Duration; +use crate::ptr; +use crate::ffi::{OsStr, OsString}; +use crate::io::ErrorKind; +use crate::os::windows::ffi::{OsStrExt, OsStringExt}; +use crate::path::PathBuf; +use crate::time::Duration; pub use libc::strlen; pub use self::rand::hashmap_random_keys; @@ -76,11 +76,11 @@ pub fn decode_error_kind(errno: i32) -> ErrorKind { } } -pub fn to_u16s>(s: S) -> ::io::Result> { - fn inner(s: &OsStr) -> ::io::Result> { +pub fn to_u16s>(s: S) -> crate::io::Result> { + fn inner(s: &OsStr) -> crate::io::Result> { let mut maybe_result: Vec = s.encode_wide().collect(); if maybe_result.iter().any(|&u| u == 0) { - return Err(::io::Error::new(::io::ErrorKind::InvalidInput, + return Err(crate::io::Error::new(ErrorKind::InvalidInput, "strings passed to WinAPI cannot contain NULs")); } maybe_result.push(0); @@ -103,7 +103,7 @@ pub fn to_u16s>(s: S) -> ::io::Result> { // Once the syscall has completed (errors bail out early) the second closure is // yielded the data which has been read from the syscall. The return value // from this closure is then the return value of the function. -fn fill_utf16_buf(mut f1: F1, f2: F2) -> ::io::Result +fn fill_utf16_buf(mut f1: F1, f2: F2) -> crate::io::Result where F1: FnMut(*mut u16, c::DWORD) -> c::DWORD, F2: FnOnce(&[u16]) -> T { @@ -135,7 +135,7 @@ fn fill_utf16_buf(mut f1: F1, f2: F2) -> ::io::Result c::SetLastError(0); let k = match f1(buf.as_mut_ptr(), n as c::DWORD) { 0 if c::GetLastError() == 0 => 0, - 0 => return Err(::io::Error::last_os_error()), + 0 => return Err(crate::io::Error::last_os_error()), n => n, } as usize; if k == n && c::GetLastError() == c::ERROR_INSUFFICIENT_BUFFER { @@ -158,7 +158,7 @@ fn wide_char_to_multi_byte(code_page: u32, flags: u32, s: &[u16], no_default_char: bool) - -> ::io::Result> { + -> crate::io::Result> { unsafe { let mut size = c::WideCharToMultiByte(code_page, flags, @@ -169,7 +169,7 @@ fn wide_char_to_multi_byte(code_page: u32, ptr::null(), ptr::null_mut()); if size == 0 { - return Err(::io::Error::last_os_error()); + return Err(crate::io::Error::last_os_error()); } let mut buf = Vec::with_capacity(size as usize); @@ -186,10 +186,10 @@ fn wide_char_to_multi_byte(code_page: u32, if no_default_char { &mut used_default_char } else { ptr::null_mut() }); if size == 0 { - return Err(::io::Error::last_os_error()); + return Err(crate::io::Error::last_os_error()); } if no_default_char && used_default_char == c::TRUE { - return Err(::io::Error::new(::io::ErrorKind::InvalidData, + return Err(crate::io::Error::new(crate::io::ErrorKind::InvalidData, "string cannot be converted to requested code page")); } @@ -221,9 +221,9 @@ macro_rules! impl_is_zero { impl_is_zero! { i8 i16 i32 i64 isize u8 u16 u32 u64 usize } -pub fn cvt(i: I) -> ::io::Result { +pub fn cvt(i: I) -> crate::io::Result { if i.is_zero() { - Err(::io::Error::last_os_error()) + Err(crate::io::Error::last_os_error()) } else { Ok(i) } @@ -263,7 +263,7 @@ pub unsafe fn abort_internal() -> ! { #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] { asm!("int $$0x29" :: "{ecx}"(7) ::: volatile); // 7 is FAST_FAIL_FATAL_APP_EXIT - ::intrinsics::unreachable(); + crate::intrinsics::unreachable(); } - ::intrinsics::abort(); + crate::intrinsics::abort(); } diff --git a/src/libstd/sys/windows/mutex.rs b/src/libstd/sys/windows/mutex.rs index f690580ae38bc..1aa910f05c9c3 100644 --- a/src/libstd/sys/windows/mutex.rs +++ b/src/libstd/sys/windows/mutex.rs @@ -19,11 +19,11 @@ //! CriticalSection is used and we keep track of who's holding the mutex to //! detect recursive locks. -use cell::UnsafeCell; -use mem::{self, MaybeUninit}; -use sync::atomic::{AtomicUsize, Ordering}; -use sys::c; -use sys::compat; +use crate::cell::UnsafeCell; +use crate::mem::{self, MaybeUninit}; +use crate::sync::atomic::{AtomicUsize, Ordering}; +use crate::sys::c; +use crate::sys::compat; pub struct Mutex { lock: AtomicUsize, diff --git a/src/libstd/sys/windows/net.rs b/src/libstd/sys/windows/net.rs index 76be26a9d1a57..1231fd55e252e 100644 --- a/src/libstd/sys/windows/net.rs +++ b/src/libstd/sys/windows/net.rs @@ -1,26 +1,27 @@ #![unstable(issue = "0", feature = "windows_net")] -use cmp; -use io::{self, Read, IoVec, IoVecMut}; +use crate::cmp; +use crate::io::{self, Read, IoVec, IoVecMut}; +use crate::mem; +use crate::net::{SocketAddr, Shutdown}; +use crate::ptr; +use crate::sync::Once; +use crate::sys::c; +use crate::sys; +use crate::sys_common::{self, AsInner, FromInner, IntoInner}; +use crate::sys_common::net; +use crate::time::Duration; + use libc::{c_int, c_void, c_ulong, c_long}; -use mem; -use net::{SocketAddr, Shutdown}; -use ptr; -use sync::Once; -use sys::c; -use sys; -use sys_common::{self, AsInner, FromInner, IntoInner}; -use sys_common::net; -use time::Duration; pub type wrlen_t = i32; pub mod netc { - pub use sys::c::*; - pub use sys::c::SOCKADDR as sockaddr; - pub use sys::c::SOCKADDR_STORAGE_LH as sockaddr_storage; - pub use sys::c::ADDRINFOA as addrinfo; - pub use sys::c::ADDRESS_FAMILY as sa_family_t; + pub use crate::sys::c::*; + pub use crate::sys::c::SOCKADDR as sockaddr; + pub use crate::sys::c::SOCKADDR_STORAGE_LH as sockaddr_storage; + pub use crate::sys::c::ADDRINFOA as addrinfo; + pub use crate::sys::c::ADDRESS_FAMILY as sa_family_t; } pub struct Socket(c::SOCKET); diff --git a/src/libstd/sys/windows/os.rs b/src/libstd/sys/windows/os.rs index 7399dd41a41cf..5b433ddfb4a38 100644 --- a/src/libstd/sys/windows/os.rs +++ b/src/libstd/sys/windows/os.rs @@ -2,18 +2,18 @@ #![allow(nonstandard_style)] -use os::windows::prelude::*; - -use error::Error as StdError; -use ffi::{OsString, OsStr}; -use fmt; -use io; -use os::windows::ffi::EncodeWide; -use path::{self, PathBuf}; -use ptr; -use slice; -use sys::{c, cvt}; -use sys::handle::Handle; +use crate::os::windows::prelude::*; + +use crate::error::Error as StdError; +use crate::ffi::{OsString, OsStr}; +use crate::fmt; +use crate::io; +use crate::os::windows::ffi::EncodeWide; +use crate::path::{self, PathBuf}; +use crate::ptr; +use crate::slice; +use crate::sys::{c, cvt}; +use crate::sys::handle::Handle; use super::to_u16s; @@ -285,8 +285,8 @@ pub fn temp_dir() -> PathBuf { } pub fn home_dir() -> Option { - ::env::var_os("HOME").or_else(|| { - ::env::var_os("USERPROFILE") + crate::env::var_os("HOME").or_else(|| { + crate::env::var_os("USERPROFILE") }).map(PathBuf::from).or_else(|| unsafe { let me = c::GetCurrentProcess(); let mut token = ptr::null_mut(); @@ -314,8 +314,8 @@ pub fn getpid() -> u32 { #[cfg(test)] mod tests { - use io::Error; - use sys::c; + use crate::io::Error; + use crate::sys::c; // tests `error_string` above #[test] diff --git a/src/libstd/sys/windows/os_str.rs b/src/libstd/sys/windows/os_str.rs index 7e4bcd990b1e7..8befa66ecdc9c 100644 --- a/src/libstd/sys/windows/os_str.rs +++ b/src/libstd/sys/windows/os_str.rs @@ -1,13 +1,13 @@ /// The underlying OsString/OsStr implementation on Windows is a /// wrapper around the "WTF-8" encoding; see the `wtf8` module for more. -use borrow::Cow; -use fmt; -use sys_common::wtf8::{Wtf8, Wtf8Buf}; -use mem; -use rc::Rc; -use sync::Arc; -use sys_common::{AsInner, IntoInner, FromInner}; +use crate::borrow::Cow; +use crate::fmt; +use crate::sys_common::wtf8::{Wtf8, Wtf8Buf}; +use crate::mem; +use crate::rc::Rc; +use crate::sync::Arc; +use crate::sys_common::{AsInner, IntoInner, FromInner}; #[derive(Clone, Hash)] pub struct Buf { diff --git a/src/libstd/sys/windows/path.rs b/src/libstd/sys/windows/path.rs index ad1759e84c328..b8532ca9b0d4e 100644 --- a/src/libstd/sys/windows/path.rs +++ b/src/libstd/sys/windows/path.rs @@ -1,6 +1,6 @@ -use path::Prefix; -use ffi::OsStr; -use mem; +use crate::path::Prefix; +use crate::ffi::OsStr; +use crate::mem; fn os_str_as_u8_slice(s: &OsStr) -> &[u8] { unsafe { mem::transmute(s) } @@ -20,7 +20,7 @@ pub fn is_verbatim_sep(b: u8) -> bool { } pub fn parse_prefix<'a>(path: &'a OsStr) -> Option { - use path::Prefix::*; + use crate::path::Prefix::*; unsafe { // The unsafety here stems from converting between &OsStr and &[u8] // and back. This is safe to do because (1) we only look at ASCII diff --git a/src/libstd/sys/windows/pipe.rs b/src/libstd/sys/windows/pipe.rs index d3b102268f632..07f4f5f0e58c4 100644 --- a/src/libstd/sys/windows/pipe.rs +++ b/src/libstd/sys/windows/pipe.rs @@ -1,17 +1,17 @@ -use os::windows::prelude::*; +use crate::os::windows::prelude::*; -use ffi::OsStr; -use io; -use mem; -use path::Path; -use ptr; -use slice; -use sync::atomic::Ordering::SeqCst; -use sync::atomic::AtomicUsize; -use sys::c; -use sys::fs::{File, OpenOptions}; -use sys::handle::Handle; -use sys::hashmap_random_keys; +use crate::ffi::OsStr; +use crate::io; +use crate::mem; +use crate::path::Path; +use crate::ptr; +use crate::slice; +use crate::sync::atomic::Ordering::SeqCst; +use crate::sync::atomic::AtomicUsize; +use crate::sys::c; +use crate::sys::fs::{File, OpenOptions}; +use crate::sys::handle::Handle; +use crate::sys::hashmap_random_keys; //////////////////////////////////////////////////////////////////////////////// // Anonymous pipes diff --git a/src/libstd/sys/windows/process.rs b/src/libstd/sys/windows/process.rs index 2527168a968c4..95f061d22bd43 100644 --- a/src/libstd/sys/windows/process.rs +++ b/src/libstd/sys/windows/process.rs @@ -1,27 +1,28 @@ #![unstable(feature = "process_internals", issue = "0")] -use collections::BTreeMap; -use env::split_paths; -use env; -use ffi::{OsString, OsStr}; -use fmt; -use fs; -use io::{self, Error, ErrorKind}; +use crate::collections::BTreeMap; +use crate::env::split_paths; +use crate::env; +use crate::ffi::{OsString, OsStr}; +use crate::fmt; +use crate::fs; +use crate::io::{self, Error, ErrorKind}; +use crate::mem; +use crate::os::windows::ffi::OsStrExt; +use crate::path::Path; +use crate::ptr; +use crate::sys::mutex::Mutex; +use crate::sys::c; +use crate::sys::fs::{OpenOptions, File}; +use crate::sys::handle::Handle; +use crate::sys::pipe::{self, AnonPipe}; +use crate::sys::stdio; +use crate::sys::cvt; +use crate::sys_common::{AsInner, FromInner, IntoInner}; +use crate::sys_common::process::{CommandEnv, EnvKey}; +use crate::borrow::Borrow; + use libc::{c_void, EXIT_SUCCESS, EXIT_FAILURE}; -use mem; -use os::windows::ffi::OsStrExt; -use path::Path; -use ptr; -use sys::mutex::Mutex; -use sys::c; -use sys::fs::{OpenOptions, File}; -use sys::handle::Handle; -use sys::pipe::{self, AnonPipe}; -use sys::stdio; -use sys::cvt; -use sys_common::{AsInner, FromInner, IntoInner}; -use sys_common::process::{CommandEnv, EnvKey}; -use borrow::Borrow; //////////////////////////////////////////////////////////////////////////////// // Command @@ -537,7 +538,7 @@ fn make_dirp(d: Option<&OsString>) -> io::Result<(*const u16, Vec)> { #[cfg(test)] mod tests { - use ffi::{OsStr, OsString}; + use crate::ffi::{OsStr, OsString}; use super::make_command_line; #[test] diff --git a/src/libstd/sys/windows/rand.rs b/src/libstd/sys/windows/rand.rs index 4f000dceb2f18..0193f4defa1ff 100644 --- a/src/libstd/sys/windows/rand.rs +++ b/src/libstd/sys/windows/rand.rs @@ -1,6 +1,6 @@ -use io; -use mem; -use sys::c; +use crate::io; +use crate::mem; +use crate::sys::c; pub fn hashmap_random_keys() -> (u64, u64) { let mut v = (0, 0); diff --git a/src/libstd/sys/windows/rwlock.rs b/src/libstd/sys/windows/rwlock.rs index 3cd19470101aa..ef57562fc3a0b 100644 --- a/src/libstd/sys/windows/rwlock.rs +++ b/src/libstd/sys/windows/rwlock.rs @@ -1,5 +1,5 @@ -use cell::UnsafeCell; -use sys::c; +use crate::cell::UnsafeCell; +use crate::sys::c; pub struct RWLock { inner: UnsafeCell } diff --git a/src/libstd/sys/windows/stack_overflow.rs b/src/libstd/sys/windows/stack_overflow.rs index 0c7de0bc9e8f3..d5b7765f9ff5f 100644 --- a/src/libstd/sys/windows/stack_overflow.rs +++ b/src/libstd/sys/windows/stack_overflow.rs @@ -1,7 +1,7 @@ #![cfg_attr(test, allow(dead_code))] -use sys_common::util::report_overflow; -use sys::c; +use crate::sys_common::util::report_overflow; +use crate::sys::c; pub struct Handler; diff --git a/src/libstd/sys/windows/stdio.rs b/src/libstd/sys/windows/stdio.rs index 99445f4e0d45d..b1e76b3b755da 100644 --- a/src/libstd/sys/windows/stdio.rs +++ b/src/libstd/sys/windows/stdio.rs @@ -1,13 +1,13 @@ #![unstable(issue = "0", feature = "windows_stdio")] -use char::decode_utf16; -use cmp; -use io; -use ptr; -use str; -use sys::c; -use sys::cvt; -use sys::handle::Handle; +use crate::char::decode_utf16; +use crate::cmp; +use crate::io; +use crate::ptr; +use crate::str; +use crate::sys::c; +use crate::sys::cvt; +use crate::sys::handle::Handle; // Don't cache handles but get them fresh for every read/write. This allows us to track changes to // the value over time (such as if a process calls `SetStdHandle` while it's running). See #40490. @@ -201,7 +201,7 @@ fn read_u16s(handle: c::HANDLE, buf: &mut [u16]) -> io::Result { const CTRL_Z: u16 = 0x1A; const CTRL_Z_MASK: c::ULONG = 1 << CTRL_Z; let mut input_control = c::CONSOLE_READCONSOLE_CONTROL { - nLength: ::mem::size_of::() as c::ULONG, + nLength: crate::mem::size_of::() as c::ULONG, nInitialChars: 0, dwCtrlWakeupMask: CTRL_Z_MASK, dwControlKeyState: 0, diff --git a/src/libstd/sys/windows/thread.rs b/src/libstd/sys/windows/thread.rs index bd7cb673a0dbe..1b0a811f13b72 100644 --- a/src/libstd/sys/windows/thread.rs +++ b/src/libstd/sys/windows/thread.rs @@ -1,13 +1,14 @@ -use boxed::FnBox; -use io; -use ffi::CStr; -use mem; +use crate::boxed::FnBox; +use crate::io; +use crate::ffi::CStr; +use crate::mem; +use crate::ptr; +use crate::sys::c; +use crate::sys::handle::Handle; +use crate::sys_common::thread::*; +use crate::time::Duration; + use libc::c_void; -use ptr; -use sys::c; -use sys::handle::Handle; -use sys_common::thread::*; -use time::Duration; use super::to_u16s; diff --git a/src/libstd/sys/windows/thread_local.rs b/src/libstd/sys/windows/thread_local.rs index 50bbd5476b366..4c9734fa0aa61 100644 --- a/src/libstd/sys/windows/thread_local.rs +++ b/src/libstd/sys/windows/thread_local.rs @@ -1,8 +1,8 @@ -use mem; -use ptr; -use sync::atomic::AtomicPtr; -use sync::atomic::Ordering::SeqCst; -use sys::c; +use crate::mem; +use crate::ptr; +use crate::sync::atomic::AtomicPtr; +use crate::sync::atomic::Ordering::SeqCst; +use crate::sys::c; pub type Key = c::DWORD; pub type Dtor = unsafe extern fn(*mut u8); @@ -211,7 +211,7 @@ unsafe extern "system" fn on_tls_callback(h: c::LPVOID, #[cfg(target_env = "msvc")] unsafe fn reference_tls_used() { extern { static _tls_used: u8; } - ::intrinsics::volatile_load(&_tls_used); + crate::intrinsics::volatile_load(&_tls_used); } #[cfg(not(target_env = "msvc"))] unsafe fn reference_tls_used() {} diff --git a/src/libstd/sys/windows/time.rs b/src/libstd/sys/windows/time.rs index 8a8159af2f1a6..2c99bca70095c 100644 --- a/src/libstd/sys/windows/time.rs +++ b/src/libstd/sys/windows/time.rs @@ -1,9 +1,10 @@ -use cmp::Ordering; -use fmt; -use mem; -use sys::c; -use time::Duration; -use convert::TryInto; +use crate::cmp::Ordering; +use crate::fmt; +use crate::mem; +use crate::sys::c; +use crate::time::Duration; +use crate::convert::TryInto; + use core::hash::{Hash, Hasher}; const NANOS_PER_SEC: u64 = 1_000_000_000; @@ -172,11 +173,11 @@ fn intervals2dur(intervals: u64) -> Duration { mod perf_counter { use super::{NANOS_PER_SEC}; - use sync::Once; - use sys_common::mul_div_u64; - use sys::c; - use sys::cvt; - use time::Duration; + use crate::sync::Once; + use crate::sys_common::mul_div_u64; + use crate::sys::c; + use crate::sys::cvt; + use crate::time::Duration; pub struct PerformanceCounterInstant { ts: c::LARGE_INTEGER diff --git a/src/libstd/sys_common/alloc.rs b/src/libstd/sys_common/alloc.rs index eac6bb454c0cd..978a70bee0983 100644 --- a/src/libstd/sys_common/alloc.rs +++ b/src/libstd/sys_common/alloc.rs @@ -1,8 +1,8 @@ #![allow(dead_code)] -use alloc::{GlobalAlloc, Layout, System}; -use cmp; -use ptr; +use crate::alloc::{GlobalAlloc, Layout, System}; +use crate::cmp; +use crate::ptr; // The minimum alignment guaranteed by the architecture. This value is used to // add fast paths for low alignment values. diff --git a/src/libstd/sys_common/at_exit_imp.rs b/src/libstd/sys_common/at_exit_imp.rs index cd2d176c2a5c5..1181b86161199 100644 --- a/src/libstd/sys_common/at_exit_imp.rs +++ b/src/libstd/sys_common/at_exit_imp.rs @@ -2,10 +2,10 @@ //! //! Documentation can be found on the `rt::at_exit` function. -use boxed::FnBox; -use ptr; -use mem; -use sys_common::mutex::Mutex; +use crate::boxed::FnBox; +use crate::ptr; +use crate::mem; +use crate::sys_common::mutex::Mutex; type Queue = Vec>; diff --git a/src/libstd/sys_common/backtrace.rs b/src/libstd/sys_common/backtrace.rs index 347244b0e0d44..1a80908779e1a 100644 --- a/src/libstd/sys_common/backtrace.rs +++ b/src/libstd/sys_common/backtrace.rs @@ -1,17 +1,18 @@ /// Common code for printing the backtrace in the same way across the different /// supported platforms. -use env; -use io::prelude::*; -use io; -use path::{self, Path}; -use ptr; +use crate::env; +use crate::io::prelude::*; +use crate::io; +use crate::path::{self, Path}; +use crate::ptr; +use crate::str; +use crate::sync::atomic::{self, Ordering}; +use crate::sys::mutex::Mutex; + use rustc_demangle::demangle; -use str; -use sync::atomic::{self, Ordering}; -use sys::mutex::Mutex; -pub use sys::backtrace::{ +pub use crate::sys::backtrace::{ unwind_backtrace, resolve_symname, foreach_symbol_fileline, diff --git a/src/libstd/sys_common/bytestring.rs b/src/libstd/sys_common/bytestring.rs index 915c17374ca02..273d586a5a0b2 100644 --- a/src/libstd/sys_common/bytestring.rs +++ b/src/libstd/sys_common/bytestring.rs @@ -1,6 +1,6 @@ #![allow(dead_code)] -use fmt::{Formatter, Result, Write}; +use crate::fmt::{Formatter, Result, Write}; use core::str::lossy::{Utf8Lossy, Utf8LossyChunk}; pub fn debug_fmt_bytestring(slice: &[u8], f: &mut Formatter) -> Result { @@ -25,7 +25,7 @@ pub fn debug_fmt_bytestring(slice: &[u8], f: &mut Formatter) -> Result { #[cfg(test)] mod tests { use super::*; - use fmt::{Formatter, Result, Debug}; + use crate::fmt::{Formatter, Result, Debug}; #[test] fn smoke() { diff --git a/src/libstd/sys_common/condvar.rs b/src/libstd/sys_common/condvar.rs index ad95879f07355..fc59c8356f46a 100644 --- a/src/libstd/sys_common/condvar.rs +++ b/src/libstd/sys_common/condvar.rs @@ -1,6 +1,6 @@ -use time::Duration; -use sys_common::mutex::{self, Mutex}; -use sys::condvar as imp; +use crate::time::Duration; +use crate::sys_common::mutex::{self, Mutex}; +use crate::sys::condvar as imp; /// An OS-based condition variable. /// diff --git a/src/libstd/sys_common/gnu/libbacktrace.rs b/src/libstd/sys_common/gnu/libbacktrace.rs index 188eb4e4b86b1..6cd050242dd95 100644 --- a/src/libstd/sys_common/gnu/libbacktrace.rs +++ b/src/libstd/sys_common/gnu/libbacktrace.rs @@ -1,12 +1,11 @@ -use libc; -use backtrace_sys::{self, backtrace_state}; +use backtrace_sys::backtrace_state; -use ffi::CStr; -use io; -use mem; -use ptr; -use sys::backtrace::BacktraceContext; -use sys_common::backtrace::Frame; +use crate::ffi::CStr; +use crate::io; +use crate::mem; +use crate::ptr; +use crate::sys::backtrace::BacktraceContext; +use crate::sys_common::backtrace::Frame; pub fn foreach_symbol_fileline(frame: Frame, mut f: F, @@ -153,7 +152,7 @@ unsafe fn init_state() -> *mut backtrace_state { static mut STATE: *mut backtrace_state = ptr::null_mut(); if !STATE.is_null() { return STATE } - let filename = match ::sys::backtrace::gnu::get_executable_filename() { + let filename = match crate::sys::backtrace::gnu::get_executable_filename() { Ok((filename, file)) => { // filename is purposely leaked here since libbacktrace requires // it to stay allocated permanently, file is also leaked so that diff --git a/src/libstd/sys_common/io.rs b/src/libstd/sys_common/io.rs index b9071c69b7cec..44b0963302ddf 100644 --- a/src/libstd/sys_common/io.rs +++ b/src/libstd/sys_common/io.rs @@ -3,10 +3,10 @@ pub const DEFAULT_BUF_SIZE: usize = 8 * 1024; #[cfg(test)] #[allow(dead_code)] // not used on emscripten pub mod test { - use path::{Path, PathBuf}; - use env; - use rand::{self, RngCore}; - use fs; + use crate::path::{Path, PathBuf}; + use crate::env; + use crate::fs; + use rand::RngCore; pub struct TempDir(PathBuf); diff --git a/src/libstd/sys_common/mod.rs b/src/libstd/sys_common/mod.rs index c18b603a6356c..1fc32365408b8 100644 --- a/src/libstd/sys_common/mod.rs +++ b/src/libstd/sys_common/mod.rs @@ -15,11 +15,11 @@ #![allow(missing_docs)] #![allow(missing_debug_implementations)] -use sync::Once; -use sys; +use crate::sync::Once; +use crate::sys; macro_rules! rtabort { - ($($t:tt)*) => (::sys_common::util::abort(format_args!($($t)*))) + ($($t:tt)*) => (crate::sys_common::util::abort(format_args!($($t)*))) } macro_rules! rtassert { @@ -52,7 +52,7 @@ cfg_if! { target_os = "redox", all(target_arch = "wasm32", not(target_os = "emscripten")), all(target_vendor = "fortanix", target_env = "sgx")))] { - pub use sys::net; + pub use crate::sys::net; } else { pub mod net; } diff --git a/src/libstd/sys_common/mutex.rs b/src/libstd/sys_common/mutex.rs index b47d8698c605b..4b58cac7941b9 100644 --- a/src/libstd/sys_common/mutex.rs +++ b/src/libstd/sys_common/mutex.rs @@ -1,4 +1,4 @@ -use sys::mutex as imp; +use crate::sys::mutex as imp; /// An OS-based mutual exclusion lock. /// diff --git a/src/libstd/sys_common/net.rs b/src/libstd/sys_common/net.rs index 0d60593ce1f2f..36721171b1733 100644 --- a/src/libstd/sys_common/net.rs +++ b/src/libstd/sys_common/net.rs @@ -1,37 +1,38 @@ -use cmp; -use ffi::CString; -use fmt; -use io::{self, Error, ErrorKind, IoVec, IoVecMut}; +use crate::cmp; +use crate::ffi::CString; +use crate::fmt; +use crate::io::{self, Error, ErrorKind, IoVec, IoVecMut}; +use crate::mem; +use crate::net::{SocketAddr, Shutdown, Ipv4Addr, Ipv6Addr}; +use crate::ptr; +use crate::sys::net::{cvt, cvt_r, cvt_gai, Socket, init, wrlen_t}; +use crate::sys::net::netc as c; +use crate::sys_common::{AsInner, FromInner, IntoInner}; +use crate::time::Duration; +use crate::convert::{TryFrom, TryInto}; + use libc::{c_int, c_void}; -use mem; -use net::{SocketAddr, Shutdown, Ipv4Addr, Ipv6Addr}; -use ptr; -use sys::net::{cvt, cvt_r, cvt_gai, Socket, init, wrlen_t}; -use sys::net::netc as c; -use sys_common::{AsInner, FromInner, IntoInner}; -use time::Duration; -use convert::{TryFrom, TryInto}; #[cfg(any(target_os = "dragonfly", target_os = "freebsd", target_os = "ios", target_os = "macos", target_os = "openbsd", target_os = "netbsd", target_os = "solaris", target_os = "haiku", target_os = "l4re"))] -use sys::net::netc::IPV6_JOIN_GROUP as IPV6_ADD_MEMBERSHIP; +use crate::sys::net::netc::IPV6_JOIN_GROUP as IPV6_ADD_MEMBERSHIP; #[cfg(not(any(target_os = "dragonfly", target_os = "freebsd", target_os = "ios", target_os = "macos", target_os = "openbsd", target_os = "netbsd", target_os = "solaris", target_os = "haiku", target_os = "l4re")))] -use sys::net::netc::IPV6_ADD_MEMBERSHIP; +use crate::sys::net::netc::IPV6_ADD_MEMBERSHIP; #[cfg(any(target_os = "dragonfly", target_os = "freebsd", target_os = "ios", target_os = "macos", target_os = "openbsd", target_os = "netbsd", target_os = "solaris", target_os = "haiku", target_os = "l4re"))] -use sys::net::netc::IPV6_LEAVE_GROUP as IPV6_DROP_MEMBERSHIP; +use crate::sys::net::netc::IPV6_LEAVE_GROUP as IPV6_DROP_MEMBERSHIP; #[cfg(not(any(target_os = "dragonfly", target_os = "freebsd", target_os = "ios", target_os = "macos", target_os = "openbsd", target_os = "netbsd", target_os = "solaris", target_os = "haiku", target_os = "l4re")))] -use sys::net::netc::IPV6_DROP_MEMBERSHIP; +use crate::sys::net::netc::IPV6_DROP_MEMBERSHIP; #[cfg(any(target_os = "linux", target_os = "android", target_os = "dragonfly", target_os = "freebsd", @@ -109,8 +110,8 @@ fn to_ipv6mr_interface(value: u32) -> c_int { } #[cfg(not(target_os = "android"))] -fn to_ipv6mr_interface(value: u32) -> ::libc::c_uint { - value as ::libc::c_uint +fn to_ipv6mr_interface(value: u32) -> libc::c_uint { + value as libc::c_uint } //////////////////////////////////////////////////////////////////////////////// @@ -653,7 +654,7 @@ impl fmt::Debug for UdpSocket { #[cfg(test)] mod tests { use super::*; - use collections::HashMap; + use crate::collections::HashMap; #[test] fn no_lookup_host_duplicates() { diff --git a/src/libstd/sys_common/poison.rs b/src/libstd/sys_common/poison.rs index 1358916ef9936..d229423566649 100644 --- a/src/libstd/sys_common/poison.rs +++ b/src/libstd/sys_common/poison.rs @@ -1,7 +1,7 @@ -use error::{Error}; -use fmt; -use sync::atomic::{AtomicBool, Ordering}; -use thread; +use crate::error::{Error}; +use crate::fmt; +use crate::sync::atomic::{AtomicBool, Ordering}; +use crate::thread; pub struct Flag { failed: AtomicBool } diff --git a/src/libstd/sys_common/process.rs b/src/libstd/sys_common/process.rs index 3384ffeb64e9f..4d40dec97245a 100644 --- a/src/libstd/sys_common/process.rs +++ b/src/libstd/sys_common/process.rs @@ -1,10 +1,10 @@ #![allow(dead_code)] #![unstable(feature = "process_internals", issue = "0")] -use ffi::{OsStr, OsString}; -use env; -use collections::BTreeMap; -use borrow::Borrow; +use crate::ffi::{OsStr, OsString}; +use crate::env; +use crate::collections::BTreeMap; +use crate::borrow::Borrow; pub trait EnvKey: From + Into + diff --git a/src/libstd/sys_common/remutex.rs b/src/libstd/sys_common/remutex.rs index 596e5d534c293..2aec361d7a493 100644 --- a/src/libstd/sys_common/remutex.rs +++ b/src/libstd/sys_common/remutex.rs @@ -1,9 +1,9 @@ -use fmt; -use marker; -use ops::Deref; -use sys_common::poison::{self, TryLockError, TryLockResult, LockResult}; -use sys::mutex as sys; -use panic::{UnwindSafe, RefUnwindSafe}; +use crate::fmt; +use crate::marker; +use crate::ops::Deref; +use crate::sys_common::poison::{self, TryLockError, TryLockResult, LockResult}; +use crate::sys::mutex as sys; +use crate::panic::{UnwindSafe, RefUnwindSafe}; /// A re-entrant mutual exclusion /// @@ -159,10 +159,10 @@ impl Drop for ReentrantMutexGuard<'_, T> { #[cfg(all(test, not(target_os = "emscripten")))] mod tests { - use sys_common::remutex::{ReentrantMutex, ReentrantMutexGuard}; - use cell::RefCell; - use sync::Arc; - use thread; + use crate::sys_common::remutex::{ReentrantMutex, ReentrantMutexGuard}; + use crate::cell::RefCell; + use crate::sync::Arc; + use crate::thread; #[test] fn smoke() { diff --git a/src/libstd/sys_common/rwlock.rs b/src/libstd/sys_common/rwlock.rs index 0aa0284539a8f..0b1a092de5422 100644 --- a/src/libstd/sys_common/rwlock.rs +++ b/src/libstd/sys_common/rwlock.rs @@ -1,4 +1,4 @@ -use sys::rwlock as imp; +use crate::sys::rwlock as imp; /// An OS-based reader-writer lock. /// diff --git a/src/libstd/sys_common/thread.rs b/src/libstd/sys_common/thread.rs index fe9ad7623b7d5..b2142e753085a 100644 --- a/src/libstd/sys_common/thread.rs +++ b/src/libstd/sys_common/thread.rs @@ -1,8 +1,8 @@ -use boxed::FnBox; -use env; -use sync::atomic::{self, Ordering}; -use sys::stack_overflow; -use sys::thread as imp; +use crate::boxed::FnBox; +use crate::env; +use crate::sync::atomic::{self, Ordering}; +use crate::sys::stack_overflow; +use crate::sys::thread as imp; #[allow(dead_code)] pub unsafe fn start_thread(main: *mut u8) { diff --git a/src/libstd/sys_common/thread_info.rs b/src/libstd/sys_common/thread_info.rs index b4bca72b09d1b..b3c21ec508a9e 100644 --- a/src/libstd/sys_common/thread_info.rs +++ b/src/libstd/sys_common/thread_info.rs @@ -1,8 +1,8 @@ #![allow(dead_code)] // stack_guard isn't used right now on all platforms -use cell::RefCell; -use sys::thread::guard::Guard; -use thread::Thread; +use crate::cell::RefCell; +use crate::sys::thread::guard::Guard; +use crate::thread::Thread; struct ThreadInfo { stack_guard: Option, diff --git a/src/libstd/sys_common/thread_local.rs b/src/libstd/sys_common/thread_local.rs index 874e58dcfeee0..bdf79002e906d 100644 --- a/src/libstd/sys_common/thread_local.rs +++ b/src/libstd/sys_common/thread_local.rs @@ -48,10 +48,10 @@ #![unstable(feature = "thread_local_internals", issue = "0")] #![allow(dead_code)] // sys isn't exported yet -use ptr; -use sync::atomic::{self, AtomicUsize, Ordering}; -use sys::thread_local as imp; -use sys_common::mutex::Mutex; +use crate::ptr; +use crate::sync::atomic::{self, AtomicUsize, Ordering}; +use crate::sys::thread_local as imp; +use crate::sys_common::mutex::Mutex; /// A type for TLS keys that are statically allocated. /// diff --git a/src/libstd/sys_common/util.rs b/src/libstd/sys_common/util.rs index 7dec22be97808..206443a673692 100644 --- a/src/libstd/sys_common/util.rs +++ b/src/libstd/sys_common/util.rs @@ -1,7 +1,7 @@ -use fmt; -use io::prelude::*; -use sys::stdio::panic_output; -use thread; +use crate::fmt; +use crate::io::prelude::*; +use crate::sys::stdio::panic_output; +use crate::thread; pub fn dumb_print(args: fmt::Arguments) { if let Some(mut out) = panic_output() { @@ -11,12 +11,12 @@ pub fn dumb_print(args: fmt::Arguments) { // Other platforms should use the appropriate platform-specific mechanism for // aborting the process. If no platform-specific mechanism is available, -// ::intrinsics::abort() may be used instead. The above implementations cover +// crate::intrinsics::abort() may be used instead. The above implementations cover // all targets currently supported by libstd. pub fn abort(args: fmt::Arguments) -> ! { dumb_print(format_args!("fatal runtime error: {}\n", args)); - unsafe { ::sys::abort_internal(); } + unsafe { crate::sys::abort_internal(); } } #[allow(dead_code)] // stack overflow detection not enabled on all platforms diff --git a/src/libstd/sys_common/wtf8.rs b/src/libstd/sys_common/wtf8.rs index 6d4594fe295ca..b15239e8d877e 100644 --- a/src/libstd/sys_common/wtf8.rs +++ b/src/libstd/sys_common/wtf8.rs @@ -17,18 +17,18 @@ use core::str::next_code_point; -use borrow::Cow; -use char; -use fmt; -use hash::{Hash, Hasher}; -use iter::FromIterator; -use mem; -use ops; -use rc::Rc; -use slice; -use str; -use sync::Arc; -use sys_common::AsInner; +use crate::borrow::Cow; +use crate::char; +use crate::fmt; +use crate::hash::{Hash, Hasher}; +use crate::iter::FromIterator; +use crate::mem; +use crate::ops; +use crate::rc::Rc; +use crate::slice; +use crate::str; +use crate::sync::Arc; +use crate::sys_common::AsInner; const UTF8_REPLACEMENT_CHARACTER: &str = "\u{FFFD}"; @@ -413,7 +413,7 @@ impl AsInner<[u8]> for Wtf8 { impl fmt::Debug for Wtf8 { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { fn write_str_escaped(f: &mut fmt::Formatter, s: &str) -> fmt::Result { - use fmt::Write; + use crate::fmt::Write; for c in s.chars().flat_map(|c| c.escape_debug()) { f.write_char(c)? } @@ -871,7 +871,7 @@ impl Wtf8 { #[cfg(test)] mod tests { - use borrow::Cow; + use crate::borrow::Cow; use super::*; #[test] diff --git a/src/libstd/tests/env.rs b/src/libstd/tests/env.rs index e985c3899af41..06fb5533afdd8 100644 --- a/src/libstd/tests/env.rs +++ b/src/libstd/tests/env.rs @@ -1,5 +1,3 @@ -extern crate rand; - use std::env::*; use std::ffi::{OsString, OsStr}; diff --git a/src/libstd/thread/local.rs b/src/libstd/thread/local.rs index 8207709e1f9f0..d1f53734d30e3 100644 --- a/src/libstd/thread/local.rs +++ b/src/libstd/thread/local.rs @@ -2,10 +2,10 @@ #![unstable(feature = "thread_local_internals", issue = "0")] -use cell::UnsafeCell; -use fmt; -use hint; -use mem; +use crate::cell::UnsafeCell; +use crate::fmt; +use crate::hint; +use crate::mem; /// A thread local storage key which owns its contents. /// @@ -310,14 +310,14 @@ impl LocalKey { #[doc(hidden)] #[cfg(all(target_arch = "wasm32", not(target_feature = "atomics")))] pub mod statik { - use cell::UnsafeCell; - use fmt; + use crate::cell::UnsafeCell; + use crate::fmt; pub struct Key { inner: UnsafeCell>, } - unsafe impl ::marker::Sync for Key { } + unsafe impl Sync for Key { } impl fmt::Debug for Key { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { @@ -341,11 +341,11 @@ pub mod statik { #[doc(hidden)] #[cfg(target_thread_local)] pub mod fast { - use cell::{Cell, UnsafeCell}; - use fmt; - use mem; - use ptr; - use sys::fast_thread_local::{register_dtor, requires_move_before_drop}; + use crate::cell::{Cell, UnsafeCell}; + use crate::fmt; + use crate::mem; + use crate::ptr; + use crate::sys::fast_thread_local::{register_dtor, requires_move_before_drop}; pub struct Key { inner: UnsafeCell>, @@ -412,11 +412,11 @@ pub mod fast { #[doc(hidden)] pub mod os { - use cell::{Cell, UnsafeCell}; - use fmt; - use marker; - use ptr; - use sys_common::thread_local::StaticKey as OsStaticKey; + use crate::cell::{Cell, UnsafeCell}; + use crate::fmt; + use crate::marker; + use crate::ptr; + use crate::sys_common::thread_local::StaticKey as OsStaticKey; pub struct Key { // OS-TLS key that we'll use to key off. @@ -430,7 +430,7 @@ pub mod os { } } - unsafe impl ::marker::Sync for Key { } + unsafe impl Sync for Key { } struct Value { key: &'static Key, @@ -484,9 +484,9 @@ pub mod os { #[cfg(all(test, not(target_os = "emscripten")))] mod tests { - use sync::mpsc::{channel, Sender}; - use cell::{Cell, UnsafeCell}; - use thread; + use crate::sync::mpsc::{channel, Sender}; + use crate::cell::{Cell, UnsafeCell}; + use crate::thread; struct Foo(Sender<()>); @@ -632,8 +632,8 @@ mod tests { #[cfg(test)] mod dynamic_tests { - use cell::RefCell; - use collections::HashMap; + use crate::cell::RefCell; + use crate::collections::HashMap; #[test] fn smoke() { diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index 438ea3aa3f6a3..08f0aa2f0d206 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -156,25 +156,25 @@ #![stable(feature = "rust1", since = "1.0.0")] -use any::Any; -use boxed::FnBox; -use cell::UnsafeCell; -use ffi::{CStr, CString}; -use fmt; -use io; -use mem; -use panic; -use panicking; -use str; -use sync::{Mutex, Condvar, Arc}; -use sync::atomic::AtomicUsize; -use sync::atomic::Ordering::SeqCst; -use sys::thread as imp; -use sys_common::mutex; -use sys_common::thread_info; -use sys_common::thread; -use sys_common::{AsInner, IntoInner}; -use time::Duration; +use crate::any::Any; +use crate::boxed::FnBox; +use crate::cell::UnsafeCell; +use crate::ffi::{CStr, CString}; +use crate::fmt; +use crate::io; +use crate::mem; +use crate::panic; +use crate::panicking; +use crate::str; +use crate::sync::{Mutex, Condvar, Arc}; +use crate::sync::atomic::AtomicUsize; +use crate::sync::atomic::Ordering::SeqCst; +use crate::sys::thread as imp; +use crate::sys_common::mutex; +use crate::sys_common::thread_info; +use crate::sys_common::thread; +use crate::sys_common::{AsInner, IntoInner}; +use crate::time::Duration; //////////////////////////////////////////////////////////////////////////////// // Thread-local storage @@ -466,7 +466,7 @@ impl Builder { thread_info::set(imp::guard::current(), their_thread); #[cfg(feature = "backtrace")] let try_result = panic::catch_unwind(panic::AssertUnwindSafe(|| { - ::sys_common::backtrace::__rust_begin_short_backtrace(f) + crate::sys_common::backtrace::__rust_begin_short_backtrace(f) })); #[cfg(not(feature = "backtrace"))] let try_result = panic::catch_unwind(panic::AssertUnwindSafe(f)); @@ -1051,7 +1051,7 @@ impl ThreadId { // If we somehow use up all our bits, panic so that we're not // covering up subtle bugs of IDs being reused. - if COUNTER == ::u64::MAX { + if COUNTER == crate::u64::MAX { panic!("failed to generate unique thread ID: bitspace exhausted"); } @@ -1290,7 +1290,7 @@ impl fmt::Debug for Thread { /// /// [`Result`]: ../../std/result/enum.Result.html #[stable(feature = "rust1", since = "1.0.0")] -pub type Result = ::result::Result>; +pub type Result = crate::result::Result>; // This packet is used to communicate the return value between the child thread // and the parent thread. Memory is shared through the `Arc` within and there's @@ -1482,13 +1482,13 @@ fn _assert_sync_and_send() { #[cfg(all(test, not(target_os = "emscripten")))] mod tests { - use any::Any; - use sync::mpsc::{channel, Sender}; - use result; - use super::{Builder}; - use thread; - use time::Duration; - use u32; + use super::Builder; + use crate::any::Any; + use crate::sync::mpsc::{channel, Sender}; + use crate::result; + use crate::thread; + use crate::time::Duration; + use crate::u32; // !!! These tests are dangerous. If something is buggy, they will hang, !!! // !!! instead of exiting cleanly. This might wedge the buildbots. !!! diff --git a/src/libstd/time.rs b/src/libstd/time.rs index e1f5e1fcb938d..6d7093ac33ea7 100644 --- a/src/libstd/time.rs +++ b/src/libstd/time.rs @@ -12,13 +12,13 @@ #![stable(feature = "time", since = "1.3.0")] -use cmp; -use error::Error; -use fmt; -use ops::{Add, Sub, AddAssign, SubAssign}; -use sys::time; -use sys_common::FromInner; -use sys_common::mutex::Mutex; +use crate::cmp; +use crate::error::Error; +use crate::fmt; +use crate::ops::{Add, Sub, AddAssign, SubAssign}; +use crate::sys::time; +use crate::sys_common::FromInner; +use crate::sys_common::mutex::Mutex; #[stable(feature = "time", since = "1.3.0")] pub use core::time::Duration; @@ -713,7 +713,7 @@ mod tests { assert_almost_eq!(a.checked_sub(second).unwrap().checked_add(second).unwrap(), a); // A difference of 80 and 800 years cannot fit inside a 32-bit time_t - if !(cfg!(unix) && ::mem::size_of::<::libc::time_t>() <= 4) { + if !(cfg!(unix) && crate::mem::size_of::() <= 4) { let eighty_years = second * 60 * 60 * 24 * 365 * 80; assert_almost_eq!(a - eighty_years + eighty_years, a); assert_almost_eq!(a - (eighty_years * 10) + (eighty_years * 10), a); diff --git a/src/test/ui/hygiene/no_implicit_prelude.rs b/src/test/ui/hygiene/no_implicit_prelude.rs index 20da78f08dd26..1cd05f4d44c5e 100644 --- a/src/test/ui/hygiene/no_implicit_prelude.rs +++ b/src/test/ui/hygiene/no_implicit_prelude.rs @@ -13,7 +13,7 @@ mod bar { } fn f() { ::foo::m!(); - println!(); // OK on 2015 edition (at least for now) + println!(); //~ ERROR cannot find macro `print!` in this scope } } diff --git a/src/test/ui/hygiene/no_implicit_prelude.stderr b/src/test/ui/hygiene/no_implicit_prelude.stderr index 7c9404cee2b8f..b1de7700edb3c 100644 --- a/src/test/ui/hygiene/no_implicit_prelude.stderr +++ b/src/test/ui/hygiene/no_implicit_prelude.stderr @@ -7,6 +7,15 @@ LL | fn f() { ::bar::m!(); } LL | Vec::new(); //~ ERROR failed to resolve | ^^^ use of undeclared type or module `Vec` +error: cannot find macro `print!` in this scope + --> $DIR/no_implicit_prelude.rs:16:9 + | +LL | println!(); //~ ERROR cannot find macro `print!` in this scope + | ^^^^^^^^^^^ + | + = help: have you added the `#[macro_use]` on the module/import? + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + error[E0599]: no method named `clone` found for type `()` in the current scope --> $DIR/no_implicit_prelude.rs:12:12 | @@ -20,7 +29,7 @@ LL | ().clone() //~ ERROR no method named `clone` found = note: the following trait is implemented but not in scope, perhaps add a `use` for it: `use std::clone::Clone;` -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors Some errors occurred: E0433, E0599. For more information about an error, try `rustc --explain E0433`. diff --git a/src/test/ui/tag-that-dare-not-speak-its-name.rs b/src/test/ui/tag-that-dare-not-speak-its-name.rs index 0a7f405746c88..9f47b2e9b9f41 100644 --- a/src/test/ui/tag-that-dare-not-speak-its-name.rs +++ b/src/test/ui/tag-that-dare-not-speak-its-name.rs @@ -1,10 +1,9 @@ // Issue #876 -#![no_implicit_prelude] use std::vec::Vec; fn last(v: Vec<&T> ) -> std::option::Option { - panic!(); + ::std::panic!(); } fn main() { diff --git a/src/test/ui/tag-that-dare-not-speak-its-name.stderr b/src/test/ui/tag-that-dare-not-speak-its-name.stderr index a0d6b0007d7d9..23e3d66526215 100644 --- a/src/test/ui/tag-that-dare-not-speak-its-name.stderr +++ b/src/test/ui/tag-that-dare-not-speak-its-name.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/tag-that-dare-not-speak-its-name.rs:12:20 + --> $DIR/tag-that-dare-not-speak-its-name.rs:11:20 | LL | let x : char = last(y); | ^^^^^^^ expected char, found enum `std::option::Option`