2012-05-30 13:56:50 -05:00
|
|
|
// Test rules governing higher-order pure fns.
|
|
|
|
|
2012-11-04 22:41:00 -06:00
|
|
|
fn take<T>(_v: T) {}
|
|
|
|
|
2012-05-30 13:56:50 -05:00
|
|
|
fn assign_to_pure(x: pure fn(), y: fn(), z: unsafe fn()) {
|
2012-11-04 22:41:00 -06:00
|
|
|
take::<pure fn()>(x);
|
|
|
|
take::<pure fn()>(y); //~ ERROR expected pure fn but found impure fn
|
|
|
|
take::<pure fn()>(z); //~ ERROR expected pure fn but found unsafe fn
|
2012-05-30 13:56:50 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn assign_to_impure(x: pure fn(), y: fn(), z: unsafe fn()) {
|
2012-11-04 22:41:00 -06:00
|
|
|
take::<fn()>(x);
|
|
|
|
take::<fn()>(y);
|
|
|
|
take::<fn()>(z); //~ ERROR expected impure fn but found unsafe fn
|
2012-05-30 13:56:50 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn assign_to_unsafe(x: pure fn(), y: fn(), z: unsafe fn()) {
|
2012-11-04 22:41:00 -06:00
|
|
|
take::<unsafe fn()>(x);
|
|
|
|
take::<unsafe fn()>(y);
|
|
|
|
take::<unsafe fn()>(z);
|
2012-05-30 13:56:50 -05:00
|
|
|
}
|
|
|
|
|
2012-05-30 13:59:05 -05:00
|
|
|
fn assign_to_pure2(x: pure fn@(), y: fn@(), z: unsafe fn@()) {
|
2012-11-04 22:41:00 -06:00
|
|
|
take::<pure fn()>(x);
|
|
|
|
take::<pure fn()>(y); //~ ERROR expected pure fn but found impure fn
|
|
|
|
take::<pure fn()>(z); //~ ERROR expected pure fn but found unsafe fn
|
2012-05-30 13:59:05 -05:00
|
|
|
|
2012-11-04 22:41:00 -06:00
|
|
|
take::<pure fn~()>(x); //~ ERROR expected ~ closure, found @ closure
|
|
|
|
take::<pure fn~()>(y); //~ ERROR expected ~ closure, found @ closure
|
|
|
|
take::<pure fn~()>(z); //~ ERROR expected ~ closure, found @ closure
|
2012-05-30 13:59:05 -05:00
|
|
|
|
2012-11-04 22:41:00 -06:00
|
|
|
take::<unsafe fn~()>(x); //~ ERROR expected ~ closure, found @ closure
|
|
|
|
take::<unsafe fn~()>(y); //~ ERROR expected ~ closure, found @ closure
|
|
|
|
take::<unsafe fn~()>(z); //~ ERROR expected ~ closure, found @ closure
|
2012-05-30 13:59:05 -05:00
|
|
|
}
|
|
|
|
|
2012-05-30 13:56:50 -05:00
|
|
|
fn main() {
|
2012-08-13 18:13:12 -05:00
|
|
|
}
|