Skip to content

Commit 9c8cdb2

Browse files
committed
Auto merge of #39563 - frewsxcv:rollup, r=frewsxcv
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:
2 parents 696f5c1 + 0a09274 commit 9c8cdb2

File tree

139 files changed

+1344
-576
lines changed

Some content is hidden

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

139 files changed

+1344
-576
lines changed

src/bootstrap/bin/main.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
//! rustbuild, the Rust build system
1212
//!
1313
//! This is the entry point for the build system used to compile the `rustc`
14-
//! compiler. Lots of documentation can be found in the `README.md` file next to
15-
//! this file, and otherwise documentation can be found throughout the `build`
14+
//! compiler. Lots of documentation can be found in the `README.md` file in the
15+
//! parent directory, and otherwise documentation can be found throughout the `build`
1616
//! directory in each respective module.
1717
1818
#![deny(warnings)]

src/bootstrap/bootstrap.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -438,14 +438,14 @@ def main():
438438
rb.use_vendored_sources = '\nvendor = true' in rb.config_toml or \
439439
'CFG_ENABLE_VENDOR' in rb.config_mk
440440

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

450450
if rb.use_vendored_sources:
451451
if not os.path.exists('.cargo'):

src/bootstrap/dist.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,8 @@ pub fn rust_src(build: &Build) {
381381
"README.md",
382382
"RELEASES.md",
383383
"configure",
384-
"Makefile.in"
384+
"Makefile.in",
385+
"x.py",
385386
];
386387
let src_dirs = [
387388
"man",

src/libcollections/binary_heap.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1088,7 +1088,7 @@ impl<'a, T: 'a> ExactSizeIterator for Drain<'a, T> {
10881088
#[unstable(feature = "fused", issue = "35602")]
10891089
impl<'a, T: 'a> FusedIterator for Drain<'a, T> {}
10901090

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

1100-
#[stable(feature = "rust1", since = "1.0.0")]
1100+
#[stable(feature = "binary_heap_extras_15", since = "1.5.0")]
11011101
impl<T> From<BinaryHeap<T>> for Vec<T> {
11021102
fn from(heap: BinaryHeap<T>) -> Vec<T> {
11031103
heap.data

src/libcore/char.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ impl ExactSizeIterator for EscapeUnicode {
588588
#[unstable(feature = "fused", issue = "35602")]
589589
impl FusedIterator for EscapeUnicode {}
590590

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

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

738-
#[stable(feature = "char_struct_display", since = "1.17.0")]
738+
#[unstable(feature = "char_escape_debug", issue = "35068")]
739739
impl fmt::Display for EscapeDebug {
740740
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
741741
fmt::Display::fmt(&self.0, f)

src/libcore/convert.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ pub trait TryFrom<T>: Sized {
225225
type Err;
226226

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

231231
////////////////////////////////////////////////////////////////////////////////

src/libcore/internal_macros.rs

+12-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@
1313
// based on "op T" where T is expected to be `Copy`able
1414
macro_rules! forward_ref_unop {
1515
(impl $imp:ident, $method:ident for $t:ty) => {
16-
#[stable(feature = "rust1", since = "1.0.0")]
16+
forward_ref_unop!(impl $imp, $method for $t,
17+
#[stable(feature = "rust1", since = "1.0.0")]);
18+
};
19+
(impl $imp:ident, $method:ident for $t:ty, #[$attr:meta]) => {
20+
#[$attr]
1721
impl<'a> $imp for &'a $t {
1822
type Output = <$t as $imp>::Output;
1923

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

@@ -39,7 +47,7 @@ macro_rules! forward_ref_binop {
3947
}
4048
}
4149

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

@@ -49,7 +57,7 @@ macro_rules! forward_ref_binop {
4957
}
5058
}
5159

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

src/libcore/iter/mod.rs

+21-1
Original file line numberDiff line numberDiff line change
@@ -1086,7 +1086,7 @@ impl<I: Iterator, P> Iterator for Filter<I, P> where P: FnMut(&I::Item) -> bool
10861086

10871087
#[inline]
10881088
fn next(&mut self) -> Option<I::Item> {
1089-
for x in self.iter.by_ref() {
1089+
for x in &mut self.iter {
10901090
if (self.predicate)(&x) {
10911091
return Some(x);
10921092
}
@@ -1099,6 +1099,26 @@ impl<I: Iterator, P> Iterator for Filter<I, P> where P: FnMut(&I::Item) -> bool
10991099
let (_, upper) = self.iter.size_hint();
11001100
(0, upper) // can't know a lower bound, due to the predicate
11011101
}
1102+
1103+
// this special case allows the compiler to make `.filter(_).count()`
1104+
// branchless. Barring perfect branch prediction (which is unattainable in
1105+
// the general case), this will be much faster in >90% of cases (containing
1106+
// virtually all real workloads) and only a tiny bit slower in the rest.
1107+
//
1108+
// Having this specialization thus allows us to write `.filter(p).count()`
1109+
// where we would otherwise write `.map(|x| p(x) as usize).sum()`, which is
1110+
// less readable and also less backwards-compatible to Rust before 1.10.
1111+
//
1112+
// Using the branchless version will also simplify the LLVM byte code, thus
1113+
// leaving more budget for LLVM optimizations.
1114+
#[inline]
1115+
fn count(mut self) -> usize {
1116+
let mut count = 0;
1117+
for x in &mut self.iter {
1118+
count += (self.predicate)(&x) as usize;
1119+
}
1120+
count
1121+
}
11021122
}
11031123

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

src/libcore/iter/traits.rs

+11-7
Original file line numberDiff line numberDiff line change
@@ -661,38 +661,42 @@ pub trait Product<A = Self>: Sized {
661661

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

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

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

686-
#[stable(feature = "iter_arith_traits", since = "1.12.0")]
686+
#[$attr]
687687
impl<'a> Product<&'a $a> for $a {
688688
fn product<I: Iterator<Item=&'a $a>>(iter: I) -> $a {
689689
iter.fold($one, Mul::mul)
690690
}
691691
}
692692
)*);
693693
($($a:ty)*) => (
694-
integer_sum_product!(@impls 0, 1, $($a)+);
695-
integer_sum_product!(@impls Wrapping(0), Wrapping(1), $(Wrapping<$a>)+);
694+
integer_sum_product!(@impls 0, 1,
695+
#[stable(feature = "iter_arith_traits", since = "1.12.0")],
696+
$($a)+);
697+
integer_sum_product!(@impls Wrapping(0), Wrapping(1),
698+
#[stable(feature = "wrapping_iter_arith", since = "1.14.0")],
699+
$(Wrapping<$a>)+);
696700
);
697701
}
698702

src/libcore/num/int_macros.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212

1313
macro_rules! int_module {
1414
($T:ident) => (int_module!($T, #[stable(feature = "rust1", since = "1.0.0")]););
15-
($T:ident, $($attr: tt)*) => (
15+
($T:ident, #[$attr:meta]) => (
1616
/// The smallest value that can be represented by this integer type.
17-
$($attr)*
17+
#[$attr]
1818
pub const MIN: $T = $T::min_value();
1919
/// The largest value that can be represented by this integer type.
20-
$($attr)*
20+
#[$attr]
2121
pub const MAX: $T = $T::max_value();
2222
)
2323
}

src/libcore/num/uint_macros.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212

1313
macro_rules! uint_module {
1414
($T:ident) => (uint_module!($T, #[stable(feature = "rust1", since = "1.0.0")]););
15-
($T:ident, $($attr: tt)*) => (
15+
($T:ident, #[$attr:meta]) => (
1616
/// The smallest value that can be represented by this integer type.
17-
$($attr)*
17+
#[$attr]
1818
pub const MIN: $T = $T::min_value();
1919
/// The largest value that can be represented by this integer type.
20-
$($attr)*
20+
#[$attr]
2121
pub const MAX: $T = $T::max_value();
2222
)
2323
}

src/libcore/num/wrapping.rs

+20-10
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ macro_rules! wrapping_impl {
131131
Wrapping(self.0.wrapping_add(other.0))
132132
}
133133
}
134-
forward_ref_binop! { impl Add, add for Wrapping<$t>, Wrapping<$t> }
134+
forward_ref_binop! { impl Add, add for Wrapping<$t>, Wrapping<$t>,
135+
#[stable(feature = "wrapping_ref", since = "1.14.0")] }
135136

136137
#[stable(feature = "op_assign_traits", since = "1.8.0")]
137138
impl AddAssign for Wrapping<$t> {
@@ -150,7 +151,8 @@ macro_rules! wrapping_impl {
150151
Wrapping(self.0.wrapping_sub(other.0))
151152
}
152153
}
153-
forward_ref_binop! { impl Sub, sub for Wrapping<$t>, Wrapping<$t> }
154+
forward_ref_binop! { impl Sub, sub for Wrapping<$t>, Wrapping<$t>,
155+
#[stable(feature = "wrapping_ref", since = "1.14.0")] }
154156

155157
#[stable(feature = "op_assign_traits", since = "1.8.0")]
156158
impl SubAssign for Wrapping<$t> {
@@ -169,7 +171,8 @@ macro_rules! wrapping_impl {
169171
Wrapping(self.0.wrapping_mul(other.0))
170172
}
171173
}
172-
forward_ref_binop! { impl Mul, mul for Wrapping<$t>, Wrapping<$t> }
174+
forward_ref_binop! { impl Mul, mul for Wrapping<$t>, Wrapping<$t>,
175+
#[stable(feature = "wrapping_ref", since = "1.14.0")] }
173176

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

193197
#[stable(feature = "op_assign_traits", since = "1.8.0")]
194198
impl DivAssign for Wrapping<$t> {
@@ -207,7 +211,8 @@ macro_rules! wrapping_impl {
207211
Wrapping(self.0.wrapping_rem(other.0))
208212
}
209213
}
210-
forward_ref_binop! { impl Rem, rem for Wrapping<$t>, Wrapping<$t> }
214+
forward_ref_binop! { impl Rem, rem for Wrapping<$t>, Wrapping<$t>,
215+
#[stable(feature = "wrapping_ref", since = "1.14.0")] }
211216

212217
#[stable(feature = "op_assign_traits", since = "1.8.0")]
213218
impl RemAssign for Wrapping<$t> {
@@ -226,7 +231,8 @@ macro_rules! wrapping_impl {
226231
Wrapping(!self.0)
227232
}
228233
}
229-
forward_ref_unop! { impl Not, not for Wrapping<$t> }
234+
forward_ref_unop! { impl Not, not for Wrapping<$t>,
235+
#[stable(feature = "wrapping_ref", since = "1.14.0")] }
230236

231237
#[stable(feature = "rust1", since = "1.0.0")]
232238
impl BitXor for Wrapping<$t> {
@@ -237,7 +243,8 @@ macro_rules! wrapping_impl {
237243
Wrapping(self.0 ^ other.0)
238244
}
239245
}
240-
forward_ref_binop! { impl BitXor, bitxor for Wrapping<$t>, Wrapping<$t> }
246+
forward_ref_binop! { impl BitXor, bitxor for Wrapping<$t>, Wrapping<$t>,
247+
#[stable(feature = "wrapping_ref", since = "1.14.0")] }
241248

242249
#[stable(feature = "op_assign_traits", since = "1.8.0")]
243250
impl BitXorAssign for Wrapping<$t> {
@@ -256,7 +263,8 @@ macro_rules! wrapping_impl {
256263
Wrapping(self.0 | other.0)
257264
}
258265
}
259-
forward_ref_binop! { impl BitOr, bitor for Wrapping<$t>, Wrapping<$t> }
266+
forward_ref_binop! { impl BitOr, bitor for Wrapping<$t>, Wrapping<$t>,
267+
#[stable(feature = "wrapping_ref", since = "1.14.0")] }
260268

261269
#[stable(feature = "op_assign_traits", since = "1.8.0")]
262270
impl BitOrAssign for Wrapping<$t> {
@@ -275,7 +283,8 @@ macro_rules! wrapping_impl {
275283
Wrapping(self.0 & other.0)
276284
}
277285
}
278-
forward_ref_binop! { impl BitAnd, bitand for Wrapping<$t>, Wrapping<$t> }
286+
forward_ref_binop! { impl BitAnd, bitand for Wrapping<$t>, Wrapping<$t>,
287+
#[stable(feature = "wrapping_ref", since = "1.14.0")] }
279288

280289
#[stable(feature = "op_assign_traits", since = "1.8.0")]
281290
impl BitAndAssign for Wrapping<$t> {
@@ -293,7 +302,8 @@ macro_rules! wrapping_impl {
293302
Wrapping(0) - self
294303
}
295304
}
296-
forward_ref_unop! { impl Neg, neg for Wrapping<$t> }
305+
forward_ref_unop! { impl Neg, neg for Wrapping<$t>,
306+
#[stable(feature = "wrapping_ref", since = "1.14.0")] }
297307
)*)
298308
}
299309

0 commit comments

Comments
 (0)