rustc: Typecheck crust functions as *u8
This commit is contained in:
parent
305cbf9b8e
commit
0a503228f6
@ -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)
|
||||
|
7
src/test/compile-fail/crust-no-bind.rs
Normal file
7
src/test/compile-fail/crust-no-bind.rs
Normal file
@ -0,0 +1,7 @@
|
||||
// error-pattern:expected function or native function but found *u8
|
||||
crust fn f() {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x = bind f();
|
||||
}
|
7
src/test/compile-fail/crust-no-call.rs
Normal file
7
src/test/compile-fail/crust-no-call.rs
Normal file
@ -0,0 +1,7 @@
|
||||
// error-pattern:expected function or native function but found *u8
|
||||
crust fn f() {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
f();
|
||||
}
|
8
src/test/compile-fail/crust-wrong-value-type.rs
Normal file
8
src/test/compile-fail/crust-wrong-value-type.rs
Normal 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;
|
||||
}
|
7
src/test/run-pass/crust-take-value.rs
Normal file
7
src/test/run-pass/crust-take-value.rs
Normal file
@ -0,0 +1,7 @@
|
||||
crust fn f() {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// Crust functions are *u8 types
|
||||
let _x: *u8 = f;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user