Skip to content

Commit 5d20ff4

Browse files
committed
Auto merge of #58702 - taiki-e:libcore-2018, r=Centril
libcore => 2018 Transitions `libcore` to Rust 2018; cc #58099 r? @Centril
2 parents d6f513e + e28bce7 commit 5d20ff4

Some content is hidden

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

80 files changed

+343
-333
lines changed

src/libcore/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ name = "core"
44
version = "0.0.0"
55
autotests = false
66
autobenches = false
7+
edition = "2018"
78

89
[lib]
910
name = "core"

src/libcore/alloc.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
33
#![stable(feature = "alloc_module", since = "1.28.0")]
44

5-
use cmp;
6-
use fmt;
7-
use mem;
8-
use usize;
9-
use ptr::{self, NonNull};
10-
use num::NonZeroUsize;
5+
use crate::cmp;
6+
use crate::fmt;
7+
use crate::mem;
8+
use crate::usize;
9+
use crate::ptr::{self, NonNull};
10+
use crate::num::NonZeroUsize;
1111

1212
/// Represents the combination of a starting address and
1313
/// a total capacity of the returned block.

src/libcore/any.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@
6161
6262
#![stable(feature = "rust1", since = "1.0.0")]
6363

64-
use fmt;
65-
use intrinsics;
64+
use crate::fmt;
65+
use crate::intrinsics;
6666

6767
///////////////////////////////////////////////////////////////////////////////
6868
// Any trait

src/libcore/array.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
integer constants",
1010
issue = "27778")]
1111

12-
use borrow::{Borrow, BorrowMut};
13-
use cmp::Ordering;
14-
use convert::TryFrom;
15-
use fmt;
16-
use hash::{Hash, self};
17-
use marker::Unsize;
18-
use slice::{Iter, IterMut};
12+
use crate::borrow::{Borrow, BorrowMut};
13+
use crate::cmp::Ordering;
14+
use crate::convert::TryFrom;
15+
use crate::fmt;
16+
use crate::hash::{Hash, self};
17+
use crate::marker::Unsize;
18+
use crate::slice::{Iter, IterMut};
1919

2020
/// Utility trait implemented only on arrays of fixed size
2121
///

src/libcore/ascii.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
1212
#![stable(feature = "core_ascii", since = "1.26.0")]
1313

14-
use fmt;
15-
use ops::Range;
16-
use iter::FusedIterator;
14+
use crate::fmt;
15+
use crate::ops::Range;
16+
use crate::iter::FusedIterator;
1717

1818
/// An iterator over the escaped version of a byte.
1919
///

src/libcore/benches/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#![feature(flt2dec)]
22
#![feature(test)]
33

4-
extern crate core;
54
extern crate test;
65

76
mod any;

src/libcore/cell.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -186,12 +186,12 @@
186186
187187
#![stable(feature = "rust1", since = "1.0.0")]
188188

189-
use cmp::Ordering;
190-
use fmt::{self, Debug, Display};
191-
use marker::Unsize;
192-
use mem;
193-
use ops::{Deref, DerefMut, CoerceUnsized};
194-
use ptr;
189+
use crate::cmp::Ordering;
190+
use crate::fmt::{self, Debug, Display};
191+
use crate::marker::Unsize;
192+
use crate::mem;
193+
use crate::ops::{Deref, DerefMut, CoerceUnsized};
194+
use crate::ptr;
195195

196196
/// A mutable memory location.
197197
///

src/libcore/char/convert.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
//! Character conversions.
22
3-
use convert::TryFrom;
4-
use fmt;
5-
use mem::transmute;
6-
use str::FromStr;
3+
use crate::convert::TryFrom;
4+
use crate::fmt;
5+
use crate::mem::transmute;
6+
use crate::str::FromStr;
7+
78
use super::MAX;
89

910
/// Converts a `u32` to a `char`.

src/libcore/char/decode.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! UTF-8 and UTF-16 decoding iterators
22
3-
use fmt;
3+
use crate::fmt;
4+
45
use super::from_u32_unchecked;
56

67
/// An iterator that decodes UTF-16 encoded code points from an iterator of `u16`s.

src/libcore/char/methods.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
//! impl char {}
22
3-
use slice;
4-
use str::from_utf8_unchecked_mut;
3+
use crate::slice;
4+
use crate::str::from_utf8_unchecked_mut;
5+
use crate::unicode::printable::is_printable;
6+
use crate::unicode::tables::{conversions, derived_property, general_category, property};
7+
58
use super::*;
6-
use unicode::printable::is_printable;
7-
use unicode::tables::{conversions, derived_property, general_category, property};
89

910
#[lang = "char"]
1011
impl char {

src/libcore/char/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ pub use self::decode::{decode_utf16, DecodeUtf16, DecodeUtf16Error};
3737

3838
// unstable re-exports
3939
#[unstable(feature = "unicode_version", issue = "49726")]
40-
pub use unicode::tables::UNICODE_VERSION;
40+
pub use crate::unicode::tables::UNICODE_VERSION;
4141
#[unstable(feature = "unicode_version", issue = "49726")]
42-
pub use unicode::version::UnicodeVersion;
42+
pub use crate::unicode::version::UnicodeVersion;
4343

44-
use fmt::{self, Write};
45-
use iter::FusedIterator;
44+
use crate::fmt::{self, Write};
45+
use crate::iter::FusedIterator;
4646

4747
// UTF-8 ranges and tags for encoding characters
4848
const TAG_CONT: u8 = 0b1000_0000;

src/libcore/clone.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,13 @@ pub trait Clone : Sized {
142142
#[unstable(feature = "derive_clone_copy",
143143
reason = "deriving hack, should not be public",
144144
issue = "0")]
145-
pub struct AssertParamIsClone<T: Clone + ?Sized> { _field: ::marker::PhantomData<T> }
145+
pub struct AssertParamIsClone<T: Clone + ?Sized> { _field: crate::marker::PhantomData<T> }
146146
#[doc(hidden)]
147147
#[allow(missing_debug_implementations)]
148148
#[unstable(feature = "derive_clone_copy",
149149
reason = "deriving hack, should not be public",
150150
issue = "0")]
151-
pub struct AssertParamIsCopy<T: Copy + ?Sized> { _field: ::marker::PhantomData<T> }
151+
pub struct AssertParamIsCopy<T: Copy + ?Sized> { _field: crate::marker::PhantomData<T> }
152152

153153
/// Implementations of `Clone` for primitive types.
154154
///

src/libcore/cmp.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ pub trait Eq: PartialEq<Self> {
265265
#[unstable(feature = "derive_eq",
266266
reason = "deriving hack, should not be public",
267267
issue = "0")]
268-
pub struct AssertParamIsEq<T: Eq + ?Sized> { _field: ::marker::PhantomData<T> }
268+
pub struct AssertParamIsEq<T: Eq + ?Sized> { _field: crate::marker::PhantomData<T> }
269269

270270
/// An `Ordering` is the result of a comparison between two values.
271271
///
@@ -884,7 +884,7 @@ pub fn max<T: Ord>(v1: T, v2: T) -> T {
884884

885885
// Implementation of PartialEq, Eq, PartialOrd and Ord for primitive types
886886
mod impls {
887-
use cmp::Ordering::{self, Less, Greater, Equal};
887+
use crate::cmp::Ordering::{self, Less, Greater, Equal};
888888

889889
macro_rules! partial_eq_impl {
890890
($($t:ty)*) => ($(

src/libcore/convert.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
4141
#![stable(feature = "rust1", since = "1.0.0")]
4242

43-
use fmt;
43+
use crate::fmt;
4444

4545
/// An identity function.
4646
///

src/libcore/ffi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
//! Utilities related to FFI bindings.
66
7-
use ::fmt;
7+
use crate::fmt;
88

99
/// Equivalent to C's `void` type when used as a [pointer].
1010
///

src/libcore/fmt/builders.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use fmt;
1+
use crate::fmt;
22

33
struct PadAdapter<'a> {
44
buf: &'a mut (dyn fmt::Write + 'a),

src/libcore/fmt/float.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
use fmt::{Formatter, Result, LowerExp, UpperExp, Display, Debug};
2-
use mem::MaybeUninit;
3-
use num::flt2dec;
1+
use crate::fmt::{Formatter, Result, LowerExp, UpperExp, Display, Debug};
2+
use crate::mem::MaybeUninit;
3+
use crate::num::flt2dec;
44

55
// Don't inline this so callers don't use the stack space this function
66
// requires unless they have to.

src/libcore/fmt/mod.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
33
#![stable(feature = "rust1", since = "1.0.0")]
44

5-
use cell::{UnsafeCell, Cell, RefCell, Ref, RefMut};
6-
use marker::PhantomData;
7-
use mem;
8-
use num::flt2dec;
9-
use ops::Deref;
10-
use result;
11-
use slice;
12-
use str;
5+
use crate::cell::{UnsafeCell, Cell, RefCell, Ref, RefMut};
6+
use crate::marker::PhantomData;
7+
use crate::mem;
8+
use crate::num::flt2dec;
9+
use crate::ops::Deref;
10+
use crate::result;
11+
use crate::slice;
12+
use crate::str;
1313

1414
mod float;
1515
mod num;

src/libcore/fmt/num.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
//! Integer and floating-point number formatting
22
33

4-
use fmt;
5-
use ops::{Div, Rem, Sub};
6-
use str;
7-
use slice;
8-
use ptr;
9-
use mem::MaybeUninit;
4+
use crate::fmt;
5+
use crate::ops::{Div, Rem, Sub};
6+
use crate::str;
7+
use crate::slice;
8+
use crate::ptr;
9+
use crate::mem::MaybeUninit;
1010

1111
#[doc(hidden)]
1212
trait Int: PartialEq + PartialOrd + Div<Output=Self> + Rem<Output=Self> +
@@ -196,7 +196,7 @@ macro_rules! impl_Display {
196196

197197
unsafe {
198198
// need at least 16 bits for the 4-characters-at-a-time to work.
199-
assert!(::mem::size_of::<$u>() >= 2);
199+
assert!(crate::mem::size_of::<$u>() >= 2);
200200

201201
// eagerly decode 4 characters at a time
202202
while n >= 10000 {

src/libcore/future/future.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
reason = "futures in libcore are unstable",
33
issue = "50547")]
44

5-
use marker::Unpin;
6-
use ops;
7-
use pin::Pin;
8-
use task::{Context, Poll};
5+
use crate::marker::Unpin;
6+
use crate::ops;
7+
use crate::pin::Pin;
8+
use crate::task::{Context, Poll};
99

1010
/// A future represents an asynchronous computation.
1111
///

src/libcore/hash/mod.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@
8181
8282
#![stable(feature = "rust1", since = "1.0.0")]
8383

84-
use fmt;
85-
use marker;
84+
use crate::fmt;
85+
use crate::marker;
8686

8787
#[stable(feature = "rust1", since = "1.0.0")]
8888
#[allow(deprecated)]
@@ -541,8 +541,9 @@ impl<H> Eq for BuildHasherDefault<H> {}
541541
//////////////////////////////////////////////////////////////////////////////
542542

543543
mod impls {
544-
use mem;
545-
use slice;
544+
use crate::mem;
545+
use crate::slice;
546+
546547
use super::*;
547548

548549
macro_rules! impl_write {

src/libcore/hash/sip.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
33
#![allow(deprecated)] // the types in this module are deprecated
44

5-
use marker::PhantomData;
6-
use ptr;
7-
use cmp;
8-
use mem;
5+
use crate::marker::PhantomData;
6+
use crate::ptr;
7+
use crate::cmp;
8+
use crate::mem;
99

1010
/// An implementation of SipHash 1-3.
1111
///
@@ -269,7 +269,7 @@ impl<S: Sip> super::Hasher for Hasher<S> {
269269
#[inline]
270270
fn write_usize(&mut self, i: usize) {
271271
let bytes = unsafe {
272-
::slice::from_raw_parts(&i as *const usize as *const u8, mem::size_of::<usize>())
272+
crate::slice::from_raw_parts(&i as *const usize as *const u8, mem::size_of::<usize>())
273273
};
274274
self.short_write(bytes);
275275
}

src/libcore/hint.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
//! Hints to compiler that affects how code should be emitted or optimized.
44
5-
use intrinsics;
5+
use crate::intrinsics;
66

77
/// Informs the compiler that this point in the code is not reachable, enabling
88
/// further optimizations.

src/libcore/internal_macros.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -81,24 +81,22 @@ macro_rules! forward_ref_op_assign {
8181
macro_rules! impl_fn_for_zst {
8282
($(
8383
$( #[$attr: meta] )*
84-
// FIXME: when libcore is in the 2018 edition, use `?` repetition in
85-
// $( <$( $li : lifetime ),+> )?
86-
struct $Name: ident impl$( <$( $lifetime : lifetime ),+> )* Fn =
84+
struct $Name: ident impl$( <$( $lifetime : lifetime ),+> )? Fn =
8785
|$( $arg: ident: $ArgTy: ty ),*| -> $ReturnTy: ty
8886
$body: block;
8987
)+) => {
9088
$(
9189
$( #[$attr] )*
9290
struct $Name;
9391

94-
impl $( <$( $lifetime ),+> )* Fn<($( $ArgTy, )*)> for $Name {
92+
impl $( <$( $lifetime ),+> )? Fn<($( $ArgTy, )*)> for $Name {
9593
#[inline]
9694
extern "rust-call" fn call(&self, ($( $arg, )*): ($( $ArgTy, )*)) -> $ReturnTy {
9795
$body
9896
}
9997
}
10098

101-
impl $( <$( $lifetime ),+> )* FnMut<($( $ArgTy, )*)> for $Name {
99+
impl $( <$( $lifetime ),+> )? FnMut<($( $ArgTy, )*)> for $Name {
102100
#[inline]
103101
extern "rust-call" fn call_mut(
104102
&mut self,
@@ -108,7 +106,7 @@ macro_rules! impl_fn_for_zst {
108106
}
109107
}
110108

111-
impl $( <$( $lifetime ),+> )* FnOnce<($( $ArgTy, )*)> for $Name {
109+
impl $( <$( $lifetime ),+> )? FnOnce<($( $ArgTy, )*)> for $Name {
112110
type Output = $ReturnTy;
113111

114112
#[inline]

0 commit comments

Comments
 (0)