Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 14 pull requests #49939

Merged
merged 32 commits into from
Apr 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
e719bb0
Add docs for the test crate with the std docs
ollie27 Mar 28, 2018
6d7cfd4
proc_macro: Avoid cached TokenStream more often
alexcrichton Apr 10, 2018
43301e5
add target features when extracting and running doctests
QuietMisdreavus Apr 11, 2018
34956c8
Don't inject clippy into rls on stable/beta
oli-obk Apr 11, 2018
0b393e0
Ignore copyright year when generating deriving span tests
varkor Apr 11, 2018
6f10146
Fix test failure in src/tools/rustdoc-themes when rust.rpath = false
chrisccoulson Apr 12, 2018
de34533
Add check builder for Windows to Travis
Mark-Simulacrum Apr 11, 2018
2f60341
improve Atomic*::fetch_update docs
llogiq Apr 12, 2018
3366032
add test for using target features in doctests
QuietMisdreavus Apr 11, 2018
35087fc
Remove -Z miri debugging option
f-bro Apr 13, 2018
b744e3d
[doc] note the special type inference handling for shifts
llogiq Apr 12, 2018
6c7d3a1
Update Cargo
matklad Apr 13, 2018
6234d41
Use InternedString rather than Name for RegionParameterDef
varkor Apr 12, 2018
d015945
Update RLS
matklad Apr 13, 2018
bd9ff84
Cleanup liballoc use statements
glandium Apr 13, 2018
fbbc990
Rollup merge of #49951 - matklad:update-cargo, r=nrc
kennytm Apr 14, 2018
95b7e6f
Rollup merge of #49852 - alexcrichton:fix-more-proc-macros, r=nrc
kennytm Apr 14, 2018
642bcc4
Rollup merge of #49866 - Mark-Simulacrum:pr-travis-windows, r=alexcri…
kennytm Apr 14, 2018
c22b4db
Rollup merge of #49876 - oli-obk:no_secret_clippy_on_stable_☹, r=nrc
kennytm Apr 14, 2018
15eb465
Rollup merge of #49465 - ollie27:rustbuild_test_docs, r=steveklabnik,…
kennytm Apr 14, 2018
070a771
Rollup merge of #49886 - varkor:generate-deriving-span-tests-usabilit…
kennytm Apr 14, 2018
44a71e2
Rollup merge of #49908 - chrisccoulson:fix-rustdoc-themes-test-withou…
kennytm Apr 14, 2018
6f629d3
Rollup merge of #49913 - varkor:RegionParameterDef-InternedString, r=…
kennytm Apr 14, 2018
d21433e
Rollup merge of #49915 - llogiq:doc-shift-types, r=joshtriplett
kennytm Apr 14, 2018
31906e4
Rollup merge of #49916 - llogiq:doc-atomic-fetch-update, r=kennytm
kennytm Apr 14, 2018
e681ba2
Rollup merge of #49922 - f-bro:zmiri, r=oli-obk
kennytm Apr 14, 2018
4c8e9b9
Replace remaining uses of deprecated std::heap with std::alloc
glandium Apr 14, 2018
e35499c
Replace remaining uses of deprecated Heap with Global
glandium Apr 14, 2018
4472991
Add to_bytes and from_bytes to primitive integers
SimonSapin Apr 10, 2018
9659f05
Rollup merge of #49958 - glandium:cleanup, r=SimonSapin
kennytm Apr 14, 2018
709ec40
Rollup merge of #49871 - SimonSapin:int-bytes, r=sfackler
kennytm Apr 14, 2018
0e9d6f9
Rollup merge of #49864 - QuietMisdreavus:doctest-target-features, r=G…
kennytm Apr 14, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ matrix:
if: branch = auto
- env: IMAGE=x86_64-gnu-distcheck
if: branch = auto
- env: IMAGE=mingw-check
if: type = pull_request OR branch = auto

- stage: publish toolstate
if: branch = master AND type = push
Expand Down
3 changes: 0 additions & 3 deletions src/bootstrap/bin/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,6 @@ fn main() {
// When running miri tests, we need to generate MIR for all libraries
if env::var("TEST_MIRI").ok().map_or(false, |val| val == "true") {
cmd.arg("-Zalways-encode-mir");
if stage != "0" {
cmd.arg("-Zmiri");
}
cmd.arg("-Zmir-emit-validate=1");
}

Expand Down
5 changes: 4 additions & 1 deletion src/bootstrap/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ impl Step for Test {

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

fn make_run(run: RunConfig) {
Expand Down Expand Up @@ -557,6 +557,9 @@ impl Step for Test {

let mut cargo = builder.cargo(compiler, Mode::Libtest, target, "doc");
compile::test_cargo(build, &compiler, target, &mut cargo);

cargo.arg("--no-deps").arg("-p").arg("test");

build.run(&mut cargo);
build.cp_r(&my_out, &out);
}
Expand Down
4 changes: 2 additions & 2 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ impl Step for RustdocTheme {
}

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

if let Some(linker) = build.linker(target) {
Expand Down
3 changes: 2 additions & 1 deletion src/bootstrap/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,8 @@ tool_extended!((self, builder),
target: self.target,
extra_features: Vec::new(),
});
if clippy.is_some() {
let channel = &builder.config.channel;
if clippy.is_some() && channel != "stable" && channel != "beta" {
self.extra_features.push("clippy".to_owned());
}
builder.ensure(native::Openssl {
Expand Down
22 changes: 22 additions & 0 deletions src/ci/docker/mingw-check/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM ubuntu:16.04

RUN apt-get update && apt-get install -y --no-install-recommends \
g++ \
make \
file \
curl \
ca-certificates \
python2.7 \
git \
cmake \
sudo \
gdb \
xz-utils \
libssl-dev \
pkg-config \
mingw-w64

COPY scripts/sccache.sh /scripts/
RUN sh /scripts/sccache.sh

ENV SCRIPT python2.7 ../x.py check --target=i686-pc-windows-gnu --host=i686-pc-windows-gnu
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fn main() {
```

And that's it! The `#[global_allocator]` attribute is applied to a `static`
which implements the `Alloc` trait in the `std::heap` module. Note, though,
which implements the `Alloc` trait in the `std::alloc` module. Note, though,
that the implementation is defined for `&MyAllocator`, not just `MyAllocator`.
You may wish, however, to also provide `Alloc for MyAllocator` for other use
cases.
Expand Down
25 changes: 19 additions & 6 deletions src/etc/generate-deriving-span-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
sample usage: src/etc/generate-deriving-span-tests.py
"""

import sys, os, datetime, stat
import sys, os, datetime, stat, re

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

with open(test_file) as f:
old_str = f.read()
old_str_ignoring_date = re.sub(r'^// Copyright \d+',
'// Copyright {year}'.format(year = YEAR), old_str)
if old_str_ignoring_date == string:
# if all we're doing is updating the copyright year, ignore it
return 0

# set write permission if file exists, so it can be changed
if os.path.exists(test_file):
os.chmod(test_file, stat.S_IWUSR)

with open(test_file, 'wt') as f:
with open(test_file, 'w') as f:
f.write(string)

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

return 1


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

files = 0

for (trait, (types, super_traits, error_count)) in traits.items():
mk = lambda ty: create_test_case(ty, trait, super_traits, error_count)
if types & ENUM:
write_file(trait + '-enum', mk(ENUM_TUPLE))
write_file(trait + '-enum-struct-variant', mk(ENUM_STRUCT))
files += write_file(trait + '-enum', mk(ENUM_TUPLE))
files += write_file(trait + '-enum-struct-variant', mk(ENUM_STRUCT))
if types & STRUCT:
write_file(trait + '-struct', mk(STRUCT_FIELDS))
write_file(trait + '-tuple-struct', mk(STRUCT_TUPLE))
files += write_file(trait + '-struct', mk(STRUCT_FIELDS))
files += write_file(trait + '-tuple-struct', mk(STRUCT_TUPLE))

print('Generated {files} deriving span test{}.'.format('s' if files != 1 else '', files = files))
4 changes: 2 additions & 2 deletions src/liballoc/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@

#![stable(feature = "rust1", since = "1.0.0")]

use raw_vec::RawVec;

use core::any::Any;
use core::borrow;
use core::cmp::Ordering;
Expand All @@ -68,6 +66,8 @@ use core::mem::{self, Pin};
use core::ops::{CoerceUnsized, Deref, DerefMut, Generator, GeneratorState};
use core::ptr::{self, NonNull, Unique};
use core::convert::From;

use raw_vec::RawVec;
use str::from_boxed_utf8_unchecked;

/// A pointer type for heap allocation.
Expand Down
9 changes: 5 additions & 4 deletions src/liballoc/raw_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use alloc::{Alloc, Layout, Global};
use core::cmp;
use core::mem;
use core::ops::Drop;
use core::ptr::{self, NonNull, Unique};
use core::slice;
use super::boxed::Box;
use super::allocator::CollectionAllocErr;
use super::allocator::CollectionAllocErr::*;

use alloc::{Alloc, Layout, Global};
use alloc::CollectionAllocErr;
use alloc::CollectionAllocErr::*;
use boxed::Box;

/// A low-level utility for more ergonomically allocating, reallocating, and deallocating
/// a buffer of memory on the heap without having to worry about all the corner cases
Expand Down
6 changes: 3 additions & 3 deletions src/liballoc/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ use core::mem;
use core::ptr;
use core::iter::FusedIterator;

use vec_deque::VecDeque;
use borrow::{Borrow, ToOwned};
use boxed::Box;
use slice::{SliceConcatExt, SliceIndex};
use string::String;
use vec::Vec;
use slice::{SliceConcatExt, SliceIndex};
use boxed::Box;
use vec_deque::VecDeque;

#[stable(feature = "rust1", since = "1.0.0")]
pub use core::str::{FromStr, Utf8Error};
Expand Down
4 changes: 2 additions & 2 deletions src/liballoc/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ use core::ptr;
use core::str::pattern::Pattern;
use core::str::lossy;

use alloc::CollectionAllocErr;
use borrow::{Cow, ToOwned};
use boxed::Box;
use str::{self, from_boxed_utf8_unchecked, FromStr, Utf8Error, Chars};
use vec::Vec;
use boxed::Box;
use super::allocator::CollectionAllocErr;

/// A UTF-8 encoded, growable string.
///
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ use core::ptr;
use core::ptr::NonNull;
use core::slice;

use alloc::CollectionAllocErr;
use borrow::ToOwned;
use borrow::Cow;
use boxed::Box;
use raw_vec::RawVec;
use super::allocator::CollectionAllocErr;

/// A contiguous growable array type, written `Vec<T>` but pronounced 'vector'.
///
Expand Down
5 changes: 2 additions & 3 deletions src/liballoc/vec_deque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,9 @@ use core::slice;
use core::hash::{Hash, Hasher};
use core::cmp;

use alloc::CollectionAllocErr;
use raw_vec::RawVec;

use super::allocator::CollectionAllocErr;
use super::vec::Vec;
use vec::Vec;

const INITIAL_CAPACITY: usize = 7; // 2^3 - 1
const MINIMUM_CAPACITY: usize = 1; // 2 - 1
Expand Down
89 changes: 89 additions & 0 deletions src/libcore/num/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use convert::TryFrom;
use fmt;
use intrinsics;
use mem;
#[allow(deprecated)] use nonzero::NonZero;
use ops;
use str::FromStr;
Expand Down Expand Up @@ -1868,6 +1869,50 @@ $EndFeature, "
#[inline]
pub fn is_negative(self) -> bool { self < 0 }
}

/// Return the memory representation of this integer as a byte array.
///
/// The target platform’s native endianness is used.
/// Portable code likely wants to use this after [`to_be`] or [`to_le`].
///
/// [`to_be`]: #method.to_be
/// [`to_le`]: #method.to_le
///
/// # Examples
///
/// ```
/// #![feature(int_to_from_bytes)]
///
/// let bytes = i32::min_value().to_be().to_bytes();
/// assert_eq!(bytes, [0x80, 0, 0, 0]);
/// ```
#[unstable(feature = "int_to_from_bytes", issue = "49792")]
#[inline]
pub fn to_bytes(self) -> [u8; mem::size_of::<Self>()] {
unsafe { mem::transmute(self) }
}

/// Create an integer value from its memory representation as a byte array.
///
/// The target platform’s native endianness is used.
/// Portable code likely wants to use [`from_be`] or [`from_le`] after this.
///
/// [`from_be`]: #method.from_be
/// [`from_le`]: #method.from_le
///
/// # Examples
///
/// ```
/// #![feature(int_to_from_bytes)]
///
/// let int = i32::from_be(i32::from_bytes([0x80, 0, 0, 0]));
/// assert_eq!(int, i32::min_value());
/// ```
#[unstable(feature = "int_to_from_bytes", issue = "49792")]
#[inline]
pub fn from_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
unsafe { mem::transmute(bytes) }
}
}
}

Expand Down Expand Up @@ -3373,6 +3418,50 @@ $EndFeature, "
self.one_less_than_next_power_of_two().checked_add(1)
}
}

/// Return the memory representation of this integer as a byte array.
///
/// The target platform’s native endianness is used.
/// Portable code likely wants to use this after [`to_be`] or [`to_le`].
///
/// [`to_be`]: #method.to_be
/// [`to_le`]: #method.to_le
///
/// # Examples
///
/// ```
/// #![feature(int_to_from_bytes)]
///
/// let bytes = 0x1234_5678_u32.to_be().to_bytes();
/// assert_eq!(bytes, [0x12, 0x34, 0x56, 0x78]);
/// ```
#[unstable(feature = "int_to_from_bytes", issue = "49792")]
#[inline]
pub fn to_bytes(self) -> [u8; mem::size_of::<Self>()] {
unsafe { mem::transmute(self) }
}

/// Create an integer value from its memory representation as a byte array.
///
/// The target platform’s native endianness is used.
/// Portable code likely wants to use [`to_be`] or [`to_le`] after this.
///
/// [`to_be`]: #method.to_be
/// [`to_le`]: #method.to_le
///
/// # Examples
///
/// ```
/// #![feature(int_to_from_bytes)]
///
/// let int = u32::from_be(u32::from_bytes([0x12, 0x34, 0x56, 0x78]));
/// assert_eq!(int, 0x1234_5678_u32);
/// ```
#[unstable(feature = "int_to_from_bytes", issue = "49792")]
#[inline]
pub fn from_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
unsafe { mem::transmute(bytes) }
}
}
}

Expand Down
14 changes: 12 additions & 2 deletions src/libcore/ops/bit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,12 @@ macro_rules! bitxor_impl {

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

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

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

/// The right shift operator `>>`.
/// The right shift operator `>>`. Note that because this trait is implemented
/// for all integer types with multiple right-hand-side types, Rust's type
/// checker has special handling for `_ >> _`, setting the result type for
/// integer operations to the type of the left-hand-side operand. This means
/// that though `a >> b` and `a.shr(b)` are one and the same from an evaluation
/// standpoint, they are different when it comes to type inference.
///
/// # Examples
///
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/sync/atomic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1425,8 +1425,8 @@ assert_eq!(foo.load(Ordering::SeqCst), 0b011110);

doc_comment! {
concat!("Fetches the value, and applies a function to it that returns an optional
new value. Returns a `Result` (`Ok(_)` if the function returned `Some(_)`, else `Err(_)`) of the
previous value.
new value. Returns a `Result` of `Ok(previous_value)` if the function returned `Some(_)`, else
`Err(previous_value)`.

Note: This may call the function multiple times if the value has been changed from other threads in
the meantime, as long as the function returns `Some(_)`, but the function will have been applied
Expand Down
Loading