Skip to content

Commit

Permalink
Auto merge of #39563 - frewsxcv:rollup, r=frewsxcv
Browse files Browse the repository at this point in the history
Rollup of 19 pull requests

- Successful merges: #38518, #38921, #38959, #38983, #39009, #39107, #39193, #39289, #39312, #39393, #39442, #39443, #39453, #39454, #39471, #39477, #39478, #39527, #39552
- Failed merges:
  • Loading branch information
bors committed Feb 5, 2017
2 parents 696f5c1 + 0a09274 commit 9c8cdb2
Show file tree
Hide file tree
Showing 139 changed files with 1,344 additions and 576 deletions.
4 changes: 2 additions & 2 deletions src/bootstrap/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
//! rustbuild, the Rust build system
//!
//! This is the entry point for the build system used to compile the `rustc`
//! compiler. Lots of documentation can be found in the `README.md` file next to
//! this file, and otherwise documentation can be found throughout the `build`
//! compiler. Lots of documentation can be found in the `README.md` file in the
//! parent directory, and otherwise documentation can be found throughout the `build`
//! directory in each respective module.
#![deny(warnings)]
Expand Down
6 changes: 3 additions & 3 deletions src/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,14 +438,14 @@ def main():
rb.use_vendored_sources = '\nvendor = true' in rb.config_toml or \
'CFG_ENABLE_VENDOR' in rb.config_mk

if 'SUDO_USER' in os.environ:
if os.environ['USER'] != os.environ['SUDO_USER']:
if 'SUDO_USER' in os.environ and not rb.use_vendored_sources:
if os.environ.get('USER') != os.environ['SUDO_USER']:
rb.use_vendored_sources = True
print('info: looks like you are running this command under `sudo`')
print(' and so in order to preserve your $HOME this will now')
print(' use vendored sources by default. Note that if this')
print(' does not work you should run a normal build first')
print(' before running a command like `sudo make intall`')
print(' before running a command like `sudo make install`')

if rb.use_vendored_sources:
if not os.path.exists('.cargo'):
Expand Down
3 changes: 2 additions & 1 deletion src/bootstrap/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,8 @@ pub fn rust_src(build: &Build) {
"README.md",
"RELEASES.md",
"configure",
"Makefile.in"
"Makefile.in",
"x.py",
];
let src_dirs = [
"man",
Expand Down
4 changes: 2 additions & 2 deletions src/libcollections/binary_heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1088,7 +1088,7 @@ impl<'a, T: 'a> ExactSizeIterator for Drain<'a, T> {
#[unstable(feature = "fused", issue = "35602")]
impl<'a, T: 'a> FusedIterator for Drain<'a, T> {}

#[stable(feature = "rust1", since = "1.0.0")]
#[stable(feature = "binary_heap_extras_15", since = "1.5.0")]
impl<T: Ord> From<Vec<T>> for BinaryHeap<T> {
fn from(vec: Vec<T>) -> BinaryHeap<T> {
let mut heap = BinaryHeap { data: vec };
Expand All @@ -1097,7 +1097,7 @@ impl<T: Ord> From<Vec<T>> for BinaryHeap<T> {
}
}

#[stable(feature = "rust1", since = "1.0.0")]
#[stable(feature = "binary_heap_extras_15", since = "1.5.0")]
impl<T> From<BinaryHeap<T>> for Vec<T> {
fn from(heap: BinaryHeap<T>) -> Vec<T> {
heap.data
Expand Down
6 changes: 3 additions & 3 deletions src/libcore/char.rs
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ impl ExactSizeIterator for EscapeUnicode {
#[unstable(feature = "fused", issue = "35602")]
impl FusedIterator for EscapeUnicode {}

#[stable(feature = "char_struct_display", since = "1.17.0")]
#[stable(feature = "char_struct_display", since = "1.16.0")]
impl fmt::Display for EscapeUnicode {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
for c in self.clone() {
Expand Down Expand Up @@ -701,7 +701,7 @@ impl ExactSizeIterator for EscapeDefault {
#[unstable(feature = "fused", issue = "35602")]
impl FusedIterator for EscapeDefault {}

#[stable(feature = "char_struct_display", since = "1.17.0")]
#[stable(feature = "char_struct_display", since = "1.16.0")]
impl fmt::Display for EscapeDefault {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
for c in self.clone() {
Expand Down Expand Up @@ -735,7 +735,7 @@ impl ExactSizeIterator for EscapeDebug { }
#[unstable(feature = "fused", issue = "35602")]
impl FusedIterator for EscapeDebug {}

#[stable(feature = "char_struct_display", since = "1.17.0")]
#[unstable(feature = "char_escape_debug", issue = "35068")]
impl fmt::Display for EscapeDebug {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Display::fmt(&self.0, f)
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ pub trait TryFrom<T>: Sized {
type Err;

/// Performs the conversion.
fn try_from(T) -> Result<Self, Self::Err>;
fn try_from(value: T) -> Result<Self, Self::Err>;
}

////////////////////////////////////////////////////////////////////////////////
Expand Down
16 changes: 12 additions & 4 deletions src/libcore/internal_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
// based on "op T" where T is expected to be `Copy`able
macro_rules! forward_ref_unop {
(impl $imp:ident, $method:ident for $t:ty) => {
#[stable(feature = "rust1", since = "1.0.0")]
forward_ref_unop!(impl $imp, $method for $t,
#[stable(feature = "rust1", since = "1.0.0")]);
};
(impl $imp:ident, $method:ident for $t:ty, #[$attr:meta]) => {
#[$attr]
impl<'a> $imp for &'a $t {
type Output = <$t as $imp>::Output;

Expand All @@ -29,7 +33,11 @@ macro_rules! forward_ref_unop {
// based on "T op U" where T and U are expected to be `Copy`able
macro_rules! forward_ref_binop {
(impl $imp:ident, $method:ident for $t:ty, $u:ty) => {
#[stable(feature = "rust1", since = "1.0.0")]
forward_ref_binop!(impl $imp, $method for $t, $u,
#[stable(feature = "rust1", since = "1.0.0")]);
};
(impl $imp:ident, $method:ident for $t:ty, $u:ty, #[$attr:meta]) => {
#[$attr]
impl<'a> $imp<$u> for &'a $t {
type Output = <$t as $imp<$u>>::Output;

Expand All @@ -39,7 +47,7 @@ macro_rules! forward_ref_binop {
}
}

#[stable(feature = "rust1", since = "1.0.0")]
#[$attr]
impl<'a> $imp<&'a $u> for $t {
type Output = <$t as $imp<$u>>::Output;

Expand All @@ -49,7 +57,7 @@ macro_rules! forward_ref_binop {
}
}

#[stable(feature = "rust1", since = "1.0.0")]
#[$attr]
impl<'a, 'b> $imp<&'a $u> for &'b $t {
type Output = <$t as $imp<$u>>::Output;

Expand Down
22 changes: 21 additions & 1 deletion src/libcore/iter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1086,7 +1086,7 @@ impl<I: Iterator, P> Iterator for Filter<I, P> where P: FnMut(&I::Item) -> bool

#[inline]
fn next(&mut self) -> Option<I::Item> {
for x in self.iter.by_ref() {
for x in &mut self.iter {
if (self.predicate)(&x) {
return Some(x);
}
Expand All @@ -1099,6 +1099,26 @@ impl<I: Iterator, P> Iterator for Filter<I, P> where P: FnMut(&I::Item) -> bool
let (_, upper) = self.iter.size_hint();
(0, upper) // can't know a lower bound, due to the predicate
}

// this special case allows the compiler to make `.filter(_).count()`
// branchless. Barring perfect branch prediction (which is unattainable in
// the general case), this will be much faster in >90% of cases (containing
// virtually all real workloads) and only a tiny bit slower in the rest.
//
// Having this specialization thus allows us to write `.filter(p).count()`
// where we would otherwise write `.map(|x| p(x) as usize).sum()`, which is
// less readable and also less backwards-compatible to Rust before 1.10.
//
// Using the branchless version will also simplify the LLVM byte code, thus
// leaving more budget for LLVM optimizations.
#[inline]
fn count(mut self) -> usize {
let mut count = 0;
for x in &mut self.iter {
count += (self.predicate)(&x) as usize;
}
count
}
}

#[stable(feature = "rust1", since = "1.0.0")]
Expand Down
18 changes: 11 additions & 7 deletions src/libcore/iter/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -661,38 +661,42 @@ pub trait Product<A = Self>: Sized {

// NB: explicitly use Add and Mul here to inherit overflow checks
macro_rules! integer_sum_product {
(@impls $zero:expr, $one:expr, $($a:ty)*) => ($(
#[stable(feature = "iter_arith_traits", since = "1.12.0")]
(@impls $zero:expr, $one:expr, #[$attr:meta], $($a:ty)*) => ($(
#[$attr]
impl Sum for $a {
fn sum<I: Iterator<Item=$a>>(iter: I) -> $a {
iter.fold($zero, Add::add)
}
}

#[stable(feature = "iter_arith_traits", since = "1.12.0")]
#[$attr]
impl Product for $a {
fn product<I: Iterator<Item=$a>>(iter: I) -> $a {
iter.fold($one, Mul::mul)
}
}

#[stable(feature = "iter_arith_traits", since = "1.12.0")]
#[$attr]
impl<'a> Sum<&'a $a> for $a {
fn sum<I: Iterator<Item=&'a $a>>(iter: I) -> $a {
iter.fold($zero, Add::add)
}
}

#[stable(feature = "iter_arith_traits", since = "1.12.0")]
#[$attr]
impl<'a> Product<&'a $a> for $a {
fn product<I: Iterator<Item=&'a $a>>(iter: I) -> $a {
iter.fold($one, Mul::mul)
}
}
)*);
($($a:ty)*) => (
integer_sum_product!(@impls 0, 1, $($a)+);
integer_sum_product!(@impls Wrapping(0), Wrapping(1), $(Wrapping<$a>)+);
integer_sum_product!(@impls 0, 1,
#[stable(feature = "iter_arith_traits", since = "1.12.0")],
$($a)+);
integer_sum_product!(@impls Wrapping(0), Wrapping(1),
#[stable(feature = "wrapping_iter_arith", since = "1.14.0")],
$(Wrapping<$a>)+);
);
}

Expand Down
6 changes: 3 additions & 3 deletions src/libcore/num/int_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@

macro_rules! int_module {
($T:ident) => (int_module!($T, #[stable(feature = "rust1", since = "1.0.0")]););
($T:ident, $($attr: tt)*) => (
($T:ident, #[$attr:meta]) => (
/// The smallest value that can be represented by this integer type.
$($attr)*
#[$attr]
pub const MIN: $T = $T::min_value();
/// The largest value that can be represented by this integer type.
$($attr)*
#[$attr]
pub const MAX: $T = $T::max_value();
)
}
6 changes: 3 additions & 3 deletions src/libcore/num/uint_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@

macro_rules! uint_module {
($T:ident) => (uint_module!($T, #[stable(feature = "rust1", since = "1.0.0")]););
($T:ident, $($attr: tt)*) => (
($T:ident, #[$attr:meta]) => (
/// The smallest value that can be represented by this integer type.
$($attr)*
#[$attr]
pub const MIN: $T = $T::min_value();
/// The largest value that can be represented by this integer type.
$($attr)*
#[$attr]
pub const MAX: $T = $T::max_value();
)
}
30 changes: 20 additions & 10 deletions src/libcore/num/wrapping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ macro_rules! wrapping_impl {
Wrapping(self.0.wrapping_add(other.0))
}
}
forward_ref_binop! { impl Add, add for Wrapping<$t>, Wrapping<$t> }
forward_ref_binop! { impl Add, add for Wrapping<$t>, Wrapping<$t>,
#[stable(feature = "wrapping_ref", since = "1.14.0")] }

#[stable(feature = "op_assign_traits", since = "1.8.0")]
impl AddAssign for Wrapping<$t> {
Expand All @@ -150,7 +151,8 @@ macro_rules! wrapping_impl {
Wrapping(self.0.wrapping_sub(other.0))
}
}
forward_ref_binop! { impl Sub, sub for Wrapping<$t>, Wrapping<$t> }
forward_ref_binop! { impl Sub, sub for Wrapping<$t>, Wrapping<$t>,
#[stable(feature = "wrapping_ref", since = "1.14.0")] }

#[stable(feature = "op_assign_traits", since = "1.8.0")]
impl SubAssign for Wrapping<$t> {
Expand All @@ -169,7 +171,8 @@ macro_rules! wrapping_impl {
Wrapping(self.0.wrapping_mul(other.0))
}
}
forward_ref_binop! { impl Mul, mul for Wrapping<$t>, Wrapping<$t> }
forward_ref_binop! { impl Mul, mul for Wrapping<$t>, Wrapping<$t>,
#[stable(feature = "wrapping_ref", since = "1.14.0")] }

#[stable(feature = "op_assign_traits", since = "1.8.0")]
impl MulAssign for Wrapping<$t> {
Expand All @@ -188,7 +191,8 @@ macro_rules! wrapping_impl {
Wrapping(self.0.wrapping_div(other.0))
}
}
forward_ref_binop! { impl Div, div for Wrapping<$t>, Wrapping<$t> }
forward_ref_binop! { impl Div, div for Wrapping<$t>, Wrapping<$t>,
#[stable(feature = "wrapping_ref", since = "1.14.0")] }

#[stable(feature = "op_assign_traits", since = "1.8.0")]
impl DivAssign for Wrapping<$t> {
Expand All @@ -207,7 +211,8 @@ macro_rules! wrapping_impl {
Wrapping(self.0.wrapping_rem(other.0))
}
}
forward_ref_binop! { impl Rem, rem for Wrapping<$t>, Wrapping<$t> }
forward_ref_binop! { impl Rem, rem for Wrapping<$t>, Wrapping<$t>,
#[stable(feature = "wrapping_ref", since = "1.14.0")] }

#[stable(feature = "op_assign_traits", since = "1.8.0")]
impl RemAssign for Wrapping<$t> {
Expand All @@ -226,7 +231,8 @@ macro_rules! wrapping_impl {
Wrapping(!self.0)
}
}
forward_ref_unop! { impl Not, not for Wrapping<$t> }
forward_ref_unop! { impl Not, not for Wrapping<$t>,
#[stable(feature = "wrapping_ref", since = "1.14.0")] }

#[stable(feature = "rust1", since = "1.0.0")]
impl BitXor for Wrapping<$t> {
Expand All @@ -237,7 +243,8 @@ macro_rules! wrapping_impl {
Wrapping(self.0 ^ other.0)
}
}
forward_ref_binop! { impl BitXor, bitxor for Wrapping<$t>, Wrapping<$t> }
forward_ref_binop! { impl BitXor, bitxor for Wrapping<$t>, Wrapping<$t>,
#[stable(feature = "wrapping_ref", since = "1.14.0")] }

#[stable(feature = "op_assign_traits", since = "1.8.0")]
impl BitXorAssign for Wrapping<$t> {
Expand All @@ -256,7 +263,8 @@ macro_rules! wrapping_impl {
Wrapping(self.0 | other.0)
}
}
forward_ref_binop! { impl BitOr, bitor for Wrapping<$t>, Wrapping<$t> }
forward_ref_binop! { impl BitOr, bitor for Wrapping<$t>, Wrapping<$t>,
#[stable(feature = "wrapping_ref", since = "1.14.0")] }

#[stable(feature = "op_assign_traits", since = "1.8.0")]
impl BitOrAssign for Wrapping<$t> {
Expand All @@ -275,7 +283,8 @@ macro_rules! wrapping_impl {
Wrapping(self.0 & other.0)
}
}
forward_ref_binop! { impl BitAnd, bitand for Wrapping<$t>, Wrapping<$t> }
forward_ref_binop! { impl BitAnd, bitand for Wrapping<$t>, Wrapping<$t>,
#[stable(feature = "wrapping_ref", since = "1.14.0")] }

#[stable(feature = "op_assign_traits", since = "1.8.0")]
impl BitAndAssign for Wrapping<$t> {
Expand All @@ -293,7 +302,8 @@ macro_rules! wrapping_impl {
Wrapping(0) - self
}
}
forward_ref_unop! { impl Neg, neg for Wrapping<$t> }
forward_ref_unop! { impl Neg, neg for Wrapping<$t>,
#[stable(feature = "wrapping_ref", since = "1.14.0")] }
)*)
}

Expand Down
Loading

0 comments on commit 9c8cdb2

Please sign in to comment.