Skip to content

Commit bd98fe0

Browse files
committed
Auto merge of #48040 - kennytm:rollup, r=kennytm
Rollup of 7 pull requests - Successful merges: #46962, #47986, #48012, #48013, #48026, #48031, #48036 - Failed merges:
2 parents ca7d839 + 7f0e87a commit bd98fe0

File tree

25 files changed

+235
-18
lines changed

25 files changed

+235
-18
lines changed

config.toml.example

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@
295295

296296
# Flag indicating whether git info will be retrieved from .git automatically.
297297
# Having the git information can cause a lot of rebuilds during development.
298-
# Note: If this attribute is not explicity set (e.g. if left commented out) it
298+
# Note: If this attribute is not explicitly set (e.g. if left commented out) it
299299
# will default to true if channel = "dev", but will default to false otherwise.
300300
#ignore-git = true
301301

@@ -317,8 +317,8 @@
317317
# bootstrap)
318318
#codegen-backends = ["llvm"]
319319

320-
# Flag indicating whether `libstd` calls an imported function to hande basic IO
321-
# when targetting WebAssembly. Enable this to debug tests for the `wasm32-unknown-unknown`
320+
# Flag indicating whether `libstd` calls an imported function to handle basic IO
321+
# when targeting WebAssembly. Enable this to debug tests for the `wasm32-unknown-unknown`
322322
# target, as without this option the test output will not be captured.
323323
#wasm-syscall = false
324324

@@ -349,7 +349,7 @@
349349
#linker = "cc"
350350

351351
# Path to the `llvm-config` binary of the installation of a custom LLVM to link
352-
# against. Note that if this is specifed we don't compile LLVM at all for this
352+
# against. Note that if this is specified we don't compile LLVM at all for this
353353
# target.
354354
#llvm-config = "../path/to/llvm/root/bin/llvm-config"
355355

src/Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/bootstrap/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,4 @@ serde_derive = "1.0.8"
4141
serde_json = "1.0.2"
4242
toml = "0.4"
4343
lazy_static = "0.2"
44+
time = "0.1"

src/bootstrap/dist.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ use builder::{Builder, RunConfig, ShouldRun, Step};
3333
use compile;
3434
use tool::{self, Tool};
3535
use cache::{INTERNER, Interned};
36+
use time;
3637

3738
pub fn pkgname(build: &Build, component: &str) -> String {
3839
if component == "cargo" {
@@ -445,8 +446,7 @@ impl Step for Rustc {
445446
t!(fs::create_dir_all(image.join("share/man/man1")));
446447
let man_src = build.src.join("src/doc/man");
447448
let man_dst = image.join("share/man/man1");
448-
let date_output = output(Command::new("date").arg("+%B %Y"));
449-
let month_year = date_output.trim();
449+
let month_year = t!(time::strftime("%B %Y", &time::now()));
450450
// don't use our `bootstrap::util::{copy, cp_r}`, because those try
451451
// to hardlink, and we don't want to edit the source templates
452452
for entry_result in t!(fs::read_dir(man_src)) {
@@ -456,7 +456,7 @@ impl Step for Rustc {
456456
t!(fs::copy(&page_src, &page_dst));
457457
// template in month/year and version number
458458
replace_in_file(&page_dst,
459-
&[("<INSERT DATE HERE>", month_year),
459+
&[("<INSERT DATE HERE>", &month_year),
460460
("<INSERT VERSION HERE>", channel::CFG_RELEASE_NUM)]);
461461
}
462462

src/bootstrap/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ extern crate cc;
130130
extern crate getopts;
131131
extern crate num_cpus;
132132
extern crate toml;
133+
extern crate time;
133134

134135
#[cfg(unix)]
135136
extern crate libc;

src/libcore/iter/range.rs

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
use convert::TryFrom;
1212
use mem;
13-
use ops::{self, Add, Sub};
13+
use ops::{self, Add, Sub, Try};
1414
use usize;
1515

1616
use super::{FusedIterator, TrustedLen};
@@ -397,6 +397,28 @@ impl<A: Step> Iterator for ops::RangeInclusive<A> {
397397
fn max(mut self) -> Option<A> {
398398
self.next_back()
399399
}
400+
401+
#[inline]
402+
fn try_fold<B, F, R>(&mut self, init: B, mut f: F) -> R where
403+
Self: Sized, F: FnMut(B, Self::Item) -> R, R: Try<Ok=B>
404+
{
405+
let mut accum = init;
406+
if self.start <= self.end {
407+
loop {
408+
let (x, done) =
409+
if self.start < self.end {
410+
let n = self.start.add_one();
411+
(mem::replace(&mut self.start, n), false)
412+
} else {
413+
self.end.replace_zero();
414+
(self.start.replace_one(), true)
415+
};
416+
accum = f(accum, x)?;
417+
if done { break }
418+
}
419+
}
420+
Try::from_ok(accum)
421+
}
400422
}
401423

402424
#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
@@ -418,6 +440,28 @@ impl<A: Step> DoubleEndedIterator for ops::RangeInclusive<A> {
418440
_ => None,
419441
}
420442
}
443+
444+
#[inline]
445+
fn try_rfold<B, F, R>(&mut self, init: B, mut f: F) -> R where
446+
Self: Sized, F: FnMut(B, Self::Item) -> R, R: Try<Ok=B>
447+
{
448+
let mut accum = init;
449+
if self.start <= self.end {
450+
loop {
451+
let (x, done) =
452+
if self.start < self.end {
453+
let n = self.end.sub_one();
454+
(mem::replace(&mut self.end, n), false)
455+
} else {
456+
self.start.replace_one();
457+
(self.end.replace_zero(), true)
458+
};
459+
accum = f(accum, x)?;
460+
if done { break }
461+
}
462+
}
463+
Try::from_ok(accum)
464+
}
421465
}
422466

423467
#[unstable(feature = "fused", issue = "35602")]

src/libcore/tests/iter.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,6 +1459,26 @@ fn test_range_inclusive_min() {
14591459
assert_eq!(r.min(), None);
14601460
}
14611461

1462+
#[test]
1463+
fn test_range_inclusive_folds() {
1464+
assert_eq!((1..=10).sum::<i32>(), 55);
1465+
assert_eq!((1..=10).rev().sum::<i32>(), 55);
1466+
1467+
let mut it = 40..=50;
1468+
assert_eq!(it.try_fold(0, i8::checked_add), None);
1469+
assert_eq!(it, 44..=50);
1470+
assert_eq!(it.try_rfold(0, i8::checked_add), None);
1471+
assert_eq!(it, 44..=47);
1472+
1473+
let mut it = 10..=20;
1474+
assert_eq!(it.try_fold(0, |a,b| Some(a+b)), Some(165));
1475+
assert_eq!(it, 1..=0);
1476+
1477+
let mut it = 10..=20;
1478+
assert_eq!(it.try_rfold(0, |a,b| Some(a+b)), Some(165));
1479+
assert_eq!(it, 1..=0);
1480+
}
1481+
14621482
#[test]
14631483
fn test_repeat() {
14641484
let mut it = repeat(42);

src/libproc_macro/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ impl TokenTree {
685685
})
686686
}
687687

688-
DotEq => unreachable!(),
688+
DotEq => joint!('.', Eq),
689689
OpenDelim(..) | CloseDelim(..) => unreachable!(),
690690
Whitespace | Comment | Shebang(..) | Eof => unreachable!(),
691691
};

src/librustc/diagnostics.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,28 @@ trait Foo {
256256
}
257257
```
258258
259+
### The trait cannot contain associated constants
260+
261+
Just like static functions, associated constants aren't stored on the method
262+
table. If the trait or any subtrait contain an associated constant, they cannot
263+
be made into an object.
264+
265+
```compile_fail,E0038
266+
trait Foo {
267+
const X: i32;
268+
}
269+
270+
impl Foo {}
271+
```
272+
273+
A simple workaround is to use a helper method instead:
274+
275+
```
276+
trait Foo {
277+
fn x(&self) -> i32;
278+
}
279+
```
280+
259281
### The trait cannot use `Self` as a type parameter in the supertrait listing
260282
261283
This is similar to the second sub-error, but subtler. It happens in situations

src/libstd/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@
260260
#![feature(core_intrinsics)]
261261
#![feature(dropck_eyepatch)]
262262
#![feature(exact_size_is_empty)]
263+
#![feature(external_doc)]
263264
#![feature(fs_read_write)]
264265
#![feature(fixed_size_array)]
265266
#![feature(float_from_str_radix)]

0 commit comments

Comments
 (0)