}
fn check_err<T: Decodable<Decoder>>(to_parse: &'static str, expected_error: &str) {
use std::task;
- let res = task::try(|| {
+ let res = do task::try {
// either fails in `decode` (which is what we want), or
// returns Some(error_message)/None if the string was
// invalid or valid JSON.
None
}
}
- });
+ };
match res {
Ok(Some(parse_error)) => fail!("`{}` is not valid json: {}",
to_parse, parse_error),
}).finally(|| {
// Reacquire the condvar.
match self.order {
- Just(lock) => do lock.access {
- self.sem.acquire();
- },
- Nothing => {
- self.sem.acquire();
- },
+ Just(lock) => lock.access(|| self.sem.acquire()),
+ Nothing => self.sem.acquire(),
}
})
})
// Windows does not understand "America/Los_Angeles".
// PST+08 may look wrong, but not! "PST" indicates
// the name of timezone. "+08" means UTC = local + 08.
- do "TZ=PST+08".with_c_str |env| {
+ "TZ=PST+08".with_c_str(|env| {
_putenv(env);
- }
+ })
}
tzset();
}
}
fn visit_foreign_item(&mut self, it: @ast::foreign_item, _: ()) {
- do self.with_lint_attrs(it.attrs) |cx| {
+ self.with_lint_attrs(it.attrs, |cx| {
check_attrs_usage(cx, it.attrs);
visit::walk_foreign_item(cx, it, ());
- }
+ })
}
fn visit_view_item(&mut self, i: &ast::view_item, _: ()) {
- do self.with_lint_attrs(i.attrs) |cx| {
+ self.with_lint_attrs(i.attrs, |cx| {
check_attrs_usage(cx, i.attrs);
visit::walk_view_item(cx, i, ());
- }
+ })
}
fn visit_pat(&mut self, p: &ast::Pat, _: ()) {
_ => true,
};
let tr = ty::impl_trait_ref(self.tcx, local_def(item.id));
- let public_trait = do tr.map_default(false) |tr| {
+ let public_trait = tr.map_default(false, |tr| {
!is_local(tr.def_id) ||
self.exported_items.contains(&tr.def_id.node)
- };
+ });
if public_ty || public_trait {
for method in methods.iter() {
prep.declare_input("file",
foo_c_name.as_str().unwrap().to_owned(),
digest_file_with_date(&foo_c_name));
- let out_path = prep.exec(|exec| {
+ let out_path = do prep.exec |exec| {
let out_path = api::build_library_in_workspace(exec,
&mut sub_cx.clone(),
"cdep",
"foo");
let out_p = Path::new(out_path);
out_p.as_str().unwrap().to_owned()
- });
+ };
out_path
});
let out_lib_path = Path::new(out_lib_path);
0 => {
req.defuse(); // uv callback now owns this request
let mut cx = Ctx { status: 0, task: None };
- do wait_until_woken_after(&mut cx.task) {
+ wait_until_woken_after(&mut cx.task, || {
req.set_data(&cx);
- }
+ });
match cx.status {
0 => Ok(()),
n => Err(UvError(n)),
}
}
-impl<T> Clone for RcMut<T> {
- /// Return a shallow copy of the reference counted pointer.
- #[inline]
- fn clone(&self) -> RcMut<T> {
- unsafe {
- (*self.ptr).count += 1;
- RcMut{ptr: self.ptr}
- }
- }
-}
-
-impl<T: DeepClone> DeepClone for RcMut<T> {
- /// Return a deep copy of the reference counted pointer.
- #[inline]
- fn deep_clone(&self) -> RcMut<T> {
- self.with_borrow(|x| {
- // FIXME: #6497: should avoid freeze (slow)
- unsafe { RcMut::new_unchecked(x.deep_clone()) }
- })
- }
-}
-
#[cfg(test)]
mod test_rc {
use super::*;
assert!(take() == Some(expected.clone()));
assert!(take() == None);
- do (|| {
- }).finally {
+ (|| {
+ }).finally(|| {
// Restore the actual global state.
match saved_value {
Some(ref args) => put(args.clone()),
None => ()
}
- }
+ })
}
}
}
#[test]
fn recv_a_lot() {
// Regression test that we don't run out of stack in scheduler context
- run_in_newsched_task(|| {
+ do run_in_newsched_task {
let (port, chan) = stream();
10000.times(|| { chan.send(()) });
10000.times(|| { port.recv() });
- })
+ }
}
#[test]
let c = Cell::new(c.take());
do sched.event_loop.callback { c.take().send_deferred(()) }
- }
+ })
}).finally(|| {
// Unkillable is necessary not because getting killed is dangerous here,
// but to force the recv not to use the same kill-flag that we used for
/// block; otherwise, an unwrapping task can be killed by linked failure.
pub fn unwrap(self) -> T {
unsafe {
- let mut this = this;
+ let mut this = self;
// The ~ dtor needs to run if this code succeeds.
let mut data: ~ArcData<T> = cast::transmute(this.data);
// Set up the unwrap protocol.
cast::forget(data);
fail!("Another task is already unwrapping this Arc!");
}
- })
+ }
}
/// As unwrap above, but without blocking. Returns 'UnsafeArcSelf(self)' if this is
/// Returns an iterator over the subslices of the vector which are
/// separated by elements that match `pred`, limited to splitting
/// at most `n` times.
- fn splitn(self, n: uint, pred: |&T| -> bool) -> SplitIterator<'self, T>;
+ fn splitn(self, n: uint, pred: 'self |&T| -> bool) -> SplitIterator<'self, T>;
/// Returns an iterator over the subslices of the vector which are
/// separated by elements that match `pred`. This starts at the
/// end of the vector and works backwards.
- fn rsplit(self, pred: |&T| -> bool) -> RSplitIterator<'self, T>;
+ fn rsplit(self, pred: 'self |&T| -> bool) -> RSplitIterator<'self, T>;
/// Returns an iterator over the subslices of the vector which are
/// separated by elements that match `pred` limited to splitting
/// at most `n` times. This starts at the end of the vector and
+// xfail-pretty
+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
let (pp, cc) = stream();
let cc = SharedChan::new(cc);
let ch = cc.clone();
- task::spawn(|| pfib(&ch, n - 1) );
+ task::spawn(proc() pfib(&ch, n - 1));
let ch = cc.clone();
- task::spawn(|| pfib(&ch, n - 2) );
+ task::spawn(proc() pfib(&ch, n - 2));
c.send(pp.recv() + pp.recv());
}
}
fn f(n: uint) {
let mut i = 0u;
while i < n {
- task::try(|| g() );
+ task::try(proc() g());
i += 1u;
}
}
zzz();
sentinel();
- let unique_closure: proc(int) = |x| {
+ let unique_closure: proc(int) = proc(x) {
zzz();
sentinel();
let owned = ~5;
- let closure: proc() = || {
+ let closure: proc() = proc() {
zzz();
do_something(&constant, &a_struct.a, owned);
};
fn id(f: || -> int) -> int { f() }
-fn wsucc(_n: int) -> int { (do id || { 1 }) - 0 }
+fn wsucc(_n: int) -> int { id(|| { 1 }) - 0 }
fn main() { }
fn f(f: |int|) { f(10) }
-fn main() { do f |i| { assert!(i == 10) } }
+fn main() { f(|i| { assert!(i == 10) }) }
+// xfail-pretty
+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
+// xfail-pretty
+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
+// xfail-pretty
+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
+// xfail-pretty
+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.