diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2014-03-22 00:55:50 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-03-24 17:17:46 -0700 |
| commit | 5163a26d30c1fcbdee939c93cc19a41cc5dbcaf8 (patch) | |
| tree | cd27c095559478991ca8b967a57f52a4d22cfb65 | |
| parent | eff025797a6dc58dad724e8523223d07025ac697 (diff) | |
| download | rust-5163a26d30c1fcbdee939c93cc19a41cc5dbcaf8.tar.gz rust-5163a26d30c1fcbdee939c93cc19a41cc5dbcaf8.zip | |
test: Update all tests with the sync changes
27 files changed, 80 insertions, 324 deletions
diff --git a/src/doc/guide-tasks.md b/src/doc/guide-tasks.md index 9f8e5c727bd..2ffa4529f08 100644 --- a/src/doc/guide-tasks.md +++ b/src/doc/guide-tasks.md @@ -359,7 +359,7 @@ fn main() { spawn(proc() { let local_arc : Arc<~[f64]> = rx.recv(); - let task_numbers = local_arc.get(); + let task_numbers = &*local_arc; println!("{}-norm = {}", num, pnorm(task_numbers, num)); }); } @@ -411,7 +411,7 @@ Each task recovers the underlying data by # let (tx, rx) = channel(); # tx.send(numbers_arc.clone()); # let local_arc : Arc<~[f64]> = rx.recv(); -let task_numbers = local_arc.get(); +let task_numbers = &*local_arc; # } ~~~ diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index a8f243139d2..acf6446a191 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -208,8 +208,8 @@ fn path(w: &mut io::Writer, path: &clean::Path, print_all: bool, let loc = loc.unwrap(); local_data::get(cache_key, |cache| { - let cache = cache.unwrap().get(); - let abs_root = root(cache, loc.as_slice()); + let cache = cache.unwrap(); + let abs_root = root(&**cache, loc.as_slice()); let rel_root = match path.segments.get(0).name.as_slice() { "self" => Some(~"./"), _ => None, @@ -241,7 +241,7 @@ fn path(w: &mut io::Writer, path: &clean::Path, print_all: bool, } } - match info(cache) { + match info(&**cache) { // This is a documented path, link to it! Some((ref fqp, shortty)) if abs_root.is_some() => { let mut url = abs_root.unwrap(); @@ -301,7 +301,7 @@ impl fmt::Show for clean::Type { match *self { clean::TyParamBinder(id) | clean::Generic(id) => { local_data::get(cache_key, |cache| { - let m = cache.unwrap().get(); + let m = cache.unwrap(); f.buf.write(m.typarams.get(&id).as_bytes()) }) } diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 66b965633a0..d2a34bc4e4a 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -1265,7 +1265,7 @@ fn item_trait(w: &mut Writer, it: &clean::Item, } local_data::get(cache_key, |cache| { - let cache = cache.unwrap().get(); + let cache = cache.unwrap(); match cache.implementors.find(&it.id) { Some(implementors) => { try!(write!(w, " @@ -1496,7 +1496,7 @@ fn render_struct(w: &mut Writer, it: &clean::Item, fn render_methods(w: &mut Writer, it: &clean::Item) -> fmt::Result { local_data::get(cache_key, |cache| { - let c = cache.unwrap().get(); + let c = cache.unwrap(); match c.impls.find(&it.id) { Some(v) => { let mut non_trait = v.iter().filter(|p| { @@ -1576,7 +1576,7 @@ fn render_impl(w: &mut Writer, i: &clean::Impl, Some(id) => id, }; try!(local_data::get(cache_key, |cache| { - let cache = cache.unwrap().get(); + let cache = cache.unwrap(); match cache.traits.find(&trait_id) { Some(t) => { let name = meth.name.clone(); @@ -1606,7 +1606,7 @@ fn render_impl(w: &mut Writer, i: &clean::Impl, None => {} Some(id) => { try!(local_data::get(cache_key, |cache| { - let cache = cache.unwrap().get(); + let cache = cache.unwrap(); match cache.traits.find(&id) { Some(t) => { for method in t.methods.iter() { diff --git a/src/libworkcache/lib.rs b/src/libworkcache/lib.rs index 79ed15655cc..9c0328d4b11 100644 --- a/src/libworkcache/lib.rs +++ b/src/libworkcache/lib.rs @@ -26,7 +26,7 @@ extern crate sync; use serialize::json; use serialize::json::ToJson; use serialize::{Encoder, Encodable, Decoder, Decodable}; -use sync::{Arc,RWArc}; +use sync::{Arc, RWLock}; use collections::TreeMap; use std::str; use std::io; @@ -225,7 +225,7 @@ pub type FreshnessMap = TreeMap<~str,extern fn(&str,&str)->bool>; #[deriving(Clone)] pub struct Context { - db: RWArc<Database>, + db: Arc<RWLock<Database>>, priv cfg: Arc<json::Object>, /// Map from kinds (source, exe, url, etc.) to a freshness function. /// The freshness function takes a name (e.g. file path) and value @@ -269,12 +269,12 @@ fn json_decode<T:Decodable<json::Decoder>>(s: &str) -> T { impl Context { - pub fn new(db: RWArc<Database>, + pub fn new(db: Arc<RWLock<Database>>, cfg: Arc<json::Object>) -> Context { Context::new_with_freshness(db, cfg, Arc::new(TreeMap::new())) } - pub fn new_with_freshness(db: RWArc<Database>, + pub fn new_with_freshness(db: Arc<RWLock<Database>>, cfg: Arc<json::Object>, freshness: Arc<FreshnessMap>) -> Context { Context { @@ -364,7 +364,7 @@ impl<'a> Prep<'a> { fn is_fresh(&self, cat: &str, kind: &str, name: &str, val: &str) -> bool { let k = kind.to_owned(); - let f = self.ctxt.freshness.get().find(&k); + let f = self.ctxt.freshness.deref().find(&k); debug!("freshness for: {}/{}/{}/{}", cat, kind, name, val) let fresh = match f { None => fail!("missing freshness-function for '{}'", kind), @@ -406,9 +406,10 @@ impl<'a> Prep<'a> { debug!("exec_work: looking up {} and {:?}", self.fn_name, self.declared_inputs); - let cached = self.ctxt.db.read(|db| { - db.prepare(self.fn_name, &self.declared_inputs) - }); + let cached = { + let db = self.ctxt.db.deref().read(); + db.deref().prepare(self.fn_name, &self.declared_inputs) + }; match cached { Some((ref disc_in, ref disc_out, ref res)) @@ -460,13 +461,12 @@ impl<'a, T:Send + WorkFromTask(prep, port) => { let (exe, v) = port.recv(); let s = json_encode(&v); - prep.ctxt.db.write(|db| { - db.cache(prep.fn_name, - &prep.declared_inputs, - &exe.discovered_inputs, - &exe.discovered_outputs, - s) - }); + let mut db = prep.ctxt.db.deref().write(); + db.deref_mut().cache(prep.fn_name, + &prep.declared_inputs, + &exe.discovered_inputs, + &exe.discovered_outputs, + s); v } } @@ -496,7 +496,7 @@ fn test() { let db_path = make_path(~"db.json"); - let cx = Context::new(RWArc::new(Database::new(db_path)), + let cx = Context::new(Arc::new(RWLock::new(Database::new(db_path))), Arc::new(TreeMap::new())); let s = cx.with_prep("test1", |prep| { diff --git a/src/test/bench/msgsend-ring-mutex-arcs.rs b/src/test/bench/msgsend-ring-mutex-arcs.rs index a3a6bbeb9a6..b24dc588bab 100644 --- a/src/test/bench/msgsend-ring-mutex-arcs.rs +++ b/src/test/bench/msgsend-ring-mutex-arcs.rs @@ -18,36 +18,28 @@ extern crate sync; extern crate time; -use sync::Arc; -use sync::MutexArc; -use sync::Future; +use sync::{Arc, Future, Mutex}; use std::os; use std::uint; // A poor man's pipe. -type pipe = MutexArc<Vec<uint> >; +type pipe = Arc<Mutex<Vec<uint>>>; fn send(p: &pipe, msg: uint) { - unsafe { - p.access_cond(|state, cond| { - state.push(msg); - cond.signal(); - }) - } + let mut arr = p.lock(); + arr.push(msg); + arr.cond.signal(); } fn recv(p: &pipe) -> uint { - unsafe { - p.access_cond(|state, cond| { - while state.is_empty() { - cond.wait(); - } - state.pop().unwrap() - }) + let mut arr = p.lock(); + while arr.is_empty() { + arr.cond.wait(); } + arr.pop().unwrap() } fn init() -> (pipe,pipe) { - let m = MutexArc::new(Vec::new()); + let m = Arc::new(Mutex::new(Vec::new())); ((&m).clone(), m) } diff --git a/src/test/bench/msgsend-ring-rw-arcs.rs b/src/test/bench/msgsend-ring-rw-arcs.rs index 4827712c2e2..8e4a34384e8 100644 --- a/src/test/bench/msgsend-ring-rw-arcs.rs +++ b/src/test/bench/msgsend-ring-rw-arcs.rs @@ -18,31 +18,29 @@ extern crate sync; extern crate time; -use sync::RWArc; +use sync::{RWLock, Arc}; use sync::Future; use std::os; use std::uint; // A poor man's pipe. -type pipe = RWArc<Vec<uint> >; +type pipe = Arc<RWLock<Vec<uint>>>; fn send(p: &pipe, msg: uint) { - p.write_cond(|state, cond| { - state.push(msg); - cond.signal(); - }) + let mut arr = p.write(); + arr.push(msg); + arr.cond.signal(); } fn recv(p: &pipe) -> uint { - p.write_cond(|state, cond| { - while state.is_empty() { - cond.wait(); - } - state.pop().unwrap() - }) + let mut arr = p.write(); + while arr.is_empty() { + arr.cond.wait(); + } + arr.pop().unwrap() } fn init() -> (pipe,pipe) { - let x = RWArc::new(Vec::new()); + let x = Arc::new(RWLock::new(Vec::new())); ((&x).clone(), x) } diff --git a/src/test/bench/shootout-spectralnorm.rs b/src/test/bench/shootout-spectralnorm.rs index a1fa3ff0619..939f8eaab68 100644 --- a/src/test/bench/shootout-spectralnorm.rs +++ b/src/test/bench/shootout-spectralnorm.rs @@ -14,7 +14,8 @@ use std::from_str::FromStr; use std::iter::count; use std::cmp::min; use std::os; -use sync::RWArc; +use std::slice::from_elem; +use sync::{Arc, RWLock}; fn A(i: uint, j: uint) -> f64 { ((i + j) * (i + j + 1) / 2 + i + 1) as f64 @@ -28,17 +29,16 @@ fn dot(v: &[f64], u: &[f64]) -> f64 { sum } -fn mult(v: RWArc<Vec<f64>>, - out: RWArc<Vec<f64>>, +fn mult(v: Arc<RWLock<Vec<f64>>>, out: Arc<RWLock<Vec<f64>>>, f: fn(&Vec<f64>, uint) -> f64) { - // We launch in different tasks the work to be done. To finish + // We lanch in different tasks the work to be done. To finish // this fuction, we need to wait for the completion of every // tasks. To do that, we give to each tasks a wait_chan that we // drop at the end of the work. At the end of this function, we // wait until the channel hang up. let (tx, rx) = channel(); - let len = out.read(|out| out.len()); + let len = out.read().len(); let chunk = len / 100 + 1; for chk in count(0, chunk) { if chk >= len {break;} @@ -47,8 +47,8 @@ fn mult(v: RWArc<Vec<f64>>, let out = out.clone(); spawn(proc() { for i in range(chk, min(len, chk + chunk)) { - let val = v.read(|v| f(v, i)); - out.write(|out| *out.get_mut(i) = val); + let val = f(&*v.read(), i); + *out.write().get_mut(i) = val; } drop(tx) }); @@ -67,7 +67,7 @@ fn mult_Av_impl(v: &Vec<f64> , i: uint) -> f64 { sum } -fn mult_Av(v: RWArc<Vec<f64> >, out: RWArc<Vec<f64> >) { +fn mult_Av(v: Arc<RWLock<Vec<f64>>>, out: Arc<RWLock<Vec<f64>>>) { mult(v, out, mult_Av_impl); } @@ -79,11 +79,12 @@ fn mult_Atv_impl(v: &Vec<f64> , i: uint) -> f64 { sum } -fn mult_Atv(v: RWArc<Vec<f64> >, out: RWArc<Vec<f64> >) { +fn mult_Atv(v: Arc<RWLock<Vec<f64>>>, out: Arc<RWLock<Vec<f64>>>) { mult(v, out, mult_Atv_impl); } -fn mult_AtAv(v: RWArc<Vec<f64> >, out: RWArc<Vec<f64> >, tmp: RWArc<Vec<f64> >) { +fn mult_AtAv(v: Arc<RWLock<Vec<f64>>>, out: Arc<RWLock<Vec<f64>>>, + tmp: Arc<RWLock<Vec<f64>>>) { mult_Av(v, tmp.clone()); mult_Atv(tmp, out); } @@ -97,16 +98,16 @@ fn main() { } else { FromStr::from_str(args[1]).unwrap() }; - let u = RWArc::new(Vec::from_elem(n, 1.)); - let v = RWArc::new(Vec::from_elem(n, 1.)); - let tmp = RWArc::new(Vec::from_elem(n, 1.)); + let u = Arc::new(RWLock::new(Vec::from_elem(n, 1.))); + let v = Arc::new(RWLock::new(Vec::from_elem(n, 1.))); + let tmp = Arc::new(RWLock::new(Vec::from_elem(n, 1.))); for _ in range(0, 10) { mult_AtAv(u.clone(), v.clone(), tmp.clone()); mult_AtAv(v.clone(), u.clone(), tmp.clone()); } - u.read(|u| v.read(|v| { - println!("{:.9f}", - (dot(u.as_slice(), v.as_slice()) / dot(v.as_slice(), v.as_slice())).sqrt()); - })) + let u = u.read(); + let v = v.read(); + println!("{:.9f}", (dot(u.as_slice(), v.as_slice()) / + dot(v.as_slice(), v.as_slice())).sqrt()); } diff --git a/src/test/compile-fail/arc-cant-nest-rw-arc-3177.rs b/src/test/compile-fail/arc-cant-nest-rw-arc-3177.rs deleted file mode 100644 index 151f4940d57..00000000000 --- a/src/test/compile-fail/arc-cant-nest-rw-arc-3177.rs +++ /dev/null @@ -1,17 +0,0 @@ -// 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. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate sync; -use sync::RWArc; - -fn main() { - let arc1 = RWArc::new(true); - let _arc2 = RWArc::new(arc1); //~ ERROR instantiating a type parameter with an incompatible type -} diff --git a/src/test/compile-fail/arc-rw-cond-shouldnt-escape.rs b/src/test/compile-fail/arc-rw-cond-shouldnt-escape.rs deleted file mode 100644 index 71d42d46e7c..00000000000 --- a/src/test/compile-fail/arc-rw-cond-shouldnt-escape.rs +++ /dev/null @@ -1,19 +0,0 @@ -// 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. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: lifetime of return value does not outlive the function call -extern crate sync; -use sync::RWArc; -fn main() { - let x = ~RWArc::new(1); - let mut y = None; - x.write_cond(|_one, cond| y = Some(cond)); - y.unwrap().wait(); -} diff --git a/src/test/compile-fail/arc-rw-read-mode-shouldnt-escape.rs b/src/test/compile-fail/arc-rw-read-mode-shouldnt-escape.rs deleted file mode 100644 index 1787cd5d0b4..00000000000 --- a/src/test/compile-fail/arc-rw-read-mode-shouldnt-escape.rs +++ /dev/null @@ -1,23 +0,0 @@ -// 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. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate sync; -use sync::RWArc; -fn main() { - let x = ~RWArc::new(1); - let mut y = None; - x.write_downgrade(|write_mode| { - y = Some(x.downgrade(write_mode)); - //~^ ERROR cannot infer - }); - y.unwrap(); - // Adding this line causes a method unification failure instead - // (&option::unwrap(y)).read(|state| { assert!(*state == 1); }) -} diff --git a/src/test/compile-fail/arc-rw-state-shouldnt-escape.rs b/src/test/compile-fail/arc-rw-state-shouldnt-escape.rs deleted file mode 100644 index cccca050696..00000000000 --- a/src/test/compile-fail/arc-rw-state-shouldnt-escape.rs +++ /dev/null @@ -1,20 +0,0 @@ -// 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. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate sync; -use sync::RWArc; -fn main() { - let x = ~RWArc::new(1); - let mut y = None; //~ ERROR lifetime of variable does not enclose its declaration - x.write(|one| y = Some(one)); - *y.unwrap() = 2; - //~^ ERROR lifetime of return value does not outlive the function call - //~^^ ERROR dereference of reference outside its lifetime -} diff --git a/src/test/compile-fail/arc-rw-write-mode-cond-shouldnt-escape.rs b/src/test/compile-fail/arc-rw-write-mode-cond-shouldnt-escape.rs deleted file mode 100644 index a08cb055020..00000000000 --- a/src/test/compile-fail/arc-rw-write-mode-cond-shouldnt-escape.rs +++ /dev/null @@ -1,23 +0,0 @@ -// 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. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: lifetime of variable does not enclose its declaration -extern crate sync; -use sync::RWArc; -fn main() { - let x = ~RWArc::new(1); - let mut y = None; - x.write_downgrade(|write_mode| { - (&write_mode).write_cond(|_one, cond| { - y = Some(cond); - }) - }); - y.unwrap().wait(); -} diff --git a/src/test/compile-fail/arc-rw-write-mode-shouldnt-escape.rs b/src/test/compile-fail/arc-rw-write-mode-shouldnt-escape.rs deleted file mode 100644 index 8f93d672b90..00000000000 --- a/src/test/compile-fail/arc-rw-write-mode-shouldnt-escape.rs +++ /dev/null @@ -1,21 +0,0 @@ -// 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. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: lifetime of variable does not enclose its declaration -extern crate sync; -use sync::RWArc; -fn main() { - let x = ~RWArc::new(1); - let mut y = None; - x.write_downgrade(|write_mode| y = Some(write_mode)); - y.unwrap(); - // Adding this line causes a method unification failure instead - // (&option::unwrap(y)).write(|state| { assert!(*state == 1); }) -} diff --git a/src/test/compile-fail/functional-struct-update-noncopyable.rs b/src/test/compile-fail/functional-struct-update-noncopyable.rs index 244ae47a277..0ba4db4f211 100644 --- a/src/test/compile-fail/functional-struct-update-noncopyable.rs +++ b/src/test/compile-fail/functional-struct-update-noncopyable.rs @@ -17,7 +17,7 @@ use sync::Arc; struct A { y: Arc<int>, x: Arc<int> } impl Drop for A { - fn drop(&mut self) { println!("x={:?}", self.x.get()); } + fn drop(&mut self) { println!("x={}", *self.x); } } fn main() { let a = A { y: Arc::new(1), x: Arc::new(2) }; diff --git a/src/test/compile-fail/no-capture-arc.rs b/src/test/compile-fail/no-capture-arc.rs index e76c31469ea..7e71b6fdf28 100644 --- a/src/test/compile-fail/no-capture-arc.rs +++ b/src/test/compile-fail/no-capture-arc.rs @@ -20,11 +20,10 @@ fn main() { let arc_v = Arc::new(v); task::spawn(proc() { - let v = arc_v.get(); - assert_eq!(*v.get(3), 4); + assert_eq!(*arc_v.get(3), 4); }); - assert_eq!(*(arc_v.get()).get(2), 3); + assert_eq!(*arc_v.get(2), 3); - println!("{:?}", arc_v); + println!("{}", *arc_v); } diff --git a/src/test/compile-fail/no-reuse-move-arc.rs b/src/test/compile-fail/no-reuse-move-arc.rs index 29f62ff6e1b..83e0ae0218c 100644 --- a/src/test/compile-fail/no-reuse-move-arc.rs +++ b/src/test/compile-fail/no-reuse-move-arc.rs @@ -18,11 +18,10 @@ fn main() { let arc_v = Arc::new(v); task::spawn(proc() { - let v = arc_v.get(); - assert_eq!(*v.get(3), 4); + assert_eq!(*arc_v.get(3), 4); }); - assert_eq!(*(arc_v.get()).get(2), 3); //~ ERROR use of moved value: `arc_v` + assert_eq!(*arc_v.get(2), 3); //~ ERROR use of moved value: `arc_v` - println!("{:?}", arc_v); //~ ERROR use of moved value: `arc_v` + println!("{}", *arc_v); //~ ERROR use of moved value: `arc_v` } diff --git a/src/test/compile-fail/once-cant-call-twice-on-heap.rs b/src/test/compile-fail/once-cant-call-twice-on-heap.rs index 675dcf95595..c9ee105fe7b 100644 --- a/src/test/compile-fail/once-cant-call-twice-on-heap.rs +++ b/src/test/compile-fail/once-cant-call-twice-on-heap.rs @@ -23,7 +23,7 @@ fn foo(blk: proc()) { fn main() { let x = Arc::new(true); foo(proc() { - assert!(*x.get()); + assert!(*x); drop(x); }); } diff --git a/src/test/compile-fail/once-cant-call-twice-on-stack.rs b/src/test/compile-fail/once-cant-call-twice-on-stack.rs index 48dd484c1c2..a81ddf06ac8 100644 --- a/src/test/compile-fail/once-cant-call-twice-on-stack.rs +++ b/src/test/compile-fail/once-cant-call-twice-on-stack.rs @@ -23,7 +23,7 @@ fn foo(blk: once ||) { fn main() { let x = Arc::new(true); foo(|| { - assert!(*x.get()); + assert!(*x); drop(x); }) } diff --git a/src/test/compile-fail/once-cant-move-out-of-non-once-on-stack.rs b/src/test/compile-fail/once-cant-move-out-of-non-once-on-stack.rs index 804ea46b426..8f3f9cf74db 100644 --- a/src/test/compile-fail/once-cant-move-out-of-non-once-on-stack.rs +++ b/src/test/compile-fail/once-cant-move-out-of-non-once-on-stack.rs @@ -22,7 +22,7 @@ fn foo(blk: ||) { fn main() { let x = Arc::new(true); foo(|| { - assert!(*x.get()); + assert!(*x); drop(x); //~ ERROR cannot move out of captured outer variable }) } diff --git a/src/test/compile-fail/sync-cond-shouldnt-escape.rs b/src/test/compile-fail/sync-cond-shouldnt-escape.rs deleted file mode 100644 index 4ba1c5c7cfe..00000000000 --- a/src/test/compile-fail/sync-cond-shouldnt-escape.rs +++ /dev/null @@ -1,22 +0,0 @@ -// 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. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: lifetime of variable does not enclose its declaration -extern crate sync; -use sync::Mutex; - -fn main() { - let m = ~sync::Mutex::new(); - let mut cond = None; - m.lock_cond(|c| { - cond = Some(c); - }); - cond.unwrap().signal(); -} diff --git a/src/test/compile-fail/sync-rwlock-cond-shouldnt-escape.rs b/src/test/compile-fail/sync-rwlock-cond-shouldnt-escape.rs deleted file mode 100644 index 697858f40da..00000000000 --- a/src/test/compile-fail/sync-rwlock-cond-shouldnt-escape.rs +++ /dev/null @@ -1,21 +0,0 @@ -// 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. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: lifetime of method receiver does not outlive the method call -extern crate sync; -use sync::RWLock; -fn main() { - let x = ~RWLock::new(); - let mut y = None; - x.write_cond(|cond| { - y = Some(cond); - }); - y.unwrap().wait(); -} diff --git a/src/test/compile-fail/sync-rwlock-read-mode-shouldnt-escape.rs b/src/test/compile-fail/sync-rwlock-read-mode-shouldnt-escape.rs deleted file mode 100644 index 30ed0912f6a..00000000000 --- a/src/test/compile-fail/sync-rwlock-read-mode-shouldnt-escape.rs +++ /dev/null @@ -1,22 +0,0 @@ -// 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. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: cannot infer -extern crate sync; -use sync::RWLock; -fn main() { - let x = ~RWLock::new(); - let mut y = None; - x.write_downgrade(|write_mode| { - y = Some(x.downgrade(write_mode)); - }) - // Adding this line causes a method unification failure instead - // (&option::unwrap(y)).read(proc() { }); -} diff --git a/src/test/compile-fail/sync-rwlock-write-mode-cond-shouldnt-escape.rs b/src/test/compile-fail/sync-rwlock-write-mode-cond-shouldnt-escape.rs deleted file mode 100644 index 09b4e34ea8c..00000000000 --- a/src/test/compile-fail/sync-rwlock-write-mode-cond-shouldnt-escape.rs +++ /dev/null @@ -1,23 +0,0 @@ -// 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. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: lifetime of variable does not enclose its declaration -extern crate sync; -use sync::RWLock; -fn main() { - let x = ~RWLock::new(); - let mut y = None; - x.write_downgrade(|write_mode| { - (&write_mode).write_cond(|cond| { - y = Some(cond); - }) - }); - y.unwrap().wait(); -} diff --git a/src/test/compile-fail/sync-rwlock-write-mode-shouldnt-escape.rs b/src/test/compile-fail/sync-rwlock-write-mode-shouldnt-escape.rs deleted file mode 100644 index 0fca360d0ce..00000000000 --- a/src/test/compile-fail/sync-rwlock-write-mode-shouldnt-escape.rs +++ /dev/null @@ -1,22 +0,0 @@ -// 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. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: lifetime of variable does not enclose its declaration -extern crate sync; -use sync::RWLock; -fn main() { - let x = ~RWLock::new(); - let mut y = None; - x.write_downgrade(|write_mode| { - y = Some(write_mode); - }); - // Adding this line causes a method unification failure instead - // (&option::unwrap(y)).write(proc() { }) -} diff --git a/src/test/run-pass/once-move-out-on-heap.rs b/src/test/run-pass/once-move-out-on-heap.rs index 5067a6c4f92..d27cce4dd36 100644 --- a/src/test/run-pass/once-move-out-on-heap.rs +++ b/src/test/run-pass/once-move-out-on-heap.rs @@ -23,7 +23,7 @@ fn foo(blk: proc()) { pub fn main() { let x = Arc::new(true); foo(proc() { - assert!(*x.get()); + assert!(*x); drop(x); }); } diff --git a/src/test/run-pass/once-move-out-on-stack.rs b/src/test/run-pass/once-move-out-on-stack.rs index ffee1e400af..f14827c7245 100644 --- a/src/test/run-pass/once-move-out-on-stack.rs +++ b/src/test/run-pass/once-move-out-on-stack.rs @@ -23,7 +23,7 @@ fn foo(blk: once ||) { pub fn main() { let x = Arc::new(true); foo(|| { - assert!(*x.get()); + assert!(*x); drop(x); }) } diff --git a/src/test/run-pass/trait-bounds-in-arc.rs b/src/test/run-pass/trait-bounds-in-arc.rs index 7ba36cbc0df..3deb0b7527d 100644 --- a/src/test/run-pass/trait-bounds-in-arc.rs +++ b/src/test/run-pass/trait-bounds-in-arc.rs @@ -85,20 +85,20 @@ pub fn main() { fn check_legs(arc: Arc<Vec<~Pet:Share+Send>>) { let mut legs = 0; - for pet in arc.get().iter() { + for pet in arc.iter() { legs += pet.num_legs(); } assert!(legs == 12); } fn check_names(arc: Arc<Vec<~Pet:Share+Send>>) { - for pet in arc.get().iter() { + for pet in arc.iter() { pet.name(|name| { assert!(name[0] == 'a' as u8 && name[1] == 'l' as u8); }) } } fn check_pedigree(arc: Arc<Vec<~Pet:Share+Send>>) { - for pet in arc.get().iter() { + for pet in arc.iter() { assert!(pet.of_good_pedigree()); } } |
