Skip to content

Commit 0a7de14

Browse files
committed
---
yaml --- r: 218347 b: refs/heads/tmp c: 74f4298 h: refs/heads/master i: 218345: dedd6c2 218343: 56d79f4 v: v3
1 parent c36249d commit 0a7de14

File tree

43 files changed

+138
-118
lines changed

Some content is hidden

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

43 files changed

+138
-118
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
2626
refs/heads/beta: ebf0c83cb9c6508e9564cb58337df2ad52b56430
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
28-
refs/heads/tmp: 92a95fe5507a41bdfb055913bec1be24509a5146
28+
refs/heads/tmp: 74f42980e19dd74a55d95cc0cd6428477797b6cf
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: d0fdfbfb0d34f196f52b9d15215723c4785c4afa
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828

branches/tmp/src/libcollections/bit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ impl BitVec {
283283
pub fn from_elem(nbits: usize, bit: bool) -> BitVec {
284284
let nblocks = blocks_for_bits(nbits);
285285
let mut bit_vec = BitVec {
286-
storage: vec![if bit { !0 } else { 0 }; nblocks],
286+
storage: repeat(if bit { !0 } else { 0 }).take(nblocks).collect(),
287287
nbits: nbits
288288
};
289289
bit_vec.fix_last_block();

branches/tmp/src/libcollectionstest/slice.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,7 +1318,7 @@ mod bench {
13181318

13191319
#[bench]
13201320
fn mut_iterator(b: &mut Bencher) {
1321-
let mut v = vec![0; 100];
1321+
let mut v: Vec<_> = repeat(0).take(100).collect();
13221322

13231323
b.iter(|| {
13241324
let mut i = 0;
@@ -1419,7 +1419,7 @@ mod bench {
14191419
#[bench]
14201420
fn zero_1kb_from_elem(b: &mut Bencher) {
14211421
b.iter(|| {
1422-
vec![0u8; 1024]
1422+
repeat(0u8).take(1024).collect::<Vec<_>>()
14231423
});
14241424
}
14251425

@@ -1467,7 +1467,7 @@ mod bench {
14671467
fn random_inserts(b: &mut Bencher) {
14681468
let mut rng = thread_rng();
14691469
b.iter(|| {
1470-
let mut v = vec![(0, 0); 30];
1470+
let mut v: Vec<_> = repeat((0, 0)).take(30).collect();
14711471
for _ in 0..100 {
14721472
let l = v.len();
14731473
v.insert(rng.gen::<usize>() % (l + 1),
@@ -1479,7 +1479,7 @@ mod bench {
14791479
fn random_removes(b: &mut Bencher) {
14801480
let mut rng = thread_rng();
14811481
b.iter(|| {
1482-
let mut v = vec![(0, 0); 130];
1482+
let mut v: Vec<_> = repeat((0, 0)).take(130).collect();
14831483
for _ in 0..100 {
14841484
let l = v.len();
14851485
v.remove(rng.gen::<usize>() % l);

branches/tmp/src/libcore/intrinsics.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -586,18 +586,18 @@ extern "rust-intrinsic" {
586586
pub fn overflowing_mul<T>(a: T, b: T) -> T;
587587

588588
/// Performs an unchecked signed division, which results in undefined behavior,
589-
/// in cases where y == 0, or x == isize::MIN and y == -1
589+
/// in cases where y == 0, or x == int::MIN and y == -1
590590
pub fn unchecked_sdiv<T>(x: T, y: T) -> T;
591591
/// Performs an unchecked unsigned division, which results in undefined behavior,
592592
/// in cases where y == 0
593593
pub fn unchecked_udiv<T>(x: T, y: T) -> T;
594594

595595
/// Returns the remainder of an unchecked signed division, which results in
596-
/// undefined behavior, in cases where y == 0, or x == isize::MIN and y == -1
597-
pub fn unchecked_srem<T>(x: T, y: T) -> T;
598-
/// Returns the remainder of an unchecked unsigned division, which results in
599-
/// undefined behavior, in cases where y == 0
596+
/// undefined behavior, in cases where y == 0, or x == int::MIN and y == -1
600597
pub fn unchecked_urem<T>(x: T, y: T) -> T;
598+
/// Returns the remainder of an unchecked signed division, which results in
599+
/// undefined behavior, in cases where y == 0
600+
pub fn unchecked_srem<T>(x: T, y: T) -> T;
601601

602602
/// Returns the value of the discriminant for the variant in 'v',
603603
/// cast to a `u64`; if `T` has no discriminant, returns 0.

branches/tmp/src/libcore/num/wrapping.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,16 +119,6 @@ macro_rules! wrapping_impl {
119119
}
120120
}
121121

122-
#[stable(feature = "wrapping_div", since = "1.3.0")]
123-
impl Div for Wrapping<$t> {
124-
type Output = Wrapping<$t>;
125-
126-
#[inline(always)]
127-
fn div(self, other: Wrapping<$t>) -> Wrapping<$t> {
128-
Wrapping(self.0.wrapping_div(other.0))
129-
}
130-
}
131-
132122
#[stable(feature = "rust1", since = "1.0.0")]
133123
impl Not for Wrapping<$t> {
134124
type Output = Wrapping<$t>;

branches/tmp/src/libcore/slice.rs

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1463,30 +1463,12 @@ pub mod bytes {
14631463
#[stable(feature = "rust1", since = "1.0.0")]
14641464
impl<A, B> PartialEq<[B]> for [A] where A: PartialEq<B> {
14651465
fn eq(&self, other: &[B]) -> bool {
1466-
if self.len() != other.len() {
1467-
return false;
1468-
}
1469-
1470-
for i in 0..self.len() {
1471-
if !self[i].eq(&other[i]) {
1472-
return false;
1473-
}
1474-
}
1475-
1476-
true
1466+
self.len() == other.len() &&
1467+
order::eq(self.iter(), other.iter())
14771468
}
14781469
fn ne(&self, other: &[B]) -> bool {
1479-
if self.len() != other.len() {
1480-
return true;
1481-
}
1482-
1483-
for i in 0..self.len() {
1484-
if self[i].ne(&other[i]) {
1485-
return true;
1486-
}
1487-
}
1488-
1489-
false
1470+
self.len() != other.len() ||
1471+
order::ne(self.iter(), other.iter())
14901472
}
14911473
}
14921474

branches/tmp/src/libcoretest/ptr.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
use core::ptr::*;
1212
use core::mem;
13+
use std::iter::repeat;
1314

1415
#[test]
1516
fn test() {
@@ -109,7 +110,7 @@ fn test_as_mut() {
109110
#[test]
110111
fn test_ptr_addition() {
111112
unsafe {
112-
let xs = vec![5; 16];
113+
let xs = repeat(5).take(16).collect::<Vec<_>>();
113114
let mut ptr = xs.as_ptr();
114115
let end = ptr.offset(16);
115116

@@ -127,7 +128,7 @@ fn test_ptr_addition() {
127128
m_ptr = m_ptr.offset(1);
128129
}
129130

130-
assert!(xs_mut == vec![10; 16]);
131+
assert!(xs_mut == repeat(10).take(16).collect::<Vec<_>>());
131132
}
132133
}
133134

branches/tmp/src/libgraphviz/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,7 @@ mod tests {
599599
use std::io;
600600
use std::io::prelude::*;
601601
use std::borrow::IntoCow;
602+
use std::iter::repeat;
602603

603604
/// each node is an index in a vector in the graph.
604605
type Node = usize;
@@ -646,7 +647,7 @@ mod tests {
646647
fn to_opt_strs(self) -> Vec<Option<&'static str>> {
647648
match self {
648649
UnlabelledNodes(len)
649-
=> vec![None; len],
650+
=> repeat(None).take(len).collect(),
650651
AllNodesLabelled(lbls)
651652
=> lbls.into_iter().map(
652653
|l|Some(l)).collect(),

branches/tmp/src/liblibc/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2522,6 +2522,7 @@ pub mod consts {
25222522
pub const S_IFDIR : c_int = 16384;
25232523
pub const S_IFREG : c_int = 32768;
25242524
pub const S_IFLNK : c_int = 40960;
2525+
pub const S_IFSOCK : mode_t = 49152;
25252526
pub const S_IFMT : c_int = 61440;
25262527
pub const S_IEXEC : c_int = 64;
25272528
pub const S_IWRITE : c_int = 128;
@@ -2881,6 +2882,7 @@ pub mod consts {
28812882
pub const S_IFDIR : mode_t = 16384;
28822883
pub const S_IFREG : mode_t = 32768;
28832884
pub const S_IFLNK : mode_t = 40960;
2885+
pub const S_IFSOCK : mode_t = 49152;
28842886
pub const S_IFMT : mode_t = 61440;
28852887
pub const S_IEXEC : mode_t = 64;
28862888
pub const S_IWRITE : mode_t = 128;
@@ -3103,6 +3105,7 @@ pub mod consts {
31033105
pub const S_IFDIR : mode_t = 16384;
31043106
pub const S_IFREG : mode_t = 32768;
31053107
pub const S_IFLNK : mode_t = 40960;
3108+
pub const S_IFSOCK : mode_t = 49152;
31063109
pub const S_IFMT : mode_t = 61440;
31073110
pub const S_IEXEC : mode_t = 64;
31083111
pub const S_IWRITE : mode_t = 128;
@@ -3905,6 +3908,7 @@ pub mod consts {
39053908
pub const S_IFDIR : mode_t = 16384;
39063909
pub const S_IFREG : mode_t = 32768;
39073910
pub const S_IFLNK : mode_t = 40960;
3911+
pub const S_IFSOCK : mode_t = 49152;
39083912
pub const S_IFMT : mode_t = 61440;
39093913
pub const S_IEXEC : mode_t = 64;
39103914
pub const S_IWRITE : mode_t = 128;
@@ -4365,6 +4369,7 @@ pub mod consts {
43654369
pub const S_IFDIR : mode_t = 16384;
43664370
pub const S_IFREG : mode_t = 32768;
43674371
pub const S_IFLNK : mode_t = 40960;
4372+
pub const S_IFSOCK : mode_t = 49152;
43684373
pub const S_IFMT : mode_t = 61440;
43694374
pub const S_IEXEC : mode_t = 64;
43704375
pub const S_IWRITE : mode_t = 128;
@@ -4791,6 +4796,7 @@ pub mod consts {
47914796
pub const S_IFDIR : mode_t = 16384;
47924797
pub const S_IFREG : mode_t = 32768;
47934798
pub const S_IFLNK : mode_t = 40960;
4799+
pub const S_IFSOCK : mode_t = 49152;
47944800
pub const S_IFMT : mode_t = 61440;
47954801
pub const S_IEXEC : mode_t = 64;
47964802
pub const S_IWRITE : mode_t = 128;

branches/tmp/src/librand/reseeding.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ mod tests {
186186
const FILL_BYTES_V_LEN: usize = 13579;
187187
#[test]
188188
fn test_rng_fill_bytes() {
189-
let mut v = vec![0; FILL_BYTES_V_LEN];
189+
let mut v = repeat(0).take(FILL_BYTES_V_LEN).collect::<Vec<_>>();
190190
::test::rng().fill_bytes(&mut v);
191191

192192
// Sanity test: if we've gotten here, `fill_bytes` has not infinitely

branches/tmp/src/librustc/middle/check_match.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ fn is_useful(cx: &MatchCheckCtxt,
704704
match is_useful(cx, &matrix, v.tail(), witness) {
705705
UsefulWithWitness(pats) => {
706706
let arity = constructor_arity(cx, &constructor, left_ty);
707-
let wild_pats = vec![DUMMY_WILD_PAT; arity];
707+
let wild_pats: Vec<_> = repeat(DUMMY_WILD_PAT).take(arity).collect();
708708
let enum_pat = construct_witness(cx, &constructor, wild_pats, left_ty);
709709
let mut new_pats = vec![enum_pat];
710710
new_pats.extend(pats);
@@ -862,7 +862,7 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat],
862862
} = raw_pat(r[col]);
863863
let head: Option<Vec<&Pat>> = match *node {
864864
ast::PatWild(_) =>
865-
Some(vec![DUMMY_WILD_PAT; arity]),
865+
Some(repeat(DUMMY_WILD_PAT).take(arity).collect()),
866866

867867
ast::PatIdent(_, _, _) => {
868868
let opt_def = cx.tcx.def_map.borrow().get(&pat_id).map(|d| d.full_def());
@@ -875,7 +875,7 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat],
875875
} else {
876876
None
877877
},
878-
_ => Some(vec![DUMMY_WILD_PAT; arity])
878+
_ => Some(repeat(DUMMY_WILD_PAT).take(arity).collect())
879879
}
880880
}
881881

@@ -889,7 +889,7 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat],
889889
DefVariant(..) | DefStruct(..) => {
890890
Some(match args {
891891
&Some(ref args) => args.iter().map(|p| &**p).collect(),
892-
&None => vec![DUMMY_WILD_PAT; arity],
892+
&None => repeat(DUMMY_WILD_PAT).take(arity).collect(),
893893
})
894894
}
895895
_ => None

branches/tmp/src/librustc/middle/dataflow.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use middle::cfg::CFGIndex;
2121
use middle::ty;
2222
use std::io;
2323
use std::usize;
24+
use std::iter::repeat;
2425
use syntax::ast;
2526
use syntax::ast_util::IdRange;
2627
use syntax::visit;
@@ -238,11 +239,11 @@ impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> {
238239

239240
let entry = if oper.initial_value() { usize::MAX } else {0};
240241

241-
let zeroes = vec![0; num_nodes * words_per_id];
242-
let gens = zeroes.clone();
243-
let kills1 = zeroes.clone();
244-
let kills2 = zeroes;
245-
let on_entry = vec![entry; num_nodes * words_per_id];
242+
let zeroes: Vec<_> = repeat(0).take(num_nodes * words_per_id).collect();
243+
let gens: Vec<_> = zeroes.clone();
244+
let kills1: Vec<_> = zeroes.clone();
245+
let kills2: Vec<_> = zeroes;
246+
let on_entry: Vec<_> = repeat(entry).take(num_nodes * words_per_id).collect();
246247

247248
let nodeid_to_index = build_nodeid_to_index(decl, cfg);
248249

@@ -510,7 +511,7 @@ impl<'a, 'tcx, O:DataFlowOperator+Clone+'static> DataFlowContext<'a, 'tcx, O> {
510511
changed: true
511512
};
512513

513-
let mut temp = vec![0; words_per_id];
514+
let mut temp: Vec<_> = repeat(0).take(words_per_id).collect();
514515
while propcx.changed {
515516
propcx.changed = false;
516517
propcx.reset(&mut temp);

branches/tmp/src/librustc/middle/infer/region_inference/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ use util::nodemap::{FnvHashMap, FnvHashSet};
3434
use std::cell::{Cell, RefCell};
3535
use std::cmp::Ordering::{self, Less, Greater, Equal};
3636
use std::fmt;
37+
use std::iter::repeat;
3738
use std::u32;
3839
use syntax::ast;
3940

@@ -1303,7 +1304,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
13031304
// idea is to report errors that derive from independent
13041305
// regions of the graph, but not those that derive from
13051306
// overlapping locations.
1306-
let mut dup_vec = vec![u32::MAX; self.num_vars() as usize];
1307+
let mut dup_vec: Vec<_> = repeat(u32::MAX).take(self.num_vars() as usize).collect();
13071308

13081309
for idx in 0..self.num_vars() as usize {
13091310
match var_data[idx].value {

branches/tmp/src/librustc/middle/liveness.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ use util::nodemap::NodeMap;
119119
use std::{fmt, usize};
120120
use std::io::prelude::*;
121121
use std::io;
122+
use std::iter::repeat;
122123
use std::rc::Rc;
123124
use syntax::ast::{self, NodeId, Expr};
124125
use syntax::codemap::{BytePos, original_sp, Span};
@@ -565,8 +566,8 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
565566
Liveness {
566567
ir: ir,
567568
s: specials,
568-
successors: vec![invalid_node(); num_live_nodes],
569-
users: vec![invalid_users(); num_live_nodes * num_vars],
569+
successors: repeat(invalid_node()).take(num_live_nodes).collect(),
570+
users: repeat(invalid_users()).take(num_live_nodes * num_vars).collect(),
570571
loop_scope: Vec::new(),
571572
break_ln: NodeMap(),
572573
cont_ln: NodeMap(),

branches/tmp/src/librustc_back/sha2.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
//! use. This implementation is not intended for external use or for any use where security is
1313
//! important.
1414
15+
use std::iter::repeat;
1516
use std::slice::bytes::{MutableByteVector, copy_memory};
1617
use serialize::hex::ToHex;
1718

@@ -254,7 +255,7 @@ pub trait Digest {
254255
/// Convenience function that retrieves the result of a digest as a
255256
/// newly allocated vec of bytes.
256257
fn result_bytes(&mut self) -> Vec<u8> {
257-
let mut buf = vec![0; (self.output_bits()+7)/8];
258+
let mut buf: Vec<u8> = repeat(0).take((self.output_bits()+7)/8).collect();
258259
self.result(&mut buf);
259260
buf
260261
}
@@ -533,6 +534,7 @@ mod tests {
533534
use self::rand::Rng;
534535
use self::rand::isaac::IsaacRng;
535536
use serialize::hex::FromHex;
537+
use std::iter::repeat;
536538
use std::u64;
537539
use super::{Digest, Sha256, FixedBuffer};
538540

@@ -611,7 +613,7 @@ mod tests {
611613
/// correct.
612614
fn test_digest_1million_random<D: Digest>(digest: &mut D, blocksize: usize, expected: &str) {
613615
let total_size = 1000000;
614-
let buffer = vec![b'a'; blocksize * 2];
616+
let buffer: Vec<u8> = repeat('a' as u8).take(blocksize * 2).collect();
615617
let mut rng = IsaacRng::new_unseeded();
616618
let mut count = 0;
617619

branches/tmp/src/librustc_data_structures/bitvec.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
use std::iter;
12+
1113
/// A very simple BitVector type.
1214
pub struct BitVector {
1315
data: Vec<u64>
@@ -16,7 +18,7 @@ pub struct BitVector {
1618
impl BitVector {
1719
pub fn new(num_bits: usize) -> BitVector {
1820
let num_words = (num_bits + 63) / 64;
19-
BitVector { data: vec![0; num_words] }
21+
BitVector { data: iter::repeat(0).take(num_words).collect() }
2022
}
2123

2224
fn word_mask(&self, bit: usize) -> (usize, u64) {

0 commit comments

Comments
 (0)