diff --git a/src/libstd/old_io/net/pipe.rs b/src/libstd/old_io/net/pipe.rs index 8c4a10a55d489..6dd73273122c5 100644 --- a/src/libstd/old_io/net/pipe.rs +++ b/src/libstd/old_io/net/pipe.rs @@ -287,7 +287,7 @@ mod tests { pub fn smalltest(server: F, client: G) where F : FnOnce(UnixStream), F : Send, - G : FnOnce(UnixStream), G : Send + G : FnOnce(UnixStream), G : Send + 'static { let path1 = next_test_unix(); let path2 = path1.clone(); diff --git a/src/libstd/process.rs b/src/libstd/process.rs index d2b98ec89390b..05b5e47103f22 100644 --- a/src/libstd/process.rs +++ b/src/libstd/process.rs @@ -458,7 +458,7 @@ impl Child { /// the parent waits for the child to exit. pub fn wait_with_output(mut self) -> io::Result { drop(self.stdin.take()); - fn read(stream: Option) -> Receiver>> { + fn read(stream: Option) -> Receiver>> { let (tx, rx) = channel(); match stream { Some(stream) => { diff --git a/src/libstd/thread.rs b/src/libstd/thread.rs index c662a1dafa1eb..d5dcdca5fbf21 100644 --- a/src/libstd/thread.rs +++ b/src/libstd/thread.rs @@ -630,7 +630,7 @@ mod test { rx.recv().unwrap(); } - fn avoid_copying_the_body(spawnfn: F) where F: FnOnce(Thunk) { + fn avoid_copying_the_body(spawnfn: F) where F: FnOnce(Thunk<'static>) { let (tx, rx) = channel::(); let x = box 1; @@ -677,7 +677,7 @@ mod test { // (well, it would if the constant were 8000+ - I lowered it to be more // valgrind-friendly. try this at home, instead..!) static GENERATIONS: uint = 16; - fn child_no(x: uint) -> Thunk { + fn child_no(x: uint) -> Thunk<'static> { return Thunk::new(move|| { if x < GENERATIONS { Thread::spawn(move|| child_no(x+1).invoke(())); diff --git a/src/test/auxiliary/cci_capture_clause.rs b/src/test/auxiliary/cci_capture_clause.rs index 673c38697b79c..2053f635c44a9 100644 --- a/src/test/auxiliary/cci_capture_clause.rs +++ b/src/test/auxiliary/cci_capture_clause.rs @@ -11,7 +11,7 @@ use std::thread::Thread; use std::sync::mpsc::{Receiver, channel}; -pub fn foo(x: T) -> Receiver { +pub fn foo(x: T) -> Receiver { let (tx, rx) = channel(); Thread::spawn(move|| { tx.send(x.clone()); diff --git a/src/test/bench/shootout-reverse-complement.rs b/src/test/bench/shootout-reverse-complement.rs index 944383199543f..469923d80b6db 100644 --- a/src/test/bench/shootout-reverse-complement.rs +++ b/src/test/bench/shootout-reverse-complement.rs @@ -229,21 +229,12 @@ unsafe impl Send for Racy {} /// Executes a closure in parallel over the given iterator over mutable slice. /// The closure `f` is run in parallel with an element of `iter`. -fn parallel<'a, I, T, F>(iter: I, f: F) - where T: 'a+Send + Sync, - I: Iterator, - F: Fn(&mut [T]) + Sync { - use std::mem; - use std::raw::Repr; - - iter.map(|chunk| { - // Need to convert `f` and `chunk` to something that can cross the task - // boundary. - let f = Racy(&f as *const F as *const uint); - let raw = Racy(chunk.repr()); +fn parallel<'a, I: Iterator, F>(iter: I, ref f: F) + where I::Item: Send + 'a, + F: Fn(I::Item) + Sync + 'a { + iter.map(|x| { Thread::scoped(move|| { - let f = f.0 as *const F; - unsafe { (*f)(mem::transmute(raw.0)) } + f(x) }) }).collect::>(); } diff --git a/src/test/bench/shootout-spectralnorm.rs b/src/test/bench/shootout-spectralnorm.rs index 8356df8d8a184..0c77120e506cb 100644 --- a/src/test/bench/shootout-spectralnorm.rs +++ b/src/test/bench/shootout-spectralnorm.rs @@ -112,26 +112,16 @@ fn dot(v: &[f64], u: &[f64]) -> f64 { } -struct Racy(T); - -unsafe impl Send for Racy {} - // Executes a closure in parallel over the given mutable slice. The closure `f` // is run in parallel and yielded the starting index within `v` as well as a // sub-slice of `v`. -fn parallel(v: &mut [T], f: F) - where T: Send + Sync, - F: Fn(uint, &mut [T]) + Sync { +fn parallel<'a,T, F>(v: &mut [T], ref f: F) + where T: Send + Sync + 'a, + F: Fn(uint, &mut [T]) + Sync + 'a { let size = v.len() / os::num_cpus() + 1; - v.chunks_mut(size).enumerate().map(|(i, chunk)| { - // Need to convert `f` and `chunk` to something that can cross the task - // boundary. - let f = Racy(&f as *const _ as *const uint); - let raw = Racy(chunk.repr()); Thread::scoped(move|| { - let f = f.0 as *const F; - unsafe { (*f)(i * size, mem::transmute(raw.0)) } + f(i * size, chunk) }) }).collect::>(); } diff --git a/src/test/compile-fail/builtin-superkinds-simple.rs b/src/test/compile-fail/builtin-superkinds-simple.rs index c7b75ade55584..c3fb6a1be8797 100644 --- a/src/test/compile-fail/builtin-superkinds-simple.rs +++ b/src/test/compile-fail/builtin-superkinds-simple.rs @@ -13,7 +13,7 @@ trait Foo : Send { } -impl <'a> Foo for &'a mut () { } -//~^ ERROR the type `&'a mut ()` does not fulfill the required lifetime +impl Foo for std::rc::Rc { } +//~^ ERROR the trait `core::marker::Send` is not implemented fn main() { } diff --git a/src/test/compile-fail/coherence-impls-builtin.rs b/src/test/compile-fail/coherence-impls-builtin.rs index 2ca288b60a33f..38730d241f685 100644 --- a/src/test/compile-fail/coherence-impls-builtin.rs +++ b/src/test/compile-fail/coherence-impls-builtin.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(optin_builtin_traits)] + use std::marker::Send; enum TestE { @@ -16,18 +18,21 @@ enum TestE { struct MyType; +struct NotSync; +impl !Sync for NotSync {} + unsafe impl Send for TestE {} unsafe impl Send for MyType {} unsafe impl Send for (MyType, MyType) {} //~^ ERROR builtin traits can only be implemented on structs or enums -unsafe impl Send for &'static MyType {} +unsafe impl Send for &'static NotSync {} //~^ ERROR builtin traits can only be implemented on structs or enums unsafe impl Send for [MyType] {} //~^ ERROR builtin traits can only be implemented on structs or enums -unsafe impl Send for &'static [MyType] {} +unsafe impl Send for &'static [NotSync] {} //~^ ERROR builtin traits can only be implemented on structs or enums fn is_send() {} diff --git a/src/test/compile-fail/kindck-impl-type-params.rs b/src/test/compile-fail/kindck-impl-type-params.rs index de7639c621325..d5276efa8be98 100644 --- a/src/test/compile-fail/kindck-impl-type-params.rs +++ b/src/test/compile-fail/kindck-impl-type-params.rs @@ -17,7 +17,7 @@ struct S; trait Gettable {} -impl Gettable for S {} +impl Gettable for S {} fn f(val: T) { let t: S = S; diff --git a/src/test/compile-fail/kindck-send-object.rs b/src/test/compile-fail/kindck-send-object.rs index 7984b3b32c213..570f7ad7fe3bf 100644 --- a/src/test/compile-fail/kindck-send-object.rs +++ b/src/test/compile-fail/kindck-send-object.rs @@ -20,7 +20,7 @@ trait Message : Send { } fn object_ref_with_static_bound_not_ok() { assert_send::<&'static (Dummy+'static)>(); - //~^ ERROR the trait `core::marker::Send` is not implemented + //~^ ERROR the trait `core::marker::Sync` is not implemented } fn box_object_with_no_bound_not_ok<'a>() { @@ -28,7 +28,7 @@ fn box_object_with_no_bound_not_ok<'a>() { } fn object_with_send_bound_ok() { - assert_send::<&'static (Dummy+Send)>(); + assert_send::<&'static (Dummy+Sync)>(); assert_send::>(); } diff --git a/src/test/compile-fail/kindck-send-object1.rs b/src/test/compile-fail/kindck-send-object1.rs index 3d47d33d7c35d..48d5215b7085b 100644 --- a/src/test/compile-fail/kindck-send-object1.rs +++ b/src/test/compile-fail/kindck-send-object1.rs @@ -12,22 +12,22 @@ // is broken into two parts because some errors occur in distinct // phases in the compiler. See kindck-send-object2.rs as well! -fn assert_send() { } +fn assert_send() { } trait Dummy { } // careful with object types, who knows what they close over... fn test51<'a>() { assert_send::<&'a Dummy>(); - //~^ ERROR the trait `core::marker::Send` is not implemented + //~^ ERROR the trait `core::marker::Sync` is not implemented } fn test52<'a>() { - assert_send::<&'a (Dummy+Send)>(); + assert_send::<&'a (Dummy+Sync)>(); //~^ ERROR does not fulfill the required lifetime } // ...unless they are properly bounded fn test60() { - assert_send::<&'static (Dummy+Send)>(); + assert_send::<&'static (Dummy+Sync)>(); } fn test61() { assert_send::>(); diff --git a/src/test/compile-fail/kindck-send-object2.rs b/src/test/compile-fail/kindck-send-object2.rs index 75bae09b37f17..d3d166e2a6916 100644 --- a/src/test/compile-fail/kindck-send-object2.rs +++ b/src/test/compile-fail/kindck-send-object2.rs @@ -14,7 +14,7 @@ fn assert_send() { } trait Dummy { } fn test50() { - assert_send::<&'static Dummy>(); //~ ERROR the trait `core::marker::Send` is not implemented + assert_send::<&'static Dummy>(); //~ ERROR the trait `core::marker::Sync` is not implemented } fn test53() { @@ -23,7 +23,7 @@ fn test53() { // ...unless they are properly bounded fn test60() { - assert_send::<&'static (Dummy+Send)>(); + assert_send::<&'static (Dummy+Sync)>(); } fn test61() { assert_send::>(); diff --git a/src/test/compile-fail/kindck-send-owned.rs b/src/test/compile-fail/kindck-send-owned.rs index 266b61566560f..406711902a543 100644 --- a/src/test/compile-fail/kindck-send-owned.rs +++ b/src/test/compile-fail/kindck-send-owned.rs @@ -18,8 +18,8 @@ fn test31() { assert_send::(); } fn test32() { assert_send:: >(); } // but not if they own a bad thing -fn test40<'a>(_: &'a isize) { - assert_send::>(); //~ ERROR does not fulfill the required lifetime +fn test40() { + assert_send::>(); //~ ERROR `core::marker::Send` is not implemented } fn main() { } diff --git a/src/test/compile-fail/kindck-send-region-pointers.rs b/src/test/compile-fail/kindck-send-region-pointers.rs deleted file mode 100644 index e2a5b0678a628..0000000000000 --- a/src/test/compile-fail/kindck-send-region-pointers.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2014 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that borrowed pointers are not sendable unless 'static. - -fn assert_send() { } - -// lifetime pointers with 'static lifetime are ok -fn test01() { assert_send::<&'static isize>(); } -fn test02() { assert_send::<&'static str>(); } -fn test03() { assert_send::<&'static [isize]>(); } - -// whether or not they are mutable -fn test10() { assert_send::<&'static mut isize>(); } - -// otherwise lifetime pointers are not ok -fn test20<'a>(_: &'a isize) { - assert_send::<&'a isize>(); //~ ERROR does not fulfill the required lifetime -} -fn test21<'a>(_: &'a isize) { - assert_send::<&'a str>(); //~ ERROR does not fulfill the required lifetime -} -fn test22<'a>(_: &'a isize) { - assert_send::<&'a [isize]>(); //~ ERROR does not fulfill the required lifetime -} - -fn main() { } diff --git a/src/test/compile-fail/regions-bounded-by-send.rs b/src/test/compile-fail/regions-bounded-by-send.rs deleted file mode 100644 index 71254e15d32fc..0000000000000 --- a/src/test/compile-fail/regions-bounded-by-send.rs +++ /dev/null @@ -1,83 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test which of the builtin types are considered sendable. The tests -// in this file all test region bound and lifetime violations that are -// detected during type check. - -extern crate core; -use core::ptr::Unique; - -fn assert_send() { } -trait Dummy:Send { } - -// lifetime pointers with 'static lifetime are ok - -fn static_lifime_ok<'a,T,U:Send>(_: &'a isize) { - assert_send::<&'static isize>(); - assert_send::<&'static str>(); - assert_send::<&'static [isize]>(); - - // whether or not they are mutable - assert_send::<&'static mut isize>(); -} - -// otherwise lifetime pointers are not ok - -fn param_not_ok<'a>(x: &'a isize) { - assert_send::<&'a isize>(); //~ ERROR does not fulfill the required lifetime -} - -fn param_not_ok1<'a>(_: &'a isize) { - assert_send::<&'a str>(); //~ ERROR does not fulfill the required lifetime -} - -fn param_not_ok2<'a>(_: &'a isize) { - assert_send::<&'a [isize]>(); //~ ERROR does not fulfill the required lifetime -} - -// boxes are ok - -fn box_ok() { - assert_send::>(); - assert_send::(); - assert_send::>(); -} - -// but not if they own a bad thing - -fn box_with_region_not_ok<'a>() { - assert_send::>(); //~ ERROR does not fulfill the required lifetime -} - -// objects with insufficient bounds no ok - -fn object_with_random_bound_not_ok<'a>() { - assert_send::<&'a (Dummy+'a)>(); - //~^ ERROR reference has a longer lifetime -} - -fn object_with_send_bound_not_ok<'a>() { - assert_send::<&'a (Dummy+Send)>(); - //~^ ERROR does not fulfill the required lifetime -} - -// unsafe pointers are ok unless they point at unsendable things - -struct UniqueUnsafePtr(Unique<*const isize>); - -unsafe impl Send for UniqueUnsafePtr {} - -fn unsafe_ok1<'a>(_: &'a isize) { - assert_send::(); -} - -fn main() { -} diff --git a/src/test/compile-fail/regions-pattern-typing-issue-19552.rs b/src/test/compile-fail/regions-pattern-typing-issue-19552.rs index 57ea607cbf623..3401dd1becdd8 100644 --- a/src/test/compile-fail/regions-pattern-typing-issue-19552.rs +++ b/src/test/compile-fail/regions-pattern-typing-issue-19552.rs @@ -8,11 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn assert_send(_t: T) {} +fn assert_static(_t: T) {} fn main() { let line = String::new(); match [&*line] { //~ ERROR `line` does not live long enough - [ word ] => { assert_send(word); } + [ word ] => { assert_static(word); } } } diff --git a/src/test/compile-fail/trait-bounds-cant-coerce.rs b/src/test/compile-fail/trait-bounds-cant-coerce.rs index 89e89cf824693..79174552ae09c 100644 --- a/src/test/compile-fail/trait-bounds-cant-coerce.rs +++ b/src/test/compile-fail/trait-bounds-cant-coerce.rs @@ -22,7 +22,7 @@ fn c(x: Box) { fn d(x: Box) { a(x); //~ ERROR mismatched types //~| expected `Box` - //~| found `Box` + //~| found `Box` //~| expected bounds `Send` //~| found no bounds } diff --git a/src/test/run-pass/builtin-superkinds-capabilities-transitive.rs b/src/test/run-pass/builtin-superkinds-capabilities-transitive.rs index 3df9dd25d8681..379ac12a95424 100644 --- a/src/test/run-pass/builtin-superkinds-capabilities-transitive.rs +++ b/src/test/run-pass/builtin-superkinds-capabilities-transitive.rs @@ -22,7 +22,7 @@ trait Foo : Bar { } impl Foo for T { } impl Bar for T { } -fn foo(val: T, chan: Sender) { +fn foo(val: T, chan: Sender) { chan.send(val).unwrap(); } diff --git a/src/test/run-pass/builtin-superkinds-capabilities-xc.rs b/src/test/run-pass/builtin-superkinds-capabilities-xc.rs index 52b826393e9e3..cd019c21a3d05 100644 --- a/src/test/run-pass/builtin-superkinds-capabilities-xc.rs +++ b/src/test/run-pass/builtin-superkinds-capabilities-xc.rs @@ -25,7 +25,7 @@ struct X(T); impl RequiresShare for X { } impl RequiresRequiresShareAndSend for X { } -fn foo(val: T, chan: Sender) { +fn foo(val: T, chan: Sender) { chan.send(val).unwrap(); } diff --git a/src/test/run-pass/builtin-superkinds-capabilities.rs b/src/test/run-pass/builtin-superkinds-capabilities.rs index 034e5ff2d3a5c..dc61508eec4fa 100644 --- a/src/test/run-pass/builtin-superkinds-capabilities.rs +++ b/src/test/run-pass/builtin-superkinds-capabilities.rs @@ -18,7 +18,7 @@ trait Foo : Send { } impl Foo for T { } -fn foo(val: T, chan: Sender) { +fn foo(val: T, chan: Sender) { chan.send(val).unwrap(); } diff --git a/src/test/run-pass/builtin-superkinds-self-type.rs b/src/test/run-pass/builtin-superkinds-self-type.rs index 1b3070ba3b04d..1d05a7baa5352 100644 --- a/src/test/run-pass/builtin-superkinds-self-type.rs +++ b/src/test/run-pass/builtin-superkinds-self-type.rs @@ -13,13 +13,13 @@ use std::sync::mpsc::{Sender, channel}; -trait Foo : Send + Sized { +trait Foo : Send + Sized + 'static { fn foo(self, tx: Sender) { tx.send(self).unwrap(); } } -impl Foo for T { } +impl Foo for T { } pub fn main() { let (tx, rx) = channel(); diff --git a/src/test/run-pass/issue-18188.rs b/src/test/run-pass/issue-18188.rs index 7a5a86822afda..a4b09eb08e0f6 100644 --- a/src/test/run-pass/issue-18188.rs +++ b/src/test/run-pass/issue-18188.rs @@ -14,12 +14,12 @@ use std::thunk::Thunk; pub trait Promisable: Send + Sync {} impl Promisable for T {} -pub fn propagate(action: F) -> Thunk, Result> +pub fn propagate<'a, T, E, F, G>(action: F) -> Thunk<'a,Result, Result> where - T: Promisable + Clone, - E: Promisable + Clone, - F: FnOnce(&T) -> Result + Send, - G: FnOnce(Result) -> Result { + T: Promisable + Clone + 'a, + E: Promisable + Clone + 'a, + F: FnOnce(&T) -> Result + Send + 'a, + G: FnOnce(Result) -> Result + 'a { Thunk::with_arg(move |result: Result| { match result { Ok(ref t) => action(t), diff --git a/src/test/run-pass/issue-21058.rs b/src/test/run-pass/issue-21058.rs index 044d43a57faba..3cdd57aed5a1c 100644 --- a/src/test/run-pass/issue-21058.rs +++ b/src/test/run-pass/issue-21058.rs @@ -14,7 +14,7 @@ struct DST { a: u32, b: str } fn main() { // get_tydesc should support unsized types - assert!(unsafe {( + assert_eq!(unsafe {( // Slice (*std::intrinsics::get_tydesc::<[u8]>()).name, // str @@ -25,5 +25,5 @@ fn main() { (*std::intrinsics::get_tydesc::()).name, // DST (*std::intrinsics::get_tydesc::()).name - )} == ("[u8]", "str", "core::marker::Copy + 'static", "NT", "DST")); + )}, ("[u8]", "str", "core::marker::Copy", "NT", "DST")); } diff --git a/src/test/run-pass/issue-2190-1.rs b/src/test/run-pass/issue-2190-1.rs index 810bf385d7e0b..3025741694f43 100644 --- a/src/test/run-pass/issue-2190-1.rs +++ b/src/test/run-pass/issue-2190-1.rs @@ -13,11 +13,11 @@ use std::thunk::Thunk; static generations: uint = 1024+256+128+49; -fn spawn(f: Thunk) { +fn spawn(f: Thunk<'static>) { Builder::new().stack_size(32 * 1024).spawn(move|| f.invoke(())); } -fn child_no(x: uint) -> Thunk { +fn child_no(x: uint) -> Thunk<'static> { Thunk::new(move|| { if x < generations { spawn(child_no(x+1)); diff --git a/src/test/run-pass/send-type-inference.rs b/src/test/run-pass/send-type-inference.rs index ae992a0a358d1..60093803f0b77 100644 --- a/src/test/run-pass/send-type-inference.rs +++ b/src/test/run-pass/send-type-inference.rs @@ -16,7 +16,7 @@ struct Command { val: V } -fn cache_server(mut tx: Sender>>) { +fn cache_server(mut tx: Sender>>) { let (tx1, _rx) = channel(); tx.send(tx1); }