rustc: Typecheck crust functions as *u8

This commit is contained in:
Brian Anderson 2012-02-10 15:34:23 -08:00
parent 305cbf9b8e
commit 0a503228f6
5 changed files with 41 additions and 0 deletions

View File

@ -107,6 +107,18 @@ fn ty_param_bounds_and_ty_for_def(fcx: @fn_ctxt, sp: span, defn: ast::def) ->
}
}
}
ast::def_fn(id, ast::crust_fn) {
// Crust functions are just u8 pointers
ret {
bounds: @[],
ty: ty::mk_ptr(
fcx.ccx.tcx,
{
ty: ty::mk_mach_uint(fcx.ccx.tcx, ast::ty_u8),
mut: ast::imm
})
};
}
ast::def_fn(id, _) | ast::def_const(id) |
ast::def_variant(_, id) | ast::def_class(id)
| ast::def_class_method(_, id) | ast::def_class_field(_, id)

View File

@ -0,0 +1,7 @@
// error-pattern:expected function or native function but found *u8
crust fn f() {
}
fn main() {
let x = bind f();
}

View File

@ -0,0 +1,7 @@
// error-pattern:expected function or native function but found *u8
crust fn f() {
}
fn main() {
f();
}

View File

@ -0,0 +1,8 @@
// error-pattern:expected `fn()` but found `*u8`
crust fn f() {
}
fn main() {
// Crust functions are *u8 types
let _x: fn() = f;
}

View File

@ -0,0 +1,7 @@
crust fn f() {
}
fn main() {
// Crust functions are *u8 types
let _x: *u8 = f;
}