Skip to content

Commit 1102b2c

Browse files
committed
Auto merge of #22548 - Manishearth:rollup, r=alexcrichton
I had most of these tested locally, why not get them out of the way too?
2 parents 522d09d + cf310d3 commit 1102b2c

File tree

10 files changed

+332
-262
lines changed

10 files changed

+332
-262
lines changed

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ links to the major sections:
1414
If you have questions, please make a post on [internals.rust-lang.org][internals] or
1515
hop on [#rust-internals][pound-rust-internals].
1616

17-
As a reminder, all contributors are expected to follow our [Code of Conduct](coc).
17+
As a reminder, all contributors are expected to follow our [Code of Conduct][coc].
1818

1919
[pound-rust-internals]: http://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust-internals
2020
[internals]: http://internals.rust-lang.org

src/doc/trpl/guessing-game.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ fn main() {
9191
```
9292

9393
You've seen this code before, when we talked about standard input. We
94-
import the `std::io` module with `use`, and then our `main` function contains
94+
import the `std::old_io` module with `use`, and then our `main` function contains
9595
our program's logic. We print a little message announcing the game, ask the
9696
user to input a guess, get their input, and then print it out.
9797

src/doc/trpl/if.md

+14
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,20 @@ if x == 5 {
3434
}
3535
```
3636

37+
If there is more than one case, use an `else if`:
38+
39+
```rust
40+
let x = 5;
41+
42+
if x == 5 {
43+
println!("x is five!");
44+
} else if x == 6 {
45+
println!("x is six!");
46+
} else {
47+
println!("x is not five or six :(");
48+
}
49+
```
50+
3751
This is all pretty standard. However, you can also do this:
3852

3953

src/libcoretest/iter.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ fn test_iterator_chain() {
8282
let xs = [0, 1, 2, 3, 4, 5];
8383
let ys = [30, 40, 50, 60];
8484
let expected = [0, 1, 2, 3, 4, 5, 30, 40, 50, 60];
85-
let mut it = xs.iter().chain(ys.iter());
85+
let it = xs.iter().chain(ys.iter());
8686
let mut i = 0;
8787
for &x in it {
8888
assert_eq!(x, expected[i]);
@@ -91,7 +91,7 @@ fn test_iterator_chain() {
9191
assert_eq!(i, expected.len());
9292

9393
let ys = count(30, 10).take(4);
94-
let mut it = xs.iter().cloned().chain(ys);
94+
let it = xs.iter().cloned().chain(ys);
9595
let mut i = 0;
9696
for x in it {
9797
assert_eq!(x, expected[i]);
@@ -110,7 +110,7 @@ fn test_filter_map() {
110110
#[test]
111111
fn test_iterator_enumerate() {
112112
let xs = [0, 1, 2, 3, 4, 5];
113-
let mut it = xs.iter().enumerate();
113+
let it = xs.iter().enumerate();
114114
for (i, &x) in it {
115115
assert_eq!(i, x);
116116
}
@@ -152,7 +152,7 @@ fn test_iterator_peekable() {
152152
fn test_iterator_take_while() {
153153
let xs = [0, 1, 2, 3, 5, 13, 15, 16, 17, 19];
154154
let ys = [0, 1, 2, 3, 5, 13];
155-
let mut it = xs.iter().take_while(|&x| *x < 15);
155+
let it = xs.iter().take_while(|&x| *x < 15);
156156
let mut i = 0;
157157
for x in it {
158158
assert_eq!(*x, ys[i]);
@@ -165,7 +165,7 @@ fn test_iterator_take_while() {
165165
fn test_iterator_skip_while() {
166166
let xs = [0, 1, 2, 3, 5, 13, 15, 16, 17, 19];
167167
let ys = [15, 16, 17, 19];
168-
let mut it = xs.iter().skip_while(|&x| *x < 15);
168+
let it = xs.iter().skip_while(|&x| *x < 15);
169169
let mut i = 0;
170170
for x in it {
171171
assert_eq!(*x, ys[i]);
@@ -231,7 +231,7 @@ fn test_iterator_scan() {
231231
let xs = [0, 1, 2, 3, 4];
232232
let ys = [0f64, 1.0, 3.0, 6.0, 10.0];
233233

234-
let mut it = xs.iter().scan(0, add);
234+
let it = xs.iter().scan(0, add);
235235
let mut i = 0;
236236
for x in it {
237237
assert_eq!(x, ys[i]);
@@ -244,7 +244,7 @@ fn test_iterator_scan() {
244244
fn test_iterator_flat_map() {
245245
let xs = [0, 3, 6];
246246
let ys = [0, 1, 2, 3, 4, 5, 6, 7, 8];
247-
let mut it = xs.iter().flat_map(|&x| count(x, 1).take(3));
247+
let it = xs.iter().flat_map(|&x| count(x, 1).take(3));
248248
let mut i = 0;
249249
for x in it {
250250
assert_eq!(x, ys[i]);
@@ -279,7 +279,7 @@ fn test_unfoldr() {
279279
}
280280
}
281281

282-
let mut it = Unfold::new(0, count);
282+
let it = Unfold::new(0, count);
283283
let mut i = 0;
284284
for counted in it {
285285
assert_eq!(counted, i);

src/liblibc/lib.rs

+241-237
Large diffs are not rendered by default.

src/librustc_trans/back/lto.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,12 @@ pub fn run(sess: &session::Session, llmod: ModuleRef,
167167
llvm::LLVMRustAddAnalysisPasses(tm, pm, llmod);
168168
llvm::LLVMRustAddPass(pm, "verify\0".as_ptr() as *const _);
169169

170-
let opt = sess.opts.cg.opt_level.unwrap_or(0) as libc::c_uint;
170+
let opt = match sess.opts.optimize {
171+
config::No => 0,
172+
config::Less => 1,
173+
config::Default => 2,
174+
config::Aggressive => 3,
175+
};
171176

172177
let builder = llvm::LLVMPassManagerBuilderCreate();
173178
llvm::LLVMPassManagerBuilderSetOptLevel(builder, opt);

src/librustc_trans/trans/controlflow.rs

+7
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use llvm::ValueRef;
1212
use middle::def;
1313
use middle::lang_items::{PanicFnLangItem, PanicBoundsCheckFnLangItem};
1414
use trans::base::*;
15+
use trans::basic_block::BasicBlock;
1516
use trans::build::*;
1617
use trans::callee;
1718
use trans::cleanup::CleanupMethods;
@@ -280,6 +281,12 @@ pub fn trans_loop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
280281

281282
fcx.pop_loop_cleanup_scope(loop_expr.id);
282283

284+
// If there are no predecessors for the next block, we just translated an endless loop and the
285+
// next block is unreachable
286+
if BasicBlock(next_bcx_in.llbb).pred_iter().next().is_none() {
287+
Unreachable(next_bcx_in);
288+
}
289+
283290
return next_bcx_in;
284291
}
285292

src/libstd/thread.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -465,16 +465,16 @@ impl Thread {
465465
}
466466
}
467467

468-
/// Deprecated: use module-level free fucntion.
469-
#[deprecated(since = "1.0.0", reason = "use module-level free fucntion")]
468+
/// Deprecated: use module-level free function.
469+
#[deprecated(since = "1.0.0", reason = "use module-level free function")]
470470
#[unstable(feature = "std_misc",
471471
reason = "may change with specifics of new Send semantics")]
472472
pub fn spawn<F>(f: F) -> Thread where F: FnOnce(), F: Send + 'static {
473473
Builder::new().spawn(f).unwrap().thread().clone()
474474
}
475475

476-
/// Deprecated: use module-level free fucntion.
477-
#[deprecated(since = "1.0.0", reason = "use module-level free fucntion")]
476+
/// Deprecated: use module-level free function.
477+
#[deprecated(since = "1.0.0", reason = "use module-level free function")]
478478
#[unstable(feature = "std_misc",
479479
reason = "may change with specifics of new Send semantics")]
480480
pub fn scoped<'a, T, F>(f: F) -> JoinGuard<'a, T> where
@@ -483,30 +483,30 @@ impl Thread {
483483
Builder::new().scoped(f).unwrap()
484484
}
485485

486-
/// Deprecated: use module-level free fucntion.
487-
#[deprecated(since = "1.0.0", reason = "use module-level free fucntion")]
486+
/// Deprecated: use module-level free function.
487+
#[deprecated(since = "1.0.0", reason = "use module-level free function")]
488488
#[stable(feature = "rust1", since = "1.0.0")]
489489
pub fn current() -> Thread {
490490
thread_info::current_thread()
491491
}
492492

493-
/// Deprecated: use module-level free fucntion.
494-
#[deprecated(since = "1.0.0", reason = "use module-level free fucntion")]
493+
/// Deprecated: use module-level free function.
494+
#[deprecated(since = "1.0.0", reason = "use module-level free function")]
495495
#[unstable(feature = "std_misc", reason = "name may change")]
496496
pub fn yield_now() {
497497
unsafe { imp::yield_now() }
498498
}
499499

500-
/// Deprecated: use module-level free fucntion.
501-
#[deprecated(since = "1.0.0", reason = "use module-level free fucntion")]
500+
/// Deprecated: use module-level free function.
501+
#[deprecated(since = "1.0.0", reason = "use module-level free function")]
502502
#[inline]
503503
#[stable(feature = "rust1", since = "1.0.0")]
504504
pub fn panicking() -> bool {
505505
unwind::panicking()
506506
}
507507

508-
/// Deprecated: use module-level free fucntion.
509-
#[deprecated(since = "1.0.0", reason = "use module-level free fucntion")]
508+
/// Deprecated: use module-level free function.
509+
#[deprecated(since = "1.0.0", reason = "use module-level free function")]
510510
#[unstable(feature = "std_misc", reason = "recently introduced")]
511511
pub fn park() {
512512
let thread = current();
@@ -517,8 +517,8 @@ impl Thread {
517517
*guard = false;
518518
}
519519

520-
/// Deprecated: use module-level free fucntion.
521-
#[deprecated(since = "1.0.0", reason = "use module-level free fucntion")]
520+
/// Deprecated: use module-level free function.
521+
#[deprecated(since = "1.0.0", reason = "use module-level free function")]
522522
#[unstable(feature = "std_misc", reason = "recently introduced")]
523523
pub fn park_timeout(dur: Duration) {
524524
let thread = current();

src/libtest/stats.rs

+20
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212

1313
use std::cmp::Ordering::{self, Less, Greater, Equal};
1414
use std::collections::hash_map::Entry::{Occupied, Vacant};
15+
#[cfg(not(stage0))]
1516
use std::collections::hash_map;
17+
#[cfg(stage0)]
18+
use std::collections::hash_map::{self, Hasher};
1619
use std::hash::Hash;
1720
use std::mem;
1821
use std::num::{Float, FromPrimitive};
@@ -332,6 +335,7 @@ pub fn winsorize<T: Float + FromPrimitive>(samples: &mut [T], pct: T) {
332335

333336
/// Returns a HashMap with the number of occurrences of every element in the
334337
/// sequence that the iterator exposes.
338+
#[cfg(not(stage0))]
335339
pub fn freq_count<T, U>(iter: T) -> hash_map::HashMap<U, uint>
336340
where T: Iterator<Item=U>, U: Eq + Clone + Hash
337341
{
@@ -345,6 +349,22 @@ pub fn freq_count<T, U>(iter: T) -> hash_map::HashMap<U, uint>
345349
map
346350
}
347351

352+
/// Returns a HashMap with the number of occurrences of every element in the
353+
/// sequence that the iterator exposes.
354+
#[cfg(stage0)]
355+
pub fn freq_count<T, U>(iter: T) -> hash_map::HashMap<U, uint>
356+
where T: Iterator<Item=U>, U: Eq + Clone + Hash<Hasher>
357+
{
358+
let mut map: hash_map::HashMap<U,uint> = hash_map::HashMap::new();
359+
for elem in iter {
360+
match map.entry(elem) {
361+
Occupied(mut entry) => { *entry.get_mut() += 1; },
362+
Vacant(entry) => { entry.insert(1); },
363+
}
364+
}
365+
map
366+
}
367+
348368
// Test vectors generated from R, using the script src/etc/stat-test-vectors.r.
349369

350370
#[cfg(test)]

src/test/compile-fail/if-loop.rs

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(rustc_attrs)]
12+
#![allow(warnings)]
13+
14+
// This used to ICE because the "if" being unreachable was not handled correctly
15+
fn err() {
16+
if loop {} {}
17+
}
18+
19+
#[rustc_error]
20+
fn main() {} //~ ERROR compilation successful

0 commit comments

Comments
 (0)