Skip to content

Commit 7a14f49

Browse files
committed
Update tests for the Send - 'static change.
1 parent adfcd93 commit 7a14f49

25 files changed

+52
-183
lines changed

src/libstd/old_io/net/pipe.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ mod tests {
287287

288288
pub fn smalltest<F,G>(server: F, client: G)
289289
where F : FnOnce(UnixStream), F : Send,
290-
G : FnOnce(UnixStream), G : Send
290+
G : FnOnce(UnixStream), G : Send + 'static
291291
{
292292
let path1 = next_test_unix();
293293
let path2 = path1.clone();

src/libstd/process.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ impl Child {
458458
/// the parent waits for the child to exit.
459459
pub fn wait_with_output(mut self) -> io::Result<Output> {
460460
drop(self.stdin.take());
461-
fn read<T: Read + Send>(stream: Option<T>) -> Receiver<io::Result<Vec<u8>>> {
461+
fn read<T: Read + Send + 'static>(stream: Option<T>) -> Receiver<io::Result<Vec<u8>>> {
462462
let (tx, rx) = channel();
463463
match stream {
464464
Some(stream) => {

src/libstd/thread.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ mod test {
630630
rx.recv().unwrap();
631631
}
632632

633-
fn avoid_copying_the_body<F>(spawnfn: F) where F: FnOnce(Thunk) {
633+
fn avoid_copying_the_body<F>(spawnfn: F) where F: FnOnce(Thunk<'static>) {
634634
let (tx, rx) = channel::<uint>();
635635

636636
let x = box 1;
@@ -677,7 +677,7 @@ mod test {
677677
// (well, it would if the constant were 8000+ - I lowered it to be more
678678
// valgrind-friendly. try this at home, instead..!)
679679
static GENERATIONS: uint = 16;
680-
fn child_no(x: uint) -> Thunk {
680+
fn child_no(x: uint) -> Thunk<'static> {
681681
return Thunk::new(move|| {
682682
if x < GENERATIONS {
683683
Thread::spawn(move|| child_no(x+1).invoke(()));

src/test/auxiliary/cci_capture_clause.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use std::thread::Thread;
1212
use std::sync::mpsc::{Receiver, channel};
1313

14-
pub fn foo<T:Send + Clone>(x: T) -> Receiver<T> {
14+
pub fn foo<T:'static + Send + Clone>(x: T) -> Receiver<T> {
1515
let (tx, rx) = channel();
1616
Thread::spawn(move|| {
1717
tx.send(x.clone());

src/test/bench/shootout-reverse-complement.rs

+5-14
Original file line numberDiff line numberDiff line change
@@ -229,21 +229,12 @@ unsafe impl<T: 'static> Send for Racy<T> {}
229229

230230
/// Executes a closure in parallel over the given iterator over mutable slice.
231231
/// The closure `f` is run in parallel with an element of `iter`.
232-
fn parallel<'a, I, T, F>(iter: I, f: F)
233-
where T: 'a+Send + Sync,
234-
I: Iterator<Item=&'a mut [T]>,
235-
F: Fn(&mut [T]) + Sync {
236-
use std::mem;
237-
use std::raw::Repr;
238-
239-
iter.map(|chunk| {
240-
// Need to convert `f` and `chunk` to something that can cross the task
241-
// boundary.
242-
let f = Racy(&f as *const F as *const uint);
243-
let raw = Racy(chunk.repr());
232+
fn parallel<'a, I: Iterator, F>(iter: I, ref f: F)
233+
where I::Item: Send + 'a,
234+
F: Fn(I::Item) + Sync + 'a {
235+
iter.map(|x| {
244236
Thread::scoped(move|| {
245-
let f = f.0 as *const F;
246-
unsafe { (*f)(mem::transmute(raw.0)) }
237+
f(x)
247238
})
248239
}).collect::<Vec<_>>();
249240
}

src/test/bench/shootout-spectralnorm.rs

+4-14
Original file line numberDiff line numberDiff line change
@@ -112,26 +112,16 @@ fn dot(v: &[f64], u: &[f64]) -> f64 {
112112
}
113113

114114

115-
struct Racy<T>(T);
116-
117-
unsafe impl<T: 'static> Send for Racy<T> {}
118-
119115
// Executes a closure in parallel over the given mutable slice. The closure `f`
120116
// is run in parallel and yielded the starting index within `v` as well as a
121117
// sub-slice of `v`.
122-
fn parallel<T, F>(v: &mut [T], f: F)
123-
where T: Send + Sync,
124-
F: Fn(uint, &mut [T]) + Sync {
118+
fn parallel<'a,T, F>(v: &mut [T], ref f: F)
119+
where T: Send + Sync + 'a,
120+
F: Fn(uint, &mut [T]) + Sync + 'a {
125121
let size = v.len() / os::num_cpus() + 1;
126-
127122
v.chunks_mut(size).enumerate().map(|(i, chunk)| {
128-
// Need to convert `f` and `chunk` to something that can cross the task
129-
// boundary.
130-
let f = Racy(&f as *const _ as *const uint);
131-
let raw = Racy(chunk.repr());
132123
Thread::scoped(move|| {
133-
let f = f.0 as *const F;
134-
unsafe { (*f)(i * size, mem::transmute(raw.0)) }
124+
f(i * size, chunk)
135125
})
136126
}).collect::<Vec<_>>();
137127
}

src/test/compile-fail/builtin-superkinds-simple.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
trait Foo : Send { }
1515

16-
impl <'a> Foo for &'a mut () { }
17-
//~^ ERROR the type `&'a mut ()` does not fulfill the required lifetime
16+
impl Foo for std::rc::Rc<i8> { }
17+
//~^ ERROR the trait `core::marker::Send` is not implemented
1818

1919
fn main() { }

src/test/compile-fail/coherence-impls-builtin.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![feature(optin_builtin_traits)]
12+
1113
use std::marker::Send;
1214

1315
enum TestE {
@@ -16,18 +18,21 @@ enum TestE {
1618

1719
struct MyType;
1820

21+
struct NotSync;
22+
impl !Sync for NotSync {}
23+
1924
unsafe impl Send for TestE {}
2025
unsafe impl Send for MyType {}
2126
unsafe impl Send for (MyType, MyType) {}
2227
//~^ ERROR builtin traits can only be implemented on structs or enums
2328

24-
unsafe impl Send for &'static MyType {}
29+
unsafe impl Send for &'static NotSync {}
2530
//~^ ERROR builtin traits can only be implemented on structs or enums
2631

2732
unsafe impl Send for [MyType] {}
2833
//~^ ERROR builtin traits can only be implemented on structs or enums
2934

30-
unsafe impl Send for &'static [MyType] {}
35+
unsafe impl Send for &'static [NotSync] {}
3136
//~^ ERROR builtin traits can only be implemented on structs or enums
3237

3338
fn is_send<T: Send>() {}

src/test/compile-fail/kindck-impl-type-params.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ struct S<T>;
1717

1818
trait Gettable<T> {}
1919

20-
impl<T: Send + Copy> Gettable<T> for S<T> {}
20+
impl<T: Send + Copy + 'static> Gettable<T> for S<T> {}
2121

2222
fn f<T>(val: T) {
2323
let t: S<T> = S;

src/test/compile-fail/kindck-send-object.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ trait Message : Send { }
2020

2121
fn object_ref_with_static_bound_not_ok() {
2222
assert_send::<&'static (Dummy+'static)>();
23-
//~^ ERROR the trait `core::marker::Send` is not implemented
23+
//~^ ERROR the trait `core::marker::Sync` is not implemented
2424
}
2525

2626
fn box_object_with_no_bound_not_ok<'a>() {
2727
assert_send::<Box<Dummy>>(); //~ ERROR the trait `core::marker::Send` is not implemented
2828
}
2929

3030
fn object_with_send_bound_ok() {
31-
assert_send::<&'static (Dummy+Send)>();
31+
assert_send::<&'static (Dummy+Sync)>();
3232
assert_send::<Box<Dummy+Send>>();
3333
}
3434

src/test/compile-fail/kindck-send-object1.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,22 @@
1212
// is broken into two parts because some errors occur in distinct
1313
// phases in the compiler. See kindck-send-object2.rs as well!
1414

15-
fn assert_send<T:Send>() { }
15+
fn assert_send<T:Send+'static>() { }
1616
trait Dummy { }
1717

1818
// careful with object types, who knows what they close over...
1919
fn test51<'a>() {
2020
assert_send::<&'a Dummy>();
21-
//~^ ERROR the trait `core::marker::Send` is not implemented
21+
//~^ ERROR the trait `core::marker::Sync` is not implemented
2222
}
2323
fn test52<'a>() {
24-
assert_send::<&'a (Dummy+Send)>();
24+
assert_send::<&'a (Dummy+Sync)>();
2525
//~^ ERROR does not fulfill the required lifetime
2626
}
2727

2828
// ...unless they are properly bounded
2929
fn test60() {
30-
assert_send::<&'static (Dummy+Send)>();
30+
assert_send::<&'static (Dummy+Sync)>();
3131
}
3232
fn test61() {
3333
assert_send::<Box<Dummy+Send>>();

src/test/compile-fail/kindck-send-object2.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fn assert_send<T:Send>() { }
1414
trait Dummy { }
1515

1616
fn test50() {
17-
assert_send::<&'static Dummy>(); //~ ERROR the trait `core::marker::Send` is not implemented
17+
assert_send::<&'static Dummy>(); //~ ERROR the trait `core::marker::Sync` is not implemented
1818
}
1919

2020
fn test53() {
@@ -23,7 +23,7 @@ fn test53() {
2323

2424
// ...unless they are properly bounded
2525
fn test60() {
26-
assert_send::<&'static (Dummy+Send)>();
26+
assert_send::<&'static (Dummy+Sync)>();
2727
}
2828
fn test61() {
2929
assert_send::<Box<Dummy+Send>>();

src/test/compile-fail/kindck-send-owned.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ fn test31() { assert_send::<String>(); }
1818
fn test32() { assert_send::<Vec<isize> >(); }
1919

2020
// but not if they own a bad thing
21-
fn test40<'a>(_: &'a isize) {
22-
assert_send::<Box<&'a isize>>(); //~ ERROR does not fulfill the required lifetime
21+
fn test40() {
22+
assert_send::<Box<*mut u8>>(); //~ ERROR `core::marker::Send` is not implemented
2323
}
2424

2525
fn main() { }

src/test/compile-fail/kindck-send-region-pointers.rs

-34
This file was deleted.

src/test/compile-fail/regions-bounded-by-send.rs

-83
This file was deleted.

src/test/compile-fail/regions-pattern-typing-issue-19552.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
fn assert_send<T: Send>(_t: T) {}
11+
fn assert_static<T: 'static>(_t: T) {}
1212

1313
fn main() {
1414
let line = String::new();
1515
match [&*line] { //~ ERROR `line` does not live long enough
16-
[ word ] => { assert_send(word); }
16+
[ word ] => { assert_static(word); }
1717
}
1818
}

src/test/compile-fail/trait-bounds-cant-coerce.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ fn c(x: Box<Foo+Sync+Send>) {
2222
fn d(x: Box<Foo>) {
2323
a(x); //~ ERROR mismatched types
2424
//~| expected `Box<Foo + Send>`
25-
//~| found `Box<Foo + 'static>`
25+
//~| found `Box<Foo>`
2626
//~| expected bounds `Send`
2727
//~| found no bounds
2828
}

src/test/run-pass/builtin-superkinds-capabilities-transitive.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ trait Foo : Bar { }
2222
impl <T: Send> Foo for T { }
2323
impl <T: Send> Bar for T { }
2424

25-
fn foo<T: Foo>(val: T, chan: Sender<T>) {
25+
fn foo<T: Foo + 'static>(val: T, chan: Sender<T>) {
2626
chan.send(val).unwrap();
2727
}
2828

src/test/run-pass/builtin-superkinds-capabilities-xc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ struct X<T>(T);
2525
impl <T: Sync> RequiresShare for X<T> { }
2626
impl <T: Sync+Send> RequiresRequiresShareAndSend for X<T> { }
2727

28-
fn foo<T: RequiresRequiresShareAndSend>(val: T, chan: Sender<T>) {
28+
fn foo<T: RequiresRequiresShareAndSend + 'static>(val: T, chan: Sender<T>) {
2929
chan.send(val).unwrap();
3030
}
3131

src/test/run-pass/builtin-superkinds-capabilities.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ trait Foo : Send { }
1818

1919
impl <T: Send> Foo for T { }
2020

21-
fn foo<T: Foo>(val: T, chan: Sender<T>) {
21+
fn foo<T: Foo + 'static>(val: T, chan: Sender<T>) {
2222
chan.send(val).unwrap();
2323
}
2424

0 commit comments

Comments
 (0)