2012-05-30 13:56:50 -05:00
|
|
|
// Test rules governing higher-order pure fns.
|
|
|
|
|
|
|
|
fn assign_to_pure(x: pure fn(), y: fn(), z: unsafe fn()) {
|
|
|
|
let a: pure fn() = x;
|
2012-06-30 06:23:59 -05:00
|
|
|
let b: pure fn() = y; //~ ERROR expected pure fn but found impure fn
|
|
|
|
let c: 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()) {
|
|
|
|
let h: fn() = x;
|
|
|
|
let i: fn() = y;
|
2012-06-30 06:23:59 -05:00
|
|
|
let j: 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()) {
|
|
|
|
let m: unsafe fn() = x;
|
|
|
|
let n: unsafe fn() = y;
|
|
|
|
let o: unsafe fn() = z;
|
|
|
|
}
|
|
|
|
|
2012-05-30 13:59:05 -05:00
|
|
|
fn assign_to_pure2(x: pure fn@(), y: fn@(), z: unsafe fn@()) {
|
|
|
|
let a: pure fn() = x;
|
2012-06-30 06:23:59 -05:00
|
|
|
let b: pure fn() = y; //~ ERROR expected pure fn but found impure fn
|
|
|
|
let c: pure fn() = z; //~ ERROR expected pure fn but found unsafe fn
|
2012-05-30 13:59:05 -05:00
|
|
|
|
2012-06-30 06:23:59 -05:00
|
|
|
let a: pure fn~() = x; //~ ERROR closure protocol mismatch (fn~ vs fn@)
|
|
|
|
let b: pure fn~() = y; //~ ERROR closure protocol mismatch (fn~ vs fn@)
|
|
|
|
let c: pure fn~() = z; //~ ERROR closure protocol mismatch (fn~ vs fn@)
|
2012-05-30 13:59:05 -05:00
|
|
|
|
2012-06-30 06:23:59 -05:00
|
|
|
let a: unsafe fn~() = x; //~ ERROR closure protocol mismatch (fn~ vs fn@)
|
|
|
|
let b: unsafe fn~() = y; //~ ERROR closure protocol mismatch (fn~ vs fn@)
|
|
|
|
let c: unsafe fn~() = z; //~ ERROR closure protocol mismatch (fn~ vs fn@)
|
2012-05-30 13:59:05 -05:00
|
|
|
}
|
|
|
|
|
2012-05-30 13:56:50 -05:00
|
|
|
fn main() {
|
|
|
|
}
|