Skip to content

Commit 36c904c

Browse files
author
Keegan McAllister
committed
---
yaml --- r: 130179 b: refs/heads/master c: 7f676b8 h: refs/heads/master i: 130177: 91aeb58 130175: b06730f v: v3
1 parent 4172cdc commit 36c904c

File tree

20 files changed

+458
-526
lines changed

20 files changed

+458
-526
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 6d8b5c9f7d1347b715242a837fba87a01ae61d7e
2+
refs/heads/master: 7f676b86994edcd6adf27018a5d18e957c9390ab
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 67b97ab6d2b7de9b69fd97dc171fcf8feec932ff
55
refs/heads/try: 28d5878c1f0465c11c8e7a3085008b0c592d48d0

trunk/src/libcollections/bitv.rs

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,20 @@ 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+
98112
/// The bitvector type.
99113
///
100114
/// # Example
@@ -1639,7 +1653,6 @@ impl<'a> Iterator<uint> for TwoBitPositions<'a> {
16391653
#[cfg(test)]
16401654
mod tests {
16411655
use std::prelude::*;
1642-
use std::iter::range_step;
16431656
use std::uint;
16441657
use std::rand;
16451658
use std::rand::Rng;
@@ -2033,14 +2046,12 @@ mod tests {
20332046

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

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)
2052+
for (act, &ex) in bitv.iter().zip(bools.iter()) {
2053+
assert_eq!(ex, act);
2054+
}
20442055
}
20452056

20462057
#[test]
@@ -2050,12 +2061,6 @@ mod tests {
20502061

20512062
let idxs: Vec<uint> = bitv.iter().collect();
20522063
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);
20592064
}
20602065

20612066
#[test]
@@ -2569,7 +2574,7 @@ mod tests {
25692574
}
25702575

25712576
#[bench]
2572-
fn bench_bitv_set_big_fixed(b: &mut Bencher) {
2577+
fn bench_bitv_big(b: &mut Bencher) {
25732578
let mut r = rng();
25742579
let mut bitv = Bitv::with_capacity(BENCH_BITS, false);
25752580
b.iter(|| {
@@ -2581,19 +2586,7 @@ mod tests {
25812586
}
25822587

25832588
#[bench]
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) {
2589+
fn bench_bitv_small(b: &mut Bencher) {
25972590
let mut r = rng();
25982591
let mut bitv = Bitv::with_capacity(uint::BITS, false);
25992592
b.iter(|| {
@@ -2605,7 +2598,7 @@ mod tests {
26052598
}
26062599

26072600
#[bench]
2608-
fn bench_bitvset_small(b: &mut Bencher) {
2601+
fn bench_bitv_set_small(b: &mut Bencher) {
26092602
let mut r = rng();
26102603
let mut bitv = BitvSet::new();
26112604
b.iter(|| {
@@ -2617,7 +2610,7 @@ mod tests {
26172610
}
26182611

26192612
#[bench]
2620-
fn bench_bitvset_big(b: &mut Bencher) {
2613+
fn bench_bitv_set_big(b: &mut Bencher) {
26212614
let mut r = rng();
26222615
let mut bitv = BitvSet::new();
26232616
b.iter(|| {

trunk/src/liblibc/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4542,7 +4542,7 @@ pub mod funcs {
45424542
pub fn glob(pattern: *const c_char,
45434543
flags: c_int,
45444544
errfunc: ::Nullable<extern "C" fn(epath: *const c_char,
4545-
errno: c_int) -> int>,
4545+
errno: c_int) -> c_int>,
45464546
pglob: *mut glob_t);
45474547
pub fn globfree(pglob: *mut glob_t);
45484548
}

trunk/src/libnative/io/file_unix.rs

Lines changed: 24 additions & 12 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 unsafe { libc::fstat(self.fd(), &mut stat) } {
157+
match retry(|| unsafe { libc::fstat(self.fd(), &mut stat) }) {
158158
0 => Ok(mkstat(&stat)),
159159
_ => Err(super::last_error()),
160160
}
@@ -346,7 +346,9 @@ 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(unsafe { libc::mkdir(p.as_ptr(), mode as libc::mode_t) })
349+
super::mkerr_libc(retry(|| unsafe {
350+
libc::mkdir(p.as_ptr(), mode as libc::mode_t)
351+
}))
350352
}
351353

352354
pub fn readdir(p: &CString) -> IoResult<Vec<CString>> {
@@ -391,11 +393,13 @@ pub fn readdir(p: &CString) -> IoResult<Vec<CString>> {
391393
}
392394

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

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

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

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

411417
pub fn chown(p: &CString, uid: int, gid: int) -> IoResult<()> {
@@ -422,10 +428,10 @@ pub fn readlink(p: &CString) -> IoResult<CString> {
422428
len = 1024; // FIXME: read PATH_MAX from C ffi?
423429
}
424430
let mut buf: Vec<u8> = Vec::with_capacity(len as uint);
425-
match unsafe {
431+
match retry(|| unsafe {
426432
libc::readlink(p, buf.as_ptr() as *mut libc::c_char,
427433
len as libc::size_t) as libc::c_int
428-
} {
434+
}) {
429435
-1 => Err(super::last_error()),
430436
n => {
431437
assert!(n > 0);
@@ -436,11 +442,15 @@ pub fn readlink(p: &CString) -> IoResult<CString> {
436442
}
437443

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

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

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

480490
pub fn stat(p: &CString) -> IoResult<rtio::FileStat> {
481491
let mut stat: libc::stat = unsafe { mem::zeroed() };
482-
match unsafe { libc::stat(p.as_ptr(), &mut stat) } {
492+
match retry(|| unsafe { libc::stat(p.as_ptr(), &mut stat) }) {
483493
0 => Ok(mkstat(&stat)),
484494
_ => Err(super::last_error()),
485495
}
486496
}
487497

488498
pub fn lstat(p: &CString) -> IoResult<rtio::FileStat> {
489499
let mut stat: libc::stat = unsafe { mem::zeroed() };
490-
match unsafe { libc::lstat(p.as_ptr(), &mut stat) } {
500+
match retry(|| unsafe { libc::lstat(p.as_ptr(), &mut stat) }) {
491501
0 => Ok(mkstat(&stat)),
492502
_ => Err(super::last_error()),
493503
}
@@ -498,7 +508,9 @@ pub fn utime(p: &CString, atime: u64, mtime: u64) -> IoResult<()> {
498508
actime: (atime / 1000) as libc::time_t,
499509
modtime: (mtime / 1000) as libc::time_t,
500510
};
501-
super::mkerr_libc(unsafe { libc::utime(p.as_ptr(), &buf) })
511+
super::mkerr_libc(retry(|| unsafe {
512+
libc::utime(p.as_ptr(), &buf)
513+
}))
502514
}
503515

504516
#[cfg(test)]

trunk/src/librustc/middle/check_match.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ 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::{mod, Visitor, FnKind};
31+
use syntax::visit;
32+
use syntax::visit::{Visitor, FnKind};
3233
use util::ppaux::ty_to_string;
3334

3435
struct Matrix(Vec<Vec<Gc<Pat>>>);
@@ -102,9 +103,7 @@ pub enum Constructor {
102103
/// Ranges of literal values (2..5).
103104
ConstantRange(const_val, const_val),
104105
/// Array patterns of length n.
105-
Slice(uint),
106-
/// Array patterns with a subslice.
107-
SliceWithSubslice(uint, uint)
106+
Slice(uint)
108107
}
109108

110109
#[deriving(Clone, PartialEq)]
@@ -271,6 +270,13 @@ fn check_arms(cx: &MatchCheckCtxt, arms: &[Arm]) {
271270
}
272271
}
273272

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+
274280
fn check_exhaustive(cx: &MatchCheckCtxt, sp: Span, matrix: &Matrix) {
275281
match is_useful(cx, matrix, [wild()], ConstructWitness) {
276282
UsefulWithWitness(pats) => {
@@ -815,14 +821,6 @@ pub fn specialize(cx: &MatchCheckCtxt, r: &[Gc<Pat>],
815821
pats.push_all(after.as_slice());
816822
Some(pats)
817823
},
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-
}
826824
_ => None
827825
}
828826
}

trunk/src/librustc/middle/pat_util.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,6 @@ 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-
129122
pub fn def_to_path(tcx: &ty::ctxt, id: DefId) -> Path {
130123
ty::with_path(tcx, id, |mut path| Path {
131124
global: false,

0 commit comments

Comments
 (0)