Skip to content

Commit f73e182

Browse files
committed
---
yaml --- r: 149071 b: refs/heads/try2 c: 47ab5d2 h: refs/heads/master i: 149069: 6a84e74 149067: 73ca042 149063: c071740 149055: 9e7ff93 v: v3
1 parent e84225e commit f73e182

Some content is hidden

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

67 files changed

+358
-315
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 06a0c21c91b161781ee1aced0f2a9aed84cb4646
8+
refs/heads/try2: 47ab5d2d42aaf9e04afe6cc5aa84446e523d83ff
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/Makefile.in

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,9 @@ ifdef TRACE
126126
endif
127127
ifdef CFG_DISABLE_RPATH
128128
# NOTE: make this CFG_RUSTC_FLAGS after stage0 snapshot
129-
RUSTFLAGS_STAGE1 += --no-rpath
130-
RUSTFLAGS_STAGE2 += --no-rpath
131-
RUSTFLAGS_STAGE3 += --no-rpath
129+
RUSTFLAGS_STAGE1 += -C no-rpath
130+
RUSTFLAGS_STAGE2 += -C no-rpath
131+
RUSTFLAGS_STAGE3 += -C no-rpath
132132
endif
133133

134134
# The executables crated during this compilation process have no need to include

branches/try2/src/libarena/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ use std::rc::Rc;
4040
use std::rt::global_heap;
4141
use std::unstable::intrinsics::{TyDesc, get_tydesc};
4242
use std::unstable::intrinsics;
43-
use std::util;
4443
use std::vec;
4544

4645
// The way arena uses arrays is really deeply awful. The arrays are
@@ -404,7 +403,7 @@ impl TypedArenaChunk {
404403
}
405404

406405
// Destroy the next chunk.
407-
let next_opt = util::replace(&mut self.next, None);
406+
let next_opt = mem::replace(&mut self.next, None);
408407
match next_opt {
409408
None => {}
410409
Some(mut next) => {

branches/try2/src/libcollections/dlist.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
// the reverse direction.
2424

2525
use std::cast;
26+
use std::mem::{replace, swap};
2627
use std::ptr;
27-
use std::util;
2828
use std::iter::Rev;
2929
use std::iter;
3030

@@ -102,7 +102,7 @@ impl<T> Rawlink<T> {
102102

103103
/// Return the `Rawlink` and replace with `Rawlink::none()`
104104
fn take(&mut self) -> Rawlink<T> {
105-
util::replace(self, Rawlink::none())
105+
replace(self, Rawlink::none())
106106
}
107107
}
108108

@@ -161,7 +161,7 @@ impl<T> DList<T> {
161161
Some(ref mut head) => {
162162
new_head.prev = Rawlink::none();
163163
head.prev = Rawlink::some(new_head);
164-
util::swap(head, &mut new_head);
164+
swap(head, &mut new_head);
165165
head.next = Some(new_head);
166166
}
167167
}
@@ -319,7 +319,7 @@ impl<T> DList<T> {
319319
/// O(1)
320320
#[inline]
321321
pub fn prepend(&mut self, mut other: DList<T>) {
322-
util::swap(self, &mut other);
322+
swap(self, &mut other);
323323
self.append(other);
324324
}
325325

branches/try2/src/libcollections/list.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,26 @@ pub fn find<T:Clone>(ls: @List<T>, f: |&T| -> bool) -> Option<T> {
6363
};
6464
}
6565

66+
/**
67+
* Returns true if a list contains an element that matches a given predicate
68+
*
69+
* Apply function `f` to each element of `ls`, starting from the first.
70+
* When function `f` returns true then it also returns true. If `f` matches no
71+
* elements then false is returned.
72+
*/
73+
pub fn any<T>(ls: @List<T>, f: |&T| -> bool) -> bool {
74+
let mut ls = ls;
75+
loop {
76+
ls = match *ls {
77+
Cons(ref hd, tl) => {
78+
if f(hd) { return true; }
79+
tl
80+
}
81+
Nil => return false
82+
}
83+
};
84+
}
85+
6686
/// Returns true if a list contains an element with the given value
6787
pub fn has<T:Eq>(ls: @List<T>, elt: T) -> bool {
6888
let mut found = false;
@@ -222,6 +242,15 @@ mod tests {
222242
assert_eq!(list::find(empty, match_), option::None::<int>);
223243
}
224244

245+
#[test]
246+
fn test_any() {
247+
fn match_(i: &int) -> bool { return *i == 2; }
248+
let l = from_vec([0, 1, 2]);
249+
let empty = @list::Nil::<int>;
250+
assert_eq!(list::any(l, match_), true);
251+
assert_eq!(list::any(empty, match_), false);
252+
}
253+
225254
#[test]
226255
fn test_has() {
227256
let l = from_vec([5, 8, 6]);

branches/try2/src/libcollections/priority_queue.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
#[allow(missing_doc)];
1414

1515
use std::clone::Clone;
16-
use std::mem::{move_val_init, init};
17-
use std::util::{replace, swap};
16+
use std::mem::{move_val_init, init, replace, swap};
1817
use std::vec;
1918

2019
/// A priority queue implemented with a binary heap

branches/try2/src/libcollections/smallintmap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#[allow(missing_doc)];
1717

1818
use std::iter::{Enumerate, FilterMap, Rev};
19-
use std::util::replace;
19+
use std::mem::replace;
2020
use std::vec;
2121

2222
#[allow(missing_doc)]

branches/try2/src/libcollections/treemap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
//! trees. The only requirement for the types is that the key implements
1313
//! `TotalOrd`.
1414
15-
use std::util::{swap, replace};
1615
use std::iter::{Peekable};
1716
use std::cmp::Ordering;
17+
use std::mem::{replace, swap};
1818
use std::ptr;
1919

2020
use serialize::{Encodable, Decodable, Encoder, Decoder};

branches/try2/src/libextra/num/bigint.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2592,7 +2592,8 @@ mod bigint_tests {
25922592
#[cfg(test)]
25932593
mod bench {
25942594
use super::*;
2595-
use std::{iter, util};
2595+
use std::iter;
2596+
use std::mem::replace;
25962597
use std::num::{FromPrimitive, Zero, One};
25972598
use extra::test::BenchHarness;
25982599

@@ -2609,7 +2610,7 @@ mod bench {
26092610
let mut f1: BigUint = One::one();
26102611
for _ in range(0, n) {
26112612
let f2 = f0 + f1;
2612-
f0 = util::replace(&mut f1, f2);
2613+
f0 = replace(&mut f1, f2);
26132614
}
26142615
f0
26152616
}

branches/try2/src/libextra/stats.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
use std::cmp;
1414
use std::hashmap;
1515
use std::io;
16+
use std::mem;
1617
use std::num;
17-
use std::util;
1818

1919
// NB: this can probably be rewritten in terms of num::Num
2020
// to be less f64-specific.
@@ -178,7 +178,7 @@ impl<'a> Stats for &'a [f64] {
178178
for i in range(0, partials.len()) {
179179
let mut y = partials[i];
180180
if num::abs(x) < num::abs(y) {
181-
util::swap(&mut x, &mut y);
181+
mem::swap(&mut x, &mut y);
182182
}
183183
// Rounded `x+y` is stored in `hi` with round-off stored in
184184
// `lo`. Together `hi+lo` are exactly equal to `x+y`.

branches/try2/src/libgreen/basic.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
//! loop if no other one is provided (and M:N scheduling is desired).
1717
1818
use std::cast;
19+
use std::mem::replace;
1920
use std::rt::rtio::{EventLoop, IoFactory, RemoteCallback, PausableIdleCallback,
2021
Callback};
2122
use std::unstable::sync::Exclusive;
22-
use std::util;
2323

2424
/// This is the only exported function from this module.
2525
pub fn event_loop() -> ~EventLoop {
@@ -50,7 +50,7 @@ impl BasicLoop {
5050
/// Process everything in the work queue (continually)
5151
fn work(&mut self) {
5252
while self.work.len() > 0 {
53-
for work in util::replace(&mut self.work, ~[]).move_iter() {
53+
for work in replace(&mut self.work, ~[]).move_iter() {
5454
work();
5555
}
5656
}
@@ -60,7 +60,7 @@ impl BasicLoop {
6060
let messages = unsafe {
6161
self.messages.with(|messages| {
6262
if messages.len() > 0 {
63-
Some(util::replace(messages, ~[]))
63+
Some(replace(messages, ~[]))
6464
} else {
6565
None
6666
}

branches/try2/src/libgreen/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@
174174
// NB this does *not* include globs, please keep it that way.
175175
#[feature(macro_rules)];
176176

177+
use std::mem::replace;
177178
use std::os;
178179
use std::rt::crate_map;
179180
use std::rt::rtio;
@@ -182,7 +183,6 @@ use std::rt;
182183
use std::sync::atomics::{SeqCst, AtomicUint, INIT_ATOMIC_UINT};
183184
use std::sync::deque;
184185
use std::task::TaskOpts;
185-
use std::util;
186186
use std::vec;
187187
use std::sync::arc::UnsafeArc;
188188

@@ -457,10 +457,10 @@ impl SchedPool {
457457
}
458458

459459
// Now that everyone's gone, tell everything to shut down.
460-
for mut handle in util::replace(&mut self.handles, ~[]).move_iter() {
460+
for mut handle in replace(&mut self.handles, ~[]).move_iter() {
461461
handle.send(Shutdown);
462462
}
463-
for thread in util::replace(&mut self.threads, ~[]).move_iter() {
463+
for thread in replace(&mut self.threads, ~[]).move_iter() {
464464
thread.join();
465465
}
466466
}

branches/try2/src/librustc/middle/privacy.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
//! which are available for use externally when compiled as a library.
1414
1515
use std::hashmap::{HashSet, HashMap};
16-
use std::util;
16+
use std::mem::replace;
1717

1818
use metadata::csearch;
1919
use middle::resolve;
@@ -679,7 +679,7 @@ impl<'a> Visitor<()> for PrivacyVisitor<'a> {
679679
return;
680680
}
681681

682-
let orig_curitem = util::replace(&mut self.curitem, item.id);
682+
let orig_curitem = replace(&mut self.curitem, item.id);
683683
visit::walk_item(self, item, ());
684684
self.curitem = orig_curitem;
685685
}
@@ -861,7 +861,7 @@ impl Visitor<()> for SanePrivacyVisitor {
861861
self.check_sane_privacy(item);
862862
}
863863

864-
let orig_in_fn = util::replace(&mut self.in_fn, match item.node {
864+
let orig_in_fn = replace(&mut self.in_fn, match item.node {
865865
ast::ItemMod(..) => false, // modules turn privacy back on
866866
_ => self.in_fn, // otherwise we inherit
867867
});
@@ -872,7 +872,7 @@ impl Visitor<()> for SanePrivacyVisitor {
872872
fn visit_fn(&mut self, fk: &visit::FnKind, fd: &ast::FnDecl,
873873
b: &ast::Block, s: Span, n: ast::NodeId, _: ()) {
874874
// This catches both functions and methods
875-
let orig_in_fn = util::replace(&mut self.in_fn, true);
875+
let orig_in_fn = replace(&mut self.in_fn, true);
876876
visit::walk_fn(self, fk, fd, b, s, n, ());
877877
self.in_fn = orig_in_fn;
878878
}

branches/try2/src/librustc/middle/resolve.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use syntax::visit::Visitor;
3131
use std::cell::{Cell, RefCell};
3232
use std::uint;
3333
use std::hashmap::{HashMap, HashSet};
34-
use std::util;
34+
use std::mem::replace;
3535

3636
// Definition mapping
3737
pub type DefMap = @RefCell<HashMap<NodeId,Def>>;
@@ -4067,7 +4067,7 @@ impl Resolver {
40674067
new_trait_refs.push(def_id_of_def(*def));
40684068
}
40694069
}
4070-
original_trait_refs = Some(util::replace(
4070+
original_trait_refs = Some(replace(
40714071
&mut this.current_trait_refs,
40724072
Some(new_trait_refs)));
40734073
}

branches/try2/src/librustc/middle/trans/base.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1506,16 +1506,19 @@ pub fn trans_closure<'a>(ccx: @CrateContext,
15061506
// emitting should be enabled.
15071507
debuginfo::start_emitting_source_locations(&fcx);
15081508

1509+
let dest = match fcx.llretptr.get() {
1510+
Some(e) => {expr::SaveIn(e)}
1511+
None => {
1512+
assert!(type_is_zero_size(bcx.ccx(), block_ty))
1513+
expr::Ignore
1514+
}
1515+
};
1516+
15091517
// This call to trans_block is the place where we bridge between
15101518
// translation calls that don't have a return value (trans_crate,
15111519
// trans_mod, trans_item, et cetera) and those that do
15121520
// (trans_block, trans_expr, et cetera).
1513-
if body.expr.is_none() || type_is_zero_size(bcx.ccx(), block_ty) {
1514-
bcx = controlflow::trans_block(bcx, body, expr::Ignore);
1515-
} else {
1516-
let dest = expr::SaveIn(fcx.llretptr.get().unwrap());
1517-
bcx = controlflow::trans_block(bcx, body, dest);
1518-
}
1521+
bcx = controlflow::trans_block(bcx, body, dest);
15191522

15201523
match fcx.llreturn.get() {
15211524
Some(_) => {

branches/try2/src/librustc/middle/trans/controlflow.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ pub fn trans_stmt<'a>(cx: &'a Block<'a>,
7474

7575
pub fn trans_block<'a>(bcx: &'a Block<'a>,
7676
b: &ast::Block,
77-
dest: expr::Dest)
77+
mut dest: expr::Dest)
7878
-> &'a Block<'a> {
7979
let _icx = push_ctxt("trans_block");
8080
let fcx = bcx.fcx;
@@ -85,6 +85,14 @@ pub fn trans_block<'a>(bcx: &'a Block<'a>,
8585
for s in b.stmts.iter() {
8686
bcx = trans_stmt(bcx, *s);
8787
}
88+
89+
if dest != expr::Ignore {
90+
let block_ty = node_id_type(bcx, b.id);
91+
if b.expr.is_none() || type_is_zero_size(bcx.ccx(), block_ty) {
92+
dest = expr::Ignore;
93+
}
94+
}
95+
8896
match b.expr {
8997
Some(e) => {
9098
bcx = expr::trans_into(bcx, e, dest);

branches/try2/src/librustc/middle/typeck/check/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ use util::ppaux::{UserString, Repr};
115115

116116
use std::cell::{Cell, RefCell};
117117
use std::hashmap::HashMap;
118+
use std::mem::replace;
118119
use std::result;
119-
use std::util::replace;
120120
use std::vec;
121121
use syntax::abi::AbiSet;
122122
use syntax::ast::{Provided, Required};

branches/try2/src/librustdoc/fold.rs

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

11-
use std;
1211
use clean::*;
1312
use std::iter::Extendable;
13+
use std::mem::{replace, swap};
1414

1515
pub trait DocFolder {
1616
fn fold_item(&mut self, item: Item) -> Option<Item> {
@@ -19,7 +19,6 @@ pub trait DocFolder {
1919

2020
/// don't override!
2121
fn fold_item_recur(&mut self, item: Item) -> Option<Item> {
22-
use std::util::swap;
2322
let Item { attrs, name, source, visibility, id, inner } = item;
2423
let inner = inner;
2524
let c = |x| self.fold_item(x);
@@ -92,7 +91,7 @@ pub trait DocFolder {
9291
}
9392

9493
fn fold_crate(&mut self, mut c: Crate) -> Crate {
95-
c.module = match std::util::replace(&mut c.module, None) {
94+
c.module = match replace(&mut c.module, None) {
9695
Some(module) => self.fold_item(module), None => None
9796
};
9897
return c;

0 commit comments

Comments
 (0)