Skip to content

Commit 8b8a129

Browse files
committed
---
yaml --- r: 130486 b: refs/heads/try c: 8d5e64f h: refs/heads/master v: v3
1 parent fc39560 commit 8b8a129

File tree

19 files changed

+525
-455
lines changed

19 files changed

+525
-455
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: c964cb229bd342bdeb0b4506c3a6d32b03e575f6
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 67b97ab6d2b7de9b69fd97dc171fcf8feec932ff
5-
refs/heads/try: f422de1e85e87db51bfb61655da3faa331fbd91a
5+
refs/heads/try: 8d5e64f3bc2f754bed4b5a1857dd3494c5049c50
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/libcollections/bitv.rs

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -95,20 +95,6 @@ fn match_words <'a,'b>(a: &'a Bitv, b: &'b Bitv) -> (MatchWords<'a>, MatchWords<
9595
static TRUE: bool = true;
9696
static FALSE: bool = false;
9797

98-
#[deriving(Clone)]
99-
struct SmallBitv {
100-
/// only the lowest nbits of this value are used. the rest is undefined.
101-
bits: uint
102-
}
103-
104-
#[deriving(Clone)]
105-
struct BigBitv {
106-
storage: Vec<uint>
107-
}
108-
109-
#[deriving(Clone)]
110-
enum BitvVariant { Big(BigBitv), Small(SmallBitv) }
111-
11298
/// The bitvector type.
11399
///
114100
/// # Example
@@ -1653,6 +1639,7 @@ impl<'a> Iterator<uint> for TwoBitPositions<'a> {
16531639
#[cfg(test)]
16541640
mod tests {
16551641
use std::prelude::*;
1642+
use std::iter::range_step;
16561643
use std::uint;
16571644
use std::rand;
16581645
use std::rand::Rng;
@@ -2046,12 +2033,14 @@ mod tests {
20462033

20472034
#[test]
20482035
fn test_bitv_iterator() {
2049-
let bools = [true, false, true, true];
2036+
let bools = vec![true, false, true, true];
20502037
let bitv: Bitv = bools.iter().map(|n| *n).collect();
20512038

2052-
for (act, &ex) in bitv.iter().zip(bools.iter()) {
2053-
assert_eq!(ex, act);
2054-
}
2039+
assert_eq!(bitv.iter().collect::<Vec<bool>>(), bools)
2040+
2041+
let long = Vec::from_fn(10000, |i| i % 2 == 0);
2042+
let bitv: Bitv = long.iter().map(|n| *n).collect();
2043+
assert_eq!(bitv.iter().collect::<Vec<bool>>(), long)
20552044
}
20562045

20572046
#[test]
@@ -2061,6 +2050,12 @@ mod tests {
20612050

20622051
let idxs: Vec<uint> = bitv.iter().collect();
20632052
assert_eq!(idxs, vec!(0, 2, 3));
2053+
2054+
let long: BitvSet = range(0u, 10000).map(|n| n % 2 == 0).collect();
2055+
let real = range_step(0, 10000, 2).collect::<Vec<uint>>();
2056+
2057+
let idxs: Vec<uint> = long.iter().collect();
2058+
assert_eq!(idxs, real);
20642059
}
20652060

20662061
#[test]
@@ -2574,7 +2569,7 @@ mod tests {
25742569
}
25752570

25762571
#[bench]
2577-
fn bench_bitv_big(b: &mut Bencher) {
2572+
fn bench_bitv_set_big_fixed(b: &mut Bencher) {
25782573
let mut r = rng();
25792574
let mut bitv = Bitv::with_capacity(BENCH_BITS, false);
25802575
b.iter(|| {
@@ -2586,7 +2581,19 @@ mod tests {
25862581
}
25872582

25882583
#[bench]
2589-
fn bench_bitv_small(b: &mut Bencher) {
2584+
fn bench_bitv_set_big_variable(b: &mut Bencher) {
2585+
let mut r = rng();
2586+
let mut bitv = Bitv::with_capacity(BENCH_BITS, false);
2587+
b.iter(|| {
2588+
for i in range(0u, 100) {
2589+
bitv.set((r.next_u32() as uint) % BENCH_BITS, r.gen());
2590+
}
2591+
&bitv
2592+
})
2593+
}
2594+
2595+
#[bench]
2596+
fn bench_bitv_set_small(b: &mut Bencher) {
25902597
let mut r = rng();
25912598
let mut bitv = Bitv::with_capacity(uint::BITS, false);
25922599
b.iter(|| {
@@ -2598,7 +2605,7 @@ mod tests {
25982605
}
25992606

26002607
#[bench]
2601-
fn bench_bitv_set_small(b: &mut Bencher) {
2608+
fn bench_bitvset_small(b: &mut Bencher) {
26022609
let mut r = rng();
26032610
let mut bitv = BitvSet::new();
26042611
b.iter(|| {
@@ -2610,7 +2617,7 @@ mod tests {
26102617
}
26112618

26122619
#[bench]
2613-
fn bench_bitv_set_big(b: &mut Bencher) {
2620+
fn bench_bitvset_big(b: &mut Bencher) {
26142621
let mut r = rng();
26152622
let mut bitv = BitvSet::new();
26162623
b.iter(|| {

branches/try/src/libnative/io/file_unix.rs

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ impl rtio::RtioFileStream for FileDesc {
154154

155155
fn fstat(&mut self) -> IoResult<rtio::FileStat> {
156156
let mut stat: libc::stat = unsafe { mem::zeroed() };
157-
match retry(|| unsafe { libc::fstat(self.fd(), &mut stat) }) {
157+
match unsafe { libc::fstat(self.fd(), &mut stat) } {
158158
0 => Ok(mkstat(&stat)),
159159
_ => Err(super::last_error()),
160160
}
@@ -346,9 +346,7 @@ pub fn open(path: &CString, fm: rtio::FileMode, fa: rtio::FileAccess)
346346
}
347347

348348
pub fn mkdir(p: &CString, mode: uint) -> IoResult<()> {
349-
super::mkerr_libc(retry(|| unsafe {
350-
libc::mkdir(p.as_ptr(), mode as libc::mode_t)
351-
}))
349+
super::mkerr_libc(unsafe { libc::mkdir(p.as_ptr(), mode as libc::mode_t) })
352350
}
353351

354352
pub fn readdir(p: &CString) -> IoResult<Vec<CString>> {
@@ -393,13 +391,11 @@ pub fn readdir(p: &CString) -> IoResult<Vec<CString>> {
393391
}
394392

395393
pub fn unlink(p: &CString) -> IoResult<()> {
396-
super::mkerr_libc(retry(|| unsafe { libc::unlink(p.as_ptr()) }))
394+
super::mkerr_libc(unsafe { libc::unlink(p.as_ptr()) })
397395
}
398396

399397
pub fn rename(old: &CString, new: &CString) -> IoResult<()> {
400-
super::mkerr_libc(retry(|| unsafe {
401-
libc::rename(old.as_ptr(), new.as_ptr())
402-
}))
398+
super::mkerr_libc(unsafe { libc::rename(old.as_ptr(), new.as_ptr()) })
403399
}
404400

405401
pub fn chmod(p: &CString, mode: uint) -> IoResult<()> {
@@ -409,9 +405,7 @@ pub fn chmod(p: &CString, mode: uint) -> IoResult<()> {
409405
}
410406

411407
pub fn rmdir(p: &CString) -> IoResult<()> {
412-
super::mkerr_libc(retry(|| unsafe {
413-
libc::rmdir(p.as_ptr())
414-
}))
408+
super::mkerr_libc(unsafe { libc::rmdir(p.as_ptr()) })
415409
}
416410

417411
pub fn chown(p: &CString, uid: int, gid: int) -> IoResult<()> {
@@ -428,10 +422,10 @@ pub fn readlink(p: &CString) -> IoResult<CString> {
428422
len = 1024; // FIXME: read PATH_MAX from C ffi?
429423
}
430424
let mut buf: Vec<u8> = Vec::with_capacity(len as uint);
431-
match retry(|| unsafe {
425+
match unsafe {
432426
libc::readlink(p, buf.as_ptr() as *mut libc::c_char,
433427
len as libc::size_t) as libc::c_int
434-
}) {
428+
} {
435429
-1 => Err(super::last_error()),
436430
n => {
437431
assert!(n > 0);
@@ -442,15 +436,11 @@ pub fn readlink(p: &CString) -> IoResult<CString> {
442436
}
443437

444438
pub fn symlink(src: &CString, dst: &CString) -> IoResult<()> {
445-
super::mkerr_libc(retry(|| unsafe {
446-
libc::symlink(src.as_ptr(), dst.as_ptr())
447-
}))
439+
super::mkerr_libc(unsafe { libc::symlink(src.as_ptr(), dst.as_ptr()) })
448440
}
449441

450442
pub fn link(src: &CString, dst: &CString) -> IoResult<()> {
451-
super::mkerr_libc(retry(|| unsafe {
452-
libc::link(src.as_ptr(), dst.as_ptr())
453-
}))
443+
super::mkerr_libc(unsafe { libc::link(src.as_ptr(), dst.as_ptr()) })
454444
}
455445

456446
fn mkstat(stat: &libc::stat) -> rtio::FileStat {
@@ -489,15 +479,15 @@ fn mkstat(stat: &libc::stat) -> rtio::FileStat {
489479

490480
pub fn stat(p: &CString) -> IoResult<rtio::FileStat> {
491481
let mut stat: libc::stat = unsafe { mem::zeroed() };
492-
match retry(|| unsafe { libc::stat(p.as_ptr(), &mut stat) }) {
482+
match unsafe { libc::stat(p.as_ptr(), &mut stat) } {
493483
0 => Ok(mkstat(&stat)),
494484
_ => Err(super::last_error()),
495485
}
496486
}
497487

498488
pub fn lstat(p: &CString) -> IoResult<rtio::FileStat> {
499489
let mut stat: libc::stat = unsafe { mem::zeroed() };
500-
match retry(|| unsafe { libc::lstat(p.as_ptr(), &mut stat) }) {
490+
match unsafe { libc::lstat(p.as_ptr(), &mut stat) } {
501491
0 => Ok(mkstat(&stat)),
502492
_ => Err(super::last_error()),
503493
}
@@ -508,9 +498,7 @@ pub fn utime(p: &CString, atime: u64, mtime: u64) -> IoResult<()> {
508498
actime: (atime / 1000) as libc::time_t,
509499
modtime: (mtime / 1000) as libc::time_t,
510500
};
511-
super::mkerr_libc(retry(|| unsafe {
512-
libc::utime(p.as_ptr(), &buf)
513-
}))
501+
super::mkerr_libc(unsafe { libc::utime(p.as_ptr(), &buf) })
514502
}
515503

516504
#[cfg(test)]

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

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ use syntax::codemap::{Span, Spanned, DUMMY_SP};
2828
use syntax::fold::{Folder, noop_fold_pat};
2929
use syntax::print::pprust::pat_to_string;
3030
use syntax::parse::token;
31-
use syntax::visit;
32-
use syntax::visit::{Visitor, FnKind};
31+
use syntax::visit::{mod, Visitor, FnKind};
3332
use util::ppaux::ty_to_string;
3433

3534
struct Matrix(Vec<Vec<Gc<Pat>>>);
@@ -103,7 +102,9 @@ pub enum Constructor {
103102
/// Ranges of literal values (2..5).
104103
ConstantRange(const_val, const_val),
105104
/// Array patterns of length n.
106-
Slice(uint)
105+
Slice(uint),
106+
/// Array patterns with a subslice.
107+
SliceWithSubslice(uint, uint)
107108
}
108109

109110
#[deriving(Clone, PartialEq)]
@@ -270,13 +271,6 @@ fn check_arms(cx: &MatchCheckCtxt, arms: &[Arm]) {
270271
}
271272
}
272273

273-
fn raw_pat(p: Gc<Pat>) -> Gc<Pat> {
274-
match p.node {
275-
PatIdent(_, _, Some(s)) => { raw_pat(s) }
276-
_ => { p }
277-
}
278-
}
279-
280274
fn check_exhaustive(cx: &MatchCheckCtxt, sp: Span, matrix: &Matrix) {
281275
match is_useful(cx, matrix, [wild()], ConstructWitness) {
282276
UsefulWithWitness(pats) => {
@@ -821,6 +815,14 @@ pub fn specialize(cx: &MatchCheckCtxt, r: &[Gc<Pat>],
821815
pats.push_all(after.as_slice());
822816
Some(pats)
823817
},
818+
SliceWithSubslice(prefix, suffix)
819+
if before.len() == prefix
820+
&& after.len() == suffix
821+
&& slice.is_some() => {
822+
let mut pats = before.clone();
823+
pats.push_all(after.as_slice());
824+
Some(pats)
825+
}
824826
_ => None
825827
}
826828
}

branches/try/src/librustc/middle/pat_util.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,13 @@ pub fn wild() -> Gc<Pat> {
119119
box (GC) Pat { id: 0, node: PatWild(PatWildSingle), span: DUMMY_SP }
120120
}
121121

122+
pub fn raw_pat(p: Gc<Pat>) -> Gc<Pat> {
123+
match p.node {
124+
PatIdent(_, _, Some(s)) => { raw_pat(s) }
125+
_ => { p }
126+
}
127+
}
128+
122129
pub fn def_to_path(tcx: &ty::ctxt, id: DefId) -> Path {
123130
ty::with_path(tcx, id, |mut path| Path {
124131
global: false,

0 commit comments

Comments
 (0)