Skip to content

Commit 21dae95

Browse files
committed
Auto merge of #49939 - kennytm:rollup, r=kennytm
Rollup of 14 pull requests Successful merges: #49908, #49876, #49916, #49951, #49465, #49922, #49866, #49915, #49886, #49913, #49852, #49958, #49871, #49864 Failed merges:
2 parents cfc3465 + 0e9d6f9 commit 21dae95

File tree

42 files changed

+369
-89
lines changed

Some content is hidden

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

42 files changed

+369
-89
lines changed

.travis.yml

+2
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ matrix:
176176
if: branch = auto
177177
- env: IMAGE=x86_64-gnu-distcheck
178178
if: branch = auto
179+
- env: IMAGE=mingw-check
180+
if: type = pull_request OR branch = auto
179181

180182
- stage: publish toolstate
181183
if: branch = master AND type = push

src/bootstrap/bin/rustc.rs

-3
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,6 @@ fn main() {
247247
// When running miri tests, we need to generate MIR for all libraries
248248
if env::var("TEST_MIRI").ok().map_or(false, |val| val == "true") {
249249
cmd.arg("-Zalways-encode-mir");
250-
if stage != "0" {
251-
cmd.arg("-Zmiri");
252-
}
253250
cmd.arg("-Zmir-emit-validate=1");
254251
}
255252

src/bootstrap/doc.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ impl Step for Test {
514514

515515
fn should_run(run: ShouldRun) -> ShouldRun {
516516
let builder = run.builder;
517-
run.krate("test").default_condition(builder.config.compiler_docs)
517+
run.krate("test").default_condition(builder.build.config.docs)
518518
}
519519

520520
fn make_run(run: RunConfig) {
@@ -557,6 +557,9 @@ impl Step for Test {
557557

558558
let mut cargo = builder.cargo(compiler, Mode::Libtest, target, "doc");
559559
compile::test_cargo(build, &compiler, target, &mut cargo);
560+
561+
cargo.arg("--no-deps").arg("-p").arg("test");
562+
560563
build.run(&mut cargo);
561564
build.cp_r(&my_out, &out);
562565
}

src/bootstrap/test.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ impl Step for RustdocTheme {
459459
}
460460

461461
fn run(self, builder: &Builder) {
462-
let rustdoc = builder.rustdoc(self.compiler.host);
462+
let rustdoc = builder.out.join("bootstrap/debug/rustdoc");
463463
let mut cmd = builder.tool_cmd(Tool::RustdocTheme);
464464
cmd.arg(rustdoc.to_str().unwrap())
465465
.arg(builder.src.join("src/librustdoc/html/static/themes").to_str().unwrap())
@@ -875,7 +875,7 @@ impl Step for Compiletest {
875875
if build.config.rust_debuginfo_tests {
876876
flags.push("-g".to_string());
877877
}
878-
flags.push("-Zmiri -Zunstable-options".to_string());
878+
flags.push("-Zunstable-options".to_string());
879879
flags.push(build.config.cmd.rustc_args().join(" "));
880880

881881
if let Some(linker) = build.linker(target) {

src/bootstrap/tool.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,8 @@ tool_extended!((self, builder),
564564
target: self.target,
565565
extra_features: Vec::new(),
566566
});
567-
if clippy.is_some() {
567+
let channel = &builder.config.channel;
568+
if clippy.is_some() && channel != "stable" && channel != "beta" {
568569
self.extra_features.push("clippy".to_owned());
569570
}
570571
builder.ensure(native::Openssl {

src/ci/docker/mingw-check/Dockerfile

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
FROM ubuntu:16.04
2+
3+
RUN apt-get update && apt-get install -y --no-install-recommends \
4+
g++ \
5+
make \
6+
file \
7+
curl \
8+
ca-certificates \
9+
python2.7 \
10+
git \
11+
cmake \
12+
sudo \
13+
gdb \
14+
xz-utils \
15+
libssl-dev \
16+
pkg-config \
17+
mingw-w64
18+
19+
COPY scripts/sccache.sh /scripts/
20+
RUN sh /scripts/sccache.sh
21+
22+
ENV SCRIPT python2.7 ../x.py check --target=i686-pc-windows-gnu --host=i686-pc-windows-gnu

src/doc/unstable-book/src/language-features/global-allocator.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ fn main() {
5555
```
5656

5757
And that's it! The `#[global_allocator]` attribute is applied to a `static`
58-
which implements the `Alloc` trait in the `std::heap` module. Note, though,
58+
which implements the `Alloc` trait in the `std::alloc` module. Note, though,
5959
that the implementation is defined for `&MyAllocator`, not just `MyAllocator`.
6060
You may wish, however, to also provide `Alloc for MyAllocator` for other use
6161
cases.

src/etc/generate-deriving-span-tests.py

+19-6
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
sample usage: src/etc/generate-deriving-span-tests.py
1919
"""
2020

21-
import sys, os, datetime, stat
21+
import sys, os, datetime, stat, re
2222

2323
TEST_DIR = os.path.abspath(
2424
os.path.join(os.path.dirname(__file__), '../test/compile-fail'))
@@ -87,16 +87,25 @@ def create_test_case(type, trait, super_traits, error_count):
8787
def write_file(name, string):
8888
test_file = os.path.join(TEST_DIR, 'derives-span-%s.rs' % name)
8989

90+
with open(test_file) as f:
91+
old_str = f.read()
92+
old_str_ignoring_date = re.sub(r'^// Copyright \d+',
93+
'// Copyright {year}'.format(year = YEAR), old_str)
94+
if old_str_ignoring_date == string:
95+
# if all we're doing is updating the copyright year, ignore it
96+
return 0
97+
9098
# set write permission if file exists, so it can be changed
9199
if os.path.exists(test_file):
92100
os.chmod(test_file, stat.S_IWUSR)
93101

94-
with open(test_file, 'wt') as f:
102+
with open(test_file, 'w') as f:
95103
f.write(string)
96104

97105
# mark file read-only
98106
os.chmod(test_file, stat.S_IRUSR|stat.S_IRGRP|stat.S_IROTH)
99107

108+
return 1
100109

101110

102111
ENUM = 1
@@ -120,11 +129,15 @@ def write_file(name, string):
120129
('Hash', [], 1)]:
121130
traits[trait] = (ALL, supers, errs)
122131

132+
files = 0
133+
123134
for (trait, (types, super_traits, error_count)) in traits.items():
124135
mk = lambda ty: create_test_case(ty, trait, super_traits, error_count)
125136
if types & ENUM:
126-
write_file(trait + '-enum', mk(ENUM_TUPLE))
127-
write_file(trait + '-enum-struct-variant', mk(ENUM_STRUCT))
137+
files += write_file(trait + '-enum', mk(ENUM_TUPLE))
138+
files += write_file(trait + '-enum-struct-variant', mk(ENUM_STRUCT))
128139
if types & STRUCT:
129-
write_file(trait + '-struct', mk(STRUCT_FIELDS))
130-
write_file(trait + '-tuple-struct', mk(STRUCT_TUPLE))
140+
files += write_file(trait + '-struct', mk(STRUCT_FIELDS))
141+
files += write_file(trait + '-tuple-struct', mk(STRUCT_TUPLE))
142+
143+
print('Generated {files} deriving span test{}.'.format('s' if files != 1 else '', files = files))

src/liballoc/boxed.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@
5555
5656
#![stable(feature = "rust1", since = "1.0.0")]
5757

58-
use raw_vec::RawVec;
59-
6058
use core::any::Any;
6159
use core::borrow;
6260
use core::cmp::Ordering;
@@ -68,6 +66,8 @@ use core::mem::{self, Pin};
6866
use core::ops::{CoerceUnsized, Deref, DerefMut, Generator, GeneratorState};
6967
use core::ptr::{self, NonNull, Unique};
7068
use core::convert::From;
69+
70+
use raw_vec::RawVec;
7171
use str::from_boxed_utf8_unchecked;
7272

7373
/// A pointer type for heap allocation.

src/liballoc/raw_vec.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,16 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use alloc::{Alloc, Layout, Global};
1211
use core::cmp;
1312
use core::mem;
1413
use core::ops::Drop;
1514
use core::ptr::{self, NonNull, Unique};
1615
use core::slice;
17-
use super::boxed::Box;
18-
use super::allocator::CollectionAllocErr;
19-
use super::allocator::CollectionAllocErr::*;
16+
17+
use alloc::{Alloc, Layout, Global};
18+
use alloc::CollectionAllocErr;
19+
use alloc::CollectionAllocErr::*;
20+
use boxed::Box;
2021

2122
/// A low-level utility for more ergonomically allocating, reallocating, and deallocating
2223
/// a buffer of memory on the heap without having to worry about all the corner cases

src/liballoc/str.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ use core::mem;
4646
use core::ptr;
4747
use core::iter::FusedIterator;
4848

49-
use vec_deque::VecDeque;
5049
use borrow::{Borrow, ToOwned};
50+
use boxed::Box;
51+
use slice::{SliceConcatExt, SliceIndex};
5152
use string::String;
5253
use vec::Vec;
53-
use slice::{SliceConcatExt, SliceIndex};
54-
use boxed::Box;
54+
use vec_deque::VecDeque;
5555

5656
#[stable(feature = "rust1", since = "1.0.0")]
5757
pub use core::str::{FromStr, Utf8Error};

src/liballoc/string.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ use core::ptr;
6666
use core::str::pattern::Pattern;
6767
use core::str::lossy;
6868

69+
use alloc::CollectionAllocErr;
6970
use borrow::{Cow, ToOwned};
71+
use boxed::Box;
7072
use str::{self, from_boxed_utf8_unchecked, FromStr, Utf8Error, Chars};
7173
use vec::Vec;
72-
use boxed::Box;
73-
use super::allocator::CollectionAllocErr;
7474

7575
/// A UTF-8 encoded, growable string.
7676
///

src/liballoc/vec.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ use core::ptr;
8282
use core::ptr::NonNull;
8383
use core::slice;
8484

85+
use alloc::CollectionAllocErr;
8586
use borrow::ToOwned;
8687
use borrow::Cow;
8788
use boxed::Box;
8889
use raw_vec::RawVec;
89-
use super::allocator::CollectionAllocErr;
9090

9191
/// A contiguous growable array type, written `Vec<T>` but pronounced 'vector'.
9292
///

src/liballoc/vec_deque.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,9 @@ use core::slice;
3030
use core::hash::{Hash, Hasher};
3131
use core::cmp;
3232

33+
use alloc::CollectionAllocErr;
3334
use raw_vec::RawVec;
34-
35-
use super::allocator::CollectionAllocErr;
36-
use super::vec::Vec;
35+
use vec::Vec;
3736

3837
const INITIAL_CAPACITY: usize = 7; // 2^3 - 1
3938
const MINIMUM_CAPACITY: usize = 1; // 2 - 1

src/libcore/num/mod.rs

+89
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use convert::TryFrom;
1616
use fmt;
1717
use intrinsics;
18+
use mem;
1819
#[allow(deprecated)] use nonzero::NonZero;
1920
use ops;
2021
use str::FromStr;
@@ -1868,6 +1869,50 @@ $EndFeature, "
18681869
#[inline]
18691870
pub fn is_negative(self) -> bool { self < 0 }
18701871
}
1872+
1873+
/// Return the memory representation of this integer as a byte array.
1874+
///
1875+
/// The target platform’s native endianness is used.
1876+
/// Portable code likely wants to use this after [`to_be`] or [`to_le`].
1877+
///
1878+
/// [`to_be`]: #method.to_be
1879+
/// [`to_le`]: #method.to_le
1880+
///
1881+
/// # Examples
1882+
///
1883+
/// ```
1884+
/// #![feature(int_to_from_bytes)]
1885+
///
1886+
/// let bytes = i32::min_value().to_be().to_bytes();
1887+
/// assert_eq!(bytes, [0x80, 0, 0, 0]);
1888+
/// ```
1889+
#[unstable(feature = "int_to_from_bytes", issue = "49792")]
1890+
#[inline]
1891+
pub fn to_bytes(self) -> [u8; mem::size_of::<Self>()] {
1892+
unsafe { mem::transmute(self) }
1893+
}
1894+
1895+
/// Create an integer value from its memory representation as a byte array.
1896+
///
1897+
/// The target platform’s native endianness is used.
1898+
/// Portable code likely wants to use [`from_be`] or [`from_le`] after this.
1899+
///
1900+
/// [`from_be`]: #method.from_be
1901+
/// [`from_le`]: #method.from_le
1902+
///
1903+
/// # Examples
1904+
///
1905+
/// ```
1906+
/// #![feature(int_to_from_bytes)]
1907+
///
1908+
/// let int = i32::from_be(i32::from_bytes([0x80, 0, 0, 0]));
1909+
/// assert_eq!(int, i32::min_value());
1910+
/// ```
1911+
#[unstable(feature = "int_to_from_bytes", issue = "49792")]
1912+
#[inline]
1913+
pub fn from_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
1914+
unsafe { mem::transmute(bytes) }
1915+
}
18711916
}
18721917
}
18731918

@@ -3373,6 +3418,50 @@ $EndFeature, "
33733418
self.one_less_than_next_power_of_two().checked_add(1)
33743419
}
33753420
}
3421+
3422+
/// Return the memory representation of this integer as a byte array.
3423+
///
3424+
/// The target platform’s native endianness is used.
3425+
/// Portable code likely wants to use this after [`to_be`] or [`to_le`].
3426+
///
3427+
/// [`to_be`]: #method.to_be
3428+
/// [`to_le`]: #method.to_le
3429+
///
3430+
/// # Examples
3431+
///
3432+
/// ```
3433+
/// #![feature(int_to_from_bytes)]
3434+
///
3435+
/// let bytes = 0x1234_5678_u32.to_be().to_bytes();
3436+
/// assert_eq!(bytes, [0x12, 0x34, 0x56, 0x78]);
3437+
/// ```
3438+
#[unstable(feature = "int_to_from_bytes", issue = "49792")]
3439+
#[inline]
3440+
pub fn to_bytes(self) -> [u8; mem::size_of::<Self>()] {
3441+
unsafe { mem::transmute(self) }
3442+
}
3443+
3444+
/// Create an integer value from its memory representation as a byte array.
3445+
///
3446+
/// The target platform’s native endianness is used.
3447+
/// Portable code likely wants to use [`to_be`] or [`to_le`] after this.
3448+
///
3449+
/// [`to_be`]: #method.to_be
3450+
/// [`to_le`]: #method.to_le
3451+
///
3452+
/// # Examples
3453+
///
3454+
/// ```
3455+
/// #![feature(int_to_from_bytes)]
3456+
///
3457+
/// let int = u32::from_be(u32::from_bytes([0x12, 0x34, 0x56, 0x78]));
3458+
/// assert_eq!(int, 0x1234_5678_u32);
3459+
/// ```
3460+
#[unstable(feature = "int_to_from_bytes", issue = "49792")]
3461+
#[inline]
3462+
pub fn from_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
3463+
unsafe { mem::transmute(bytes) }
3464+
}
33763465
}
33773466
}
33783467

src/libcore/ops/bit.rs

+12-2
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,12 @@ macro_rules! bitxor_impl {
315315

316316
bitxor_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
317317

318-
/// The left shift operator `<<`.
318+
/// The left shift operator `<<`. Note that because this trait is implemented
319+
/// for all integer types with multiple right-hand-side types, Rust's type
320+
/// checker has special handling for `_ << _`, setting the result type for
321+
/// integer operations to the type of the left-hand-side operand. This means
322+
/// that though `a << b` and `a.shl(b)` are one and the same from an evaluation
323+
/// standpoint, they are different when it comes to type inference.
319324
///
320325
/// # Examples
321326
///
@@ -417,7 +422,12 @@ macro_rules! shl_impl_all {
417422

418423
shl_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 isize i128 }
419424

420-
/// The right shift operator `>>`.
425+
/// The right shift operator `>>`. Note that because this trait is implemented
426+
/// for all integer types with multiple right-hand-side types, Rust's type
427+
/// checker has special handling for `_ >> _`, setting the result type for
428+
/// integer operations to the type of the left-hand-side operand. This means
429+
/// that though `a >> b` and `a.shr(b)` are one and the same from an evaluation
430+
/// standpoint, they are different when it comes to type inference.
421431
///
422432
/// # Examples
423433
///

src/libcore/sync/atomic.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1425,8 +1425,8 @@ assert_eq!(foo.load(Ordering::SeqCst), 0b011110);
14251425

14261426
doc_comment! {
14271427
concat!("Fetches the value, and applies a function to it that returns an optional
1428-
new value. Returns a `Result` (`Ok(_)` if the function returned `Some(_)`, else `Err(_)`) of the
1429-
previous value.
1428+
new value. Returns a `Result` of `Ok(previous_value)` if the function returned `Some(_)`, else
1429+
`Err(previous_value)`.
14301430
14311431
Note: This may call the function multiple times if the value has been changed from other threads in
14321432
the meantime, as long as the function returns `Some(_)`, but the function will have been applied

0 commit comments

Comments
 (0)