Skip to content

Commit 190feb6

Browse files
committed
Auto merge of #58208 - taiki-e:libstd-2018, r=Centril
libstd => 2018 Transitions `libstd` to Rust 2018; cc #58099 r? @Centril
2 parents 7e001e5 + aad9e29 commit 190feb6

File tree

291 files changed

+2030
-2060
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

291 files changed

+2030
-2060
lines changed

src/libstd/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ build = "build.rs"
66
license = "MIT/Apache-2.0"
77
repository = "https://github.com/rust-lang/rust.git"
88
description = "The Rust Standard Library"
9+
edition = "2018"
910

1011
[lib]
1112
name = "std"

src/libstd/alloc.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@
6464
use core::sync::atomic::{AtomicPtr, Ordering};
6565
use core::{mem, ptr};
6666
use core::ptr::NonNull;
67-
use sys_common::util::dumb_print;
67+
68+
use crate::sys_common::util::dumb_print;
6869

6970
#[stable(feature = "alloc_module", since = "1.28.0")]
7071
#[doc(inline)]
@@ -208,7 +209,7 @@ pub fn rust_oom(layout: Layout) -> ! {
208209
unsafe { mem::transmute(hook) }
209210
};
210211
hook(layout);
211-
unsafe { ::sys::abort_internal(); }
212+
unsafe { crate::sys::abort_internal(); }
212213
}
213214

214215
#[cfg(not(test))]

src/libstd/build.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#![deny(warnings)]
22

3-
extern crate cc;
4-
53
use std::env;
64

75
fn main() {

src/libstd/collections/hash/bench.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#![cfg(test)]
22

3-
extern crate test;
4-
5-
use self::test::Bencher;
3+
use test::Bencher;
64

75
#[bench]
86
fn new_drop(b: &mut Bencher) {

src/libstd/collections/hash/map.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
use self::Entry::*;
22
use self::VacantEntryState::*;
33

4-
use intrinsics::unlikely;
5-
use collections::CollectionAllocErr;
6-
use cell::Cell;
7-
use borrow::Borrow;
8-
use cmp::max;
9-
use fmt::{self, Debug};
4+
use crate::intrinsics::unlikely;
5+
use crate::collections::CollectionAllocErr;
6+
use crate::cell::Cell;
7+
use crate::borrow::Borrow;
8+
use crate::cmp::max;
9+
use crate::fmt::{self, Debug};
1010
#[allow(deprecated)]
11-
use hash::{Hash, Hasher, BuildHasher, SipHasher13};
12-
use iter::{FromIterator, FusedIterator};
13-
use mem::{self, replace};
14-
use ops::{Deref, DerefMut, Index};
15-
use sys;
11+
use crate::hash::{Hash, Hasher, BuildHasher, SipHasher13};
12+
use crate::iter::{FromIterator, FusedIterator};
13+
use crate::mem::{self, replace};
14+
use crate::ops::{Deref, DerefMut, Index};
15+
use crate::sys;
1616

1717
use super::table::{self, Bucket, EmptyBucket, Fallibility, FullBucket, FullBucketMut, RawTable,
1818
SafeHash};
@@ -3328,7 +3328,7 @@ mod test_map {
33283328
use super::HashMap;
33293329
use super::Entry::{Occupied, Vacant};
33303330
use super::RandomState;
3331-
use cell::RefCell;
3331+
use crate::cell::RefCell;
33323332
use rand::{thread_rng, Rng};
33333333
use realstd::collections::CollectionAllocErr::*;
33343334
use realstd::mem::size_of;

src/libstd/collections/hash/set.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
use borrow::Borrow;
2-
use fmt;
3-
use hash::{Hash, BuildHasher};
4-
use iter::{Chain, FromIterator, FusedIterator};
5-
use ops::{BitOr, BitAnd, BitXor, Sub};
1+
use crate::borrow::Borrow;
2+
use crate::fmt;
3+
use crate::hash::{Hash, BuildHasher};
4+
use crate::iter::{Chain, FromIterator, FusedIterator};
5+
use crate::ops::{BitOr, BitAnd, BitXor, Sub};
66

77
use super::Recover;
88
use super::map::{self, HashMap, Keys, RandomState};
@@ -1751,7 +1751,7 @@ mod test_set {
17511751

17521752
#[test]
17531753
fn test_replace() {
1754-
use hash;
1754+
use crate::hash;
17551755

17561756
#[derive(Debug)]
17571757
struct Foo(&'static str, i32);

src/libstd/collections/hash/table.rs

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
use alloc::{Global, Alloc, Layout, LayoutErr, handle_alloc_error};
2-
use collections::CollectionAllocErr;
3-
use hash::{BuildHasher, Hash, Hasher};
4-
use marker;
5-
use mem::{size_of, needs_drop};
6-
use mem;
7-
use ops::{Deref, DerefMut};
8-
use ptr::{self, Unique, NonNull};
9-
use hint;
1+
use crate::alloc::{Global, Alloc, Layout, LayoutErr, handle_alloc_error};
2+
use crate::collections::CollectionAllocErr;
3+
use crate::hash::{BuildHasher, Hash, Hasher};
4+
use crate::marker;
5+
use crate::mem::{self, size_of, needs_drop};
6+
use crate::ops::{Deref, DerefMut};
7+
use crate::ptr::{self, Unique, NonNull};
8+
use crate::hint;
109

1110
use self::BucketState::*;
1211

src/libstd/collections/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@
412412
#[stable(feature = "rust1", since = "1.0.0")]
413413
#[rustc_deprecated(reason = "moved to `std::ops::Bound`", since = "1.26.0")]
414414
#[doc(hidden)]
415-
pub use ops::Bound;
415+
pub use crate::ops::Bound;
416416
#[stable(feature = "rust1", since = "1.0.0")]
417417
pub use alloc_crate::collections::{BinaryHeap, BTreeMap, BTreeSet};
418418
#[stable(feature = "rust1", since = "1.0.0")]

src/libstd/env.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
1414
#![stable(feature = "env", since = "1.0.0")]
1515

16-
use error::Error;
17-
use ffi::{OsStr, OsString};
18-
use fmt;
19-
use io;
20-
use path::{Path, PathBuf};
21-
use sys;
22-
use sys::os as os_imp;
16+
use crate::error::Error;
17+
use crate::ffi::{OsStr, OsString};
18+
use crate::fmt;
19+
use crate::io;
20+
use crate::path::{Path, PathBuf};
21+
use crate::sys;
22+
use crate::sys::os as os_imp;
2323

2424
/// Returns the current working directory as a [`PathBuf`].
2525
///
@@ -800,7 +800,7 @@ impl fmt::Debug for ArgsOs {
800800
/// Constants associated with the current target
801801
#[stable(feature = "env", since = "1.0.0")]
802802
pub mod consts {
803-
use sys::env::os;
803+
use crate::sys::env::os;
804804

805805
/// A string describing the architecture of the CPU that is currently
806806
/// in use.
@@ -972,7 +972,7 @@ mod arch {
972972
mod tests {
973973
use super::*;
974974

975-
use path::Path;
975+
use crate::path::Path;
976976

977977
#[test]
978978
#[cfg_attr(target_os = "emscripten", ignore)]
@@ -995,7 +995,7 @@ mod tests {
995995
#[test]
996996
#[cfg(windows)]
997997
fn split_paths_windows() {
998-
use path::PathBuf;
998+
use crate::path::PathBuf;
999999

10001000
fn check_parse(unparsed: &str, parsed: &[&str]) -> bool {
10011001
split_paths(unparsed).collect::<Vec<_>>() ==
@@ -1017,7 +1017,7 @@ mod tests {
10171017
#[test]
10181018
#[cfg(unix)]
10191019
fn split_paths_unix() {
1020-
use path::PathBuf;
1020+
use crate::path::PathBuf;
10211021

10221022
fn check_parse(unparsed: &str, parsed: &[&str]) -> bool {
10231023
split_paths(unparsed).collect::<Vec<_>>() ==
@@ -1034,7 +1034,7 @@ mod tests {
10341034
#[test]
10351035
#[cfg(unix)]
10361036
fn join_paths_unix() {
1037-
use ffi::OsStr;
1037+
use crate::ffi::OsStr;
10381038

10391039
fn test_eq(input: &[&str], output: &str) -> bool {
10401040
&*join_paths(input.iter().cloned()).unwrap() ==
@@ -1052,7 +1052,7 @@ mod tests {
10521052
#[test]
10531053
#[cfg(windows)]
10541054
fn join_paths_windows() {
1055-
use ffi::OsStr;
1055+
use crate::ffi::OsStr;
10561056

10571057
fn test_eq(input: &[&str], output: &str) -> bool {
10581058
&*join_paths(input.iter().cloned()).unwrap() ==

src/libstd/error.rs

+12-11
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,18 @@
1313
// coherence challenge (e.g., specialization, neg impls, etc) we can
1414
// reconsider what crate these items belong in.
1515

16-
use alloc::{AllocErr, LayoutErr, CannotReallocInPlace};
17-
use any::TypeId;
18-
use borrow::Cow;
19-
use cell;
20-
use char;
2116
use core::array;
22-
use fmt::{self, Debug, Display};
23-
use mem::transmute;
24-
use num;
25-
use str;
26-
use string;
17+
18+
use crate::alloc::{AllocErr, LayoutErr, CannotReallocInPlace};
19+
use crate::any::TypeId;
20+
use crate::borrow::Cow;
21+
use crate::cell;
22+
use crate::char;
23+
use crate::fmt::{self, Debug, Display};
24+
use crate::mem::transmute;
25+
use crate::num;
26+
use crate::str;
27+
use crate::string;
2728

2829
/// `Error` is a trait representing the basic expectations for error values,
2930
/// i.e., values of type `E` in [`Result<T, E>`]. Errors must describe
@@ -852,7 +853,7 @@ impl dyn Error + Send + Sync {
852853
#[cfg(test)]
853854
mod tests {
854855
use super::Error;
855-
use fmt;
856+
use crate::fmt;
856857

857858
#[derive(Debug, PartialEq)]
858859
struct A;

src/libstd/f32.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
#![allow(missing_docs)]
1010

1111
#[cfg(not(test))]
12-
use intrinsics;
12+
use crate::intrinsics;
1313
#[cfg(not(test))]
14-
use sys::cmath;
14+
use crate::sys::cmath;
1515

1616
#[stable(feature = "rust1", since = "1.0.0")]
1717
pub use core::f32::{RADIX, MANTISSA_DIGITS, DIGITS, EPSILON};
@@ -488,7 +488,7 @@ impl f32 {
488488
#[inline]
489489
pub fn log2(self) -> f32 {
490490
#[cfg(target_os = "android")]
491-
return ::sys::android::log2f32(self);
491+
return crate::sys::android::log2f32(self);
492492
#[cfg(not(target_os = "android"))]
493493
return unsafe { intrinsics::log2f32(self) };
494494
}
@@ -932,7 +932,7 @@ impl f32 {
932932
#[inline]
933933
pub fn acosh(self) -> f32 {
934934
match self {
935-
x if x < 1.0 => ::f32::NAN,
935+
x if x < 1.0 => crate::f32::NAN,
936936
x => (x + ((x * x) - 1.0).sqrt()).ln(),
937937
}
938938
}
@@ -960,10 +960,10 @@ impl f32 {
960960

961961
#[cfg(test)]
962962
mod tests {
963-
use f32;
964-
use f32::*;
965-
use num::*;
966-
use num::FpCategory as Fp;
963+
use crate::f32;
964+
use crate::f32::*;
965+
use crate::num::*;
966+
use crate::num::FpCategory as Fp;
967967

968968
#[test]
969969
fn test_num_f32() {

src/libstd/f64.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
#![allow(missing_docs)]
1010

1111
#[cfg(not(test))]
12-
use intrinsics;
12+
use crate::intrinsics;
1313
#[cfg(not(test))]
14-
use sys::cmath;
14+
use crate::sys::cmath;
1515

1616
#[stable(feature = "rust1", since = "1.0.0")]
1717
pub use core::f64::{RADIX, MANTISSA_DIGITS, DIGITS, EPSILON};
@@ -436,7 +436,7 @@ impl f64 {
436436
pub fn log2(self) -> f64 {
437437
self.log_wrapper(|n| {
438438
#[cfg(target_os = "android")]
439-
return ::sys::android::log2f64(n);
439+
return crate::sys::android::log2f64(n);
440440
#[cfg(not(target_os = "android"))]
441441
return unsafe { intrinsics::log2f64(n) };
442442
})
@@ -906,10 +906,10 @@ impl f64 {
906906

907907
#[cfg(test)]
908908
mod tests {
909-
use f64;
910-
use f64::*;
911-
use num::*;
912-
use num::FpCategory as Fp;
909+
use crate::f64;
910+
use crate::f64::*;
911+
use crate::num::*;
912+
use crate::num::FpCategory as Fp;
913913

914914
#[test]
915915
fn test_num_f64() {

src/libstd/ffi/c_str.rs

+22-22
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
use ascii;
2-
use borrow::{Cow, Borrow};
3-
use cmp::Ordering;
4-
use error::Error;
5-
use fmt::{self, Write};
6-
use io;
7-
use mem;
8-
use memchr;
9-
use ops;
10-
use os::raw::c_char;
11-
use ptr;
12-
use rc::Rc;
13-
use slice;
14-
use str::{self, Utf8Error};
15-
use sync::Arc;
16-
use sys;
1+
use crate::ascii;
2+
use crate::borrow::{Cow, Borrow};
3+
use crate::cmp::Ordering;
4+
use crate::error::Error;
5+
use crate::fmt::{self, Write};
6+
use crate::io;
7+
use crate::mem;
8+
use crate::memchr;
9+
use crate::ops;
10+
use crate::os::raw::c_char;
11+
use crate::ptr;
12+
use crate::rc::Rc;
13+
use crate::slice;
14+
use crate::str::{self, Utf8Error};
15+
use crate::sync::Arc;
16+
use crate::sys;
1717

1818
/// A type representing an owned, C-compatible, nul-terminated string with no nul bytes in the
1919
/// middle.
@@ -1303,12 +1303,12 @@ impl AsRef<CStr> for CString {
13031303
#[cfg(test)]
13041304
mod tests {
13051305
use super::*;
1306-
use os::raw::c_char;
1307-
use borrow::Cow::{Borrowed, Owned};
1308-
use hash::{Hash, Hasher};
1309-
use collections::hash_map::DefaultHasher;
1310-
use rc::Rc;
1311-
use sync::Arc;
1306+
use crate::os::raw::c_char;
1307+
use crate::borrow::Cow::{Borrowed, Owned};
1308+
use crate::hash::{Hash, Hasher};
1309+
use crate::collections::hash_map::DefaultHasher;
1310+
use crate::rc::Rc;
1311+
use crate::sync::Arc;
13121312

13131313
#[test]
13141314
fn c_to_rust() {

0 commit comments

Comments
 (0)