Remove ty_native_fn
It was being used as a clumsy synonym of ty_fn.
This commit is contained in:
parent
566a4be1f8
commit
ec4d05de3b
@ -197,9 +197,6 @@ fn lookup_def(cnum: ast::crate_num, data: @[u8], did_: ast::def_id) ->
|
||||
'u' { ast::def_fn(did, ast::unsafe_fn) }
|
||||
'f' { ast::def_fn(did, ast::impure_fn) }
|
||||
'p' { ast::def_fn(did, ast::pure_fn) }
|
||||
'U' { ast::def_native_fn(did, ast::unsafe_fn) }
|
||||
'F' { ast::def_native_fn(did, ast::impure_fn) }
|
||||
'P' { ast::def_native_fn(did, ast::pure_fn) }
|
||||
'y' { ast::def_ty(did) }
|
||||
'T' { ast::def_native_ty(did) }
|
||||
't' { ast::def_ty(did) }
|
||||
|
@ -427,12 +427,11 @@ fn encode_info_for_native_item(ecx: @encode_ctxt, ebml_w: ebml::writer,
|
||||
ty::mk_native(ecx.ccx.tcx, local_def(nitem.id)));
|
||||
}
|
||||
native_item_fn(fn_decl, tps) {
|
||||
let letter =
|
||||
alt fn_decl.purity {
|
||||
unsafe_fn { 'U' }
|
||||
pure_fn { 'P' } // this is currently impossible, but hey.
|
||||
impure_fn { 'F' }
|
||||
} as u8;
|
||||
let letter = alt fn_decl.purity {
|
||||
unsafe_fn { 'u' }
|
||||
pure_fn { 'p' } // this is currently impossible, but hey.
|
||||
impure_fn { 'f' }
|
||||
} as u8;
|
||||
encode_def_id(ebml_w, local_def(nitem.id));
|
||||
encode_family(ebml_w, letter);
|
||||
encode_type_param_bounds(ebml_w, ecx, tps);
|
||||
|
@ -245,10 +245,6 @@ fn parse_ty(st: @pstate, conv: conv_did) -> ty::t {
|
||||
let proto = parse_proto(next(st) as char);
|
||||
parse_ty_rust_fn(st, conv, proto)
|
||||
}
|
||||
'N' {
|
||||
let func = parse_ty_fn(st, conv);
|
||||
ret ty::mk_native_fn(st.tcx, func.inputs, func.output);
|
||||
}
|
||||
'r' {
|
||||
assert (next(st) as char == '[');
|
||||
let def = parse_def(st, conv);
|
||||
|
@ -153,11 +153,6 @@ fn enc_sty(w: io::writer, cx: @ctxt, st: ty::sty) {
|
||||
enc_proto(w, f.proto);
|
||||
enc_ty_fn(w, cx, f);
|
||||
}
|
||||
ty::ty_native_fn(args, out) {
|
||||
w.write_char('N');
|
||||
enc_ty_fn(w, cx, {proto: proto_bare, inputs: args, output: out,
|
||||
ret_style: return_val, constraints: []});
|
||||
}
|
||||
ty::ty_res(def, ty, tps) {
|
||||
w.write_str("r[");
|
||||
w.write_str(cx.ds(def));
|
||||
|
@ -562,7 +562,7 @@ fn copy_is_expensive(tcx: ty::ctxt, ty: ty::t) -> bool {
|
||||
ty::ty_ptr(_) { 1u }
|
||||
ty::ty_box(_) | ty::ty_iface(_, _) { 3u }
|
||||
ty::ty_constr(t, _) | ty::ty_res(_, t, _) { score_ty(tcx, t) }
|
||||
ty::ty_fn(_) | ty::ty_native_fn(_, _) { 4u }
|
||||
ty::ty_fn(_) { 4u }
|
||||
ty::ty_str | ty::ty_vec(_) | ty::ty_param(_, _) { 50u }
|
||||
ty::ty_uniq(mt) { 1u + score_ty(tcx, mt.ty) }
|
||||
ty::ty_enum(_, ts) | ty::ty_tup(ts) {
|
||||
|
@ -19,8 +19,7 @@ fn fn_usage_expr(expr: @ast::expr,
|
||||
ast::expr_path(path) {
|
||||
if !ctx.unsafe_fn_legal {
|
||||
alt ctx.tcx.def_map.find(expr.id) {
|
||||
some(ast::def_fn(_, ast::unsafe_fn)) |
|
||||
some(ast::def_native_fn(_, ast::unsafe_fn)) {
|
||||
some(ast::def_fn(_, ast::unsafe_fn)) {
|
||||
log(error, ("expr=", expr_to_str(expr)));
|
||||
ctx.tcx.sess.span_fatal(
|
||||
expr.span,
|
||||
|
@ -131,8 +131,7 @@ fn type_is_gc_relevant(cx: ty::ctxt, ty: ty::t) -> bool {
|
||||
}
|
||||
ty::ty_constr(sub, _) { ret type_is_gc_relevant(cx, sub); }
|
||||
ty::ty_box(_) | ty::ty_uniq(_) | ty::ty_fn(_) |
|
||||
ty::ty_native_fn(_, _) | ty::ty_param(_, _) |
|
||||
ty::ty_res(_, _, _) { ret true; }
|
||||
ty::ty_param(_, _) | ty::ty_res(_, _, _) { ret true; }
|
||||
ty::ty_var(_) {
|
||||
fail "ty_var in type_is_gc_relevant";
|
||||
}
|
||||
|
@ -1365,9 +1365,8 @@ fn lookup_in_mie(e: env, mie: mod_index_entry, ns: namespace) ->
|
||||
}
|
||||
ast::native_item_fn(decl, _) {
|
||||
if ns == ns_val(ns_any_value) {
|
||||
ret some(ast::def_native_fn(
|
||||
local_def(native_item.id),
|
||||
decl.purity));
|
||||
ret some(ast::def_fn(local_def(native_item.id),
|
||||
decl.purity));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1462,8 +1461,7 @@ fn ns_for_def(d: def) -> namespace {
|
||||
ast::def_variant(_, _) { ns_val(ns_a_enum) }
|
||||
ast::def_fn(_, _) | ast::def_self(_) |
|
||||
ast::def_const(_) | ast::def_arg(_, _) | ast::def_local(_, _) |
|
||||
ast::def_upvar(_, _, _) | ast::def_native_fn(_, _) | ast::def_self(_)
|
||||
{ ns_val(ns_any_value) }
|
||||
ast::def_upvar(_, _, _) | ast::def_self(_) { ns_val(ns_any_value) }
|
||||
ast::def_mod(_) | ast::def_native_mod(_) { ns_module }
|
||||
ast::def_ty(_) | ast::def_binding(_) | ast::def_use(_) |
|
||||
ast::def_native_ty(_) { ns_type }
|
||||
|
@ -413,7 +413,6 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t, ty_param_map: [uint]) -> [u8] {
|
||||
}
|
||||
add_substr(s, sub);
|
||||
}
|
||||
ty::ty_native_fn(_, _) { s += [shape_u32]; }
|
||||
ty::ty_iface(_, _) { s += [shape_iface]; }
|
||||
ty::ty_res(did, raw_subt, tps) {
|
||||
let subt = ty::substitute_type_params(ccx.tcx, tps, raw_subt);
|
||||
|
@ -169,10 +169,6 @@ fn type_of_inner(cx: @crate_ctxt, sp: span, t: ty::t)
|
||||
ty::ty_fn(_) {
|
||||
T_fn_pair(cx, type_of_fn_from_ty(cx, sp, t, []))
|
||||
}
|
||||
ty::ty_native_fn(args, out) {
|
||||
let nft = native_fn_wrapper_type(cx, sp, [], t);
|
||||
T_fn_pair(cx, nft)
|
||||
}
|
||||
ty::ty_iface(_, _) { T_opaque_iface_ptr(cx) }
|
||||
ty::ty_res(_, sub, tps) {
|
||||
let sub1 = ty::substitute_type_params(cx.tcx, tps, sub);
|
||||
@ -233,7 +229,7 @@ fn type_of_ty_param_bounds_and_ty(lcx: @local_ctxt, sp: span,
|
||||
let cx = lcx.ccx;
|
||||
let t = tpt.ty;
|
||||
alt ty::struct(cx.tcx, t) {
|
||||
ty::ty_fn(_) | ty::ty_native_fn(_, _) {
|
||||
ty::ty_fn(_) {
|
||||
ret type_of_fn_from_ty(cx, sp, t, *tpt.bounds);
|
||||
}
|
||||
_ {
|
||||
@ -1274,7 +1270,7 @@ fn make_take_glue(cx: @block_ctxt, v: ValueRef, t: ty::t) {
|
||||
Store(bcx, s, v);
|
||||
bcx
|
||||
}
|
||||
ty::ty_native_fn(_, _) | ty::ty_fn(_) {
|
||||
ty::ty_fn(_) {
|
||||
trans_closure::make_fn_glue(bcx, v, t, take_ty)
|
||||
}
|
||||
ty::ty_opaque_closure_ptr(ck) {
|
||||
@ -1350,7 +1346,7 @@ fn make_free_glue(bcx: @block_ctxt, v: ValueRef, t: ty::t) {
|
||||
Call(bcx, ccx.upcalls.free_shared_type_desc, [v]);
|
||||
bcx
|
||||
}
|
||||
ty::ty_native_fn(_, _) | ty::ty_fn(_) {
|
||||
ty::ty_fn(_) {
|
||||
trans_closure::make_fn_glue(bcx, v, t, free_ty)
|
||||
}
|
||||
ty::ty_opaque_closure_ptr(ck) {
|
||||
@ -1375,7 +1371,7 @@ fn make_drop_glue(bcx: @block_ctxt, v0: ValueRef, t: ty::t) {
|
||||
ty::ty_res(did, inner, tps) {
|
||||
trans_res_drop(bcx, v0, did, inner, tps)
|
||||
}
|
||||
ty::ty_native_fn(_, _) | ty::ty_fn(_) {
|
||||
ty::ty_fn(_) {
|
||||
trans_closure::make_fn_glue(bcx, v0, t, drop_ty)
|
||||
}
|
||||
ty::ty_opaque_closure_ptr(ck) {
|
||||
@ -2637,7 +2633,7 @@ fn trans_var(cx: @block_ctxt, sp: span, def: ast::def, id: ast::node_id)
|
||||
-> lval_maybe_callee {
|
||||
let ccx = bcx_ccx(cx);
|
||||
alt def {
|
||||
ast::def_fn(did, _) | ast::def_native_fn(did, _) {
|
||||
ast::def_fn(did, _) {
|
||||
ret lval_static_fn(cx, did, id);
|
||||
}
|
||||
ast::def_variant(tid, vid) {
|
||||
@ -4697,7 +4693,7 @@ fn c_stack_tys(ccx: @crate_ctxt,
|
||||
sp: span,
|
||||
id: ast::node_id) -> @c_stack_tys {
|
||||
alt ty::struct(ccx.tcx, ty::node_id_to_type(ccx.tcx, id)) {
|
||||
ty::ty_native_fn(arg_tys, ret_ty) {
|
||||
ty::ty_fn({inputs: arg_tys, output: ret_ty, _}) {
|
||||
let tcx = ccx.tcx;
|
||||
let llargtys = type_of_explicit_args(ccx, sp, arg_tys);
|
||||
check non_ty_var(ccx, ret_ty); // NDM does this truly hold?
|
||||
@ -5102,7 +5098,7 @@ fn native_fn_wrapper_type(cx: @crate_ctxt, sp: span,
|
||||
param_bounds: [ty::param_bounds],
|
||||
x: ty::t) -> TypeRef {
|
||||
alt ty::struct(cx.tcx, x) {
|
||||
ty::ty_native_fn(args, out) {
|
||||
ty::ty_fn({inputs: args, output: out, _}) {
|
||||
ret type_of_fn(cx, sp, args, out, param_bounds);
|
||||
}
|
||||
}
|
||||
|
@ -667,8 +667,8 @@ fn make_fn_glue(
|
||||
};
|
||||
|
||||
ret alt ty::struct(tcx, t) {
|
||||
ty::ty_native_fn(_, _) | ty::ty_fn({proto: ast::proto_bare, _}) { bcx }
|
||||
ty::ty_fn({proto: ast::proto_block, _}) { bcx }
|
||||
ty::ty_fn({proto: ast::proto_bare, _}) |
|
||||
ty::ty_fn({proto: ast::proto_block, _}) |
|
||||
ty::ty_fn({proto: ast::proto_any, _}) { bcx }
|
||||
ty::ty_fn({proto: ast::proto_uniq, _}) { fn_env(ty::ck_uniq) }
|
||||
ty::ty_fn({proto: ast::proto_box, _}) { fn_env(ty::ck_box) }
|
||||
|
@ -1075,7 +1075,7 @@ fn callee_modes(fcx: fn_ctxt, callee: node_id) -> [ty::mode] {
|
||||
ty::type_autoderef(fcx.ccx.tcx,
|
||||
ty::node_id_to_type(fcx.ccx.tcx, callee));
|
||||
alt ty::struct(fcx.ccx.tcx, ty) {
|
||||
ty::ty_fn({inputs: args, _}) | ty::ty_native_fn(args, _) {
|
||||
ty::ty_fn({inputs: args, _}) {
|
||||
let modes = [];
|
||||
for arg: ty::arg in args { modes += [arg.mode]; }
|
||||
ret modes;
|
||||
|
@ -70,7 +70,6 @@ export mk_mach_int;
|
||||
export mk_mach_uint;
|
||||
export mk_mach_float;
|
||||
export mk_native;
|
||||
export mk_native_fn;
|
||||
export mk_nil;
|
||||
export mk_iface;
|
||||
export mk_res;
|
||||
@ -106,7 +105,6 @@ export iface_methods, store_iface_methods, impl_iface;
|
||||
export enum_variant_with_id;
|
||||
export ty_param_substs_opt_and_ty;
|
||||
export ty_param_bounds_and_ty;
|
||||
export ty_native_fn;
|
||||
export ty_bool;
|
||||
export ty_bot;
|
||||
export ty_box;
|
||||
@ -265,7 +263,6 @@ enum sty {
|
||||
ty_ptr(mt),
|
||||
ty_rec([field]),
|
||||
ty_fn(fn_ty),
|
||||
ty_native_fn([arg], t),
|
||||
ty_iface(def_id, [t]),
|
||||
ty_res(def_id, t, [t]),
|
||||
ty_tup([t]),
|
||||
@ -493,9 +490,6 @@ fn mk_raw_ty(cx: ctxt, st: sty) -> @raw_t {
|
||||
ty_fn(f) {
|
||||
derive_flags_sig(cx, has_params, has_vars, f.inputs, f.output);
|
||||
}
|
||||
ty_native_fn(args, tt) {
|
||||
derive_flags_sig(cx, has_params, has_vars, args, tt);
|
||||
}
|
||||
ty_res(_, tt, tps) {
|
||||
derive_flags_t(cx, has_params, has_vars, tt);
|
||||
for tt: t in tps { derive_flags_t(cx, has_params, has_vars, tt); }
|
||||
@ -603,10 +597,6 @@ fn mk_fn(cx: ctxt, fty: fn_ty) -> t {
|
||||
ret gen_ty(cx, ty_fn(fty));
|
||||
}
|
||||
|
||||
fn mk_native_fn(cx: ctxt, args: [arg], ty: t) -> t {
|
||||
ret gen_ty(cx, ty_native_fn(args, ty));
|
||||
}
|
||||
|
||||
fn mk_iface(cx: ctxt, did: ast::def_id, tys: [t]) -> t {
|
||||
ret gen_ty(cx, ty_iface(did, tys));
|
||||
}
|
||||
@ -692,10 +682,6 @@ fn walk_ty(cx: ctxt, ty: t, walker: fn(t)) {
|
||||
for a: arg in f.inputs { walk_ty(cx, a.ty, walker); }
|
||||
walk_ty(cx, f.output, walker);
|
||||
}
|
||||
ty_native_fn(args, ret_ty) {
|
||||
for a: arg in args { walk_ty(cx, a.ty, walker); }
|
||||
walk_ty(cx, ret_ty, walker);
|
||||
}
|
||||
ty_res(_, sub, tps) {
|
||||
walk_ty(cx, sub, walker);
|
||||
for tp: t in tps { walk_ty(cx, tp, walker); }
|
||||
@ -774,14 +760,6 @@ fn fold_ty(cx: ctxt, fld: fold_mode, ty_0: t) -> t {
|
||||
output: fold_ty(cx, fld, f.output)
|
||||
with f});
|
||||
}
|
||||
ty_native_fn(args, ret_ty) {
|
||||
let new_args: [arg] = [];
|
||||
for a: arg in args {
|
||||
let new_ty = fold_ty(cx, fld, a.ty);
|
||||
new_args += [{mode: a.mode, ty: new_ty}];
|
||||
}
|
||||
ty = mk_native_fn(cx, new_args, fold_ty(cx, fld, ret_ty));
|
||||
}
|
||||
ty_res(did, subty, tps) {
|
||||
let new_tps = [];
|
||||
for tp: t in tps { new_tps += [fold_ty(cx, fld, tp)]; }
|
||||
@ -823,7 +801,7 @@ fn type_is_bool(cx: ctxt, ty: t) -> bool {
|
||||
fn type_is_structural(cx: ctxt, ty: t) -> bool {
|
||||
alt struct(cx, ty) {
|
||||
ty_rec(_) | ty_tup(_) | ty_enum(_, _) | ty_fn(_) |
|
||||
ty_native_fn(_, _) | ty_res(_, _, _) { true }
|
||||
ty_res(_, _, _) { true }
|
||||
_ { false }
|
||||
}
|
||||
}
|
||||
@ -1025,7 +1003,7 @@ fn type_kind(cx: ctxt, ty: t) -> kind {
|
||||
// Scalar and unique types are sendable
|
||||
ty_nil | ty_bot | ty_bool | ty_int(_) | ty_uint(_) | ty_float(_) |
|
||||
ty_native(_) | ty_ptr(_) |
|
||||
ty_send_type | ty_str | ty_native_fn(_, _) { kind_sendable }
|
||||
ty_send_type | ty_str { kind_sendable }
|
||||
ty_type { kind_copyable }
|
||||
ty_fn(f) { proto_kind(f.proto) }
|
||||
ty_opaque_closure_ptr(ck_block) { kind_noncopyable }
|
||||
@ -1201,7 +1179,7 @@ fn type_is_pod(cx: ctxt, ty: t) -> bool {
|
||||
ty_send_type | ty_type | ty_native(_) | ty_ptr(_) { result = true; }
|
||||
// Boxed types
|
||||
ty_str | ty_box(_) | ty_uniq(_) | ty_vec(_) | ty_fn(_) |
|
||||
ty_native_fn(_, _) | ty_iface(_, _) { result = false; }
|
||||
ty_iface(_, _) { result = false; }
|
||||
// Structural types
|
||||
ty_enum(did, tps) {
|
||||
let variants = enum_variants(cx, did);
|
||||
@ -1384,7 +1362,6 @@ fn hash_type_structure(st: sty) -> uint {
|
||||
|
||||
// ???
|
||||
ty_fn(f) { ret hash_fn(27u, f.inputs, f.output); }
|
||||
ty_native_fn(args, rty) { ret hash_fn(28u, args, rty); }
|
||||
ty_var(v) { ret hash_uint(30u, v as uint); }
|
||||
ty_param(pid, _) { ret hash_uint(31u, pid); }
|
||||
ty_type { ret 32u; }
|
||||
@ -1542,7 +1519,6 @@ fn type_contains_params(cx: ctxt, typ: t) -> bool {
|
||||
fn ty_fn_args(cx: ctxt, fty: t) -> [arg] {
|
||||
alt struct(cx, fty) {
|
||||
ty::ty_fn(f) { ret f.inputs; }
|
||||
ty::ty_native_fn(a, _) { ret a; }
|
||||
_ { cx.sess.bug("ty_fn_args() called on non-fn type"); }
|
||||
}
|
||||
}
|
||||
@ -1550,10 +1526,6 @@ fn ty_fn_args(cx: ctxt, fty: t) -> [arg] {
|
||||
fn ty_fn_proto(cx: ctxt, fty: t) -> ast::proto {
|
||||
alt struct(cx, fty) {
|
||||
ty::ty_fn(f) { ret f.proto; }
|
||||
ty::ty_native_fn(_, _) {
|
||||
// FIXME: This should probably be proto_bare
|
||||
ret ast::proto_box;
|
||||
}
|
||||
_ { cx.sess.bug("ty_fn_proto() called on non-fn type"); }
|
||||
}
|
||||
}
|
||||
@ -1562,7 +1534,6 @@ pure fn ty_fn_ret(cx: ctxt, fty: t) -> t {
|
||||
let sty = struct(cx, fty);
|
||||
alt sty {
|
||||
ty::ty_fn(f) { ret f.output; }
|
||||
ty::ty_native_fn(_, r) { ret r; }
|
||||
_ {
|
||||
// Unchecked is ok since we diverge here
|
||||
// (might want to change the typechecker to allow
|
||||
@ -1577,7 +1548,6 @@ pure fn ty_fn_ret(cx: ctxt, fty: t) -> t {
|
||||
fn ty_fn_ret_style(cx: ctxt, fty: t) -> ast::ret_style {
|
||||
alt struct(cx, fty) {
|
||||
ty::ty_fn(f) { f.ret_style }
|
||||
ty::ty_native_fn(_, _) { ast::return_val }
|
||||
_ { cx.sess.bug("ty_fn_ret_style() called on non-fn type"); }
|
||||
}
|
||||
}
|
||||
@ -1585,7 +1555,6 @@ fn ty_fn_ret_style(cx: ctxt, fty: t) -> ast::ret_style {
|
||||
fn is_fn_ty(cx: ctxt, fty: t) -> bool {
|
||||
alt struct(cx, fty) {
|
||||
ty::ty_fn(_) { ret true; }
|
||||
ty::ty_native_fn(_, _) { ret true; }
|
||||
_ { ret false; }
|
||||
}
|
||||
}
|
||||
@ -2005,19 +1974,6 @@ mod unify {
|
||||
x { x }
|
||||
}
|
||||
}
|
||||
fn unify_native_fn(cx: @ctxt, expected_inputs: [arg], expected_output: t,
|
||||
actual_inputs: [arg], actual_output: t,
|
||||
variance: variance) -> result {
|
||||
let result_ins = alt unify_args(cx, expected_inputs,
|
||||
actual_inputs, variance) {
|
||||
either::left(err) { ret err; }
|
||||
either::right(ts) { ts }
|
||||
};
|
||||
alt unify_step(cx, expected_output, actual_output, variance) {
|
||||
ures_ok(out) { ures_ok(mk_native_fn(cx.tcx, result_ins, out)) }
|
||||
err { err }
|
||||
}
|
||||
}
|
||||
|
||||
// If the given type is a variable, returns the structure of that type.
|
||||
fn resolve_type_structure(tcx: ty_ctxt, vb: @var_bindings, typ: t) ->
|
||||
@ -2403,15 +2359,6 @@ mod unify {
|
||||
_ { ret ures_err(terr_mismatch); }
|
||||
}
|
||||
}
|
||||
ty::ty_native_fn(expected_inputs, expected_output) {
|
||||
alt struct(cx.tcx, actual) {
|
||||
ty::ty_native_fn(actual_inputs, actual_output) {
|
||||
ret unify_native_fn(cx, expected_inputs, expected_output,
|
||||
actual_inputs, actual_output, variance);
|
||||
}
|
||||
_ { ret ures_err(terr_mismatch); }
|
||||
}
|
||||
}
|
||||
ty::ty_constr(expected_t, expected_constrs) {
|
||||
|
||||
// unify the base types...
|
||||
@ -2595,8 +2542,7 @@ fn def_has_ty_params(def: ast::def) -> bool {
|
||||
ast::def_arg(_, _) | ast::def_local(_, _) | ast::def_upvar(_, _, _) |
|
||||
ast::def_ty_param(_, _) | ast::def_binding(_) | ast::def_use(_) |
|
||||
ast::def_native_ty(_) | ast::def_self(_) | ast::def_ty(_) { false }
|
||||
ast::def_fn(_, _) | ast::def_variant(_, _) |
|
||||
ast::def_native_fn(_, _) { true }
|
||||
ast::def_fn(_, _) | ast::def_variant(_, _) { true }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -109,10 +109,8 @@ fn ty_param_bounds_and_ty_for_def(fcx: @fn_ctxt, sp: span, defn: ast::def) ->
|
||||
}
|
||||
}
|
||||
}
|
||||
ast::def_fn(id, _) { ret ty::lookup_item_type(fcx.ccx.tcx, id); }
|
||||
ast::def_native_fn(id, _) { ret ty::lookup_item_type(fcx.ccx.tcx, id); }
|
||||
ast::def_const(id) { ret ty::lookup_item_type(fcx.ccx.tcx, id); }
|
||||
ast::def_variant(_, vid) { ret ty::lookup_item_type(fcx.ccx.tcx, vid); }
|
||||
ast::def_fn(id, _) | ast::def_const(id) |
|
||||
ast::def_variant(_, id) { ret ty::lookup_item_type(fcx.ccx.tcx, id); }
|
||||
ast::def_binding(id) {
|
||||
assert (fcx.locals.contains_key(id.node));
|
||||
let typ = ty::mk_var(fcx.ccx.tcx, lookup_local(fcx, sp, id.node));
|
||||
@ -479,7 +477,11 @@ fn ty_of_native_fn_decl(tcx: ty::ctxt, mode: mode, decl: ast::fn_decl,
|
||||
for a: ast::arg in decl.inputs { input_tys += [ty_of_arg(tcx, mode, a)]; }
|
||||
let output_ty = ast_ty_to_ty(tcx, mode, decl.output);
|
||||
|
||||
let t_fn = ty::mk_native_fn(tcx, input_tys, output_ty);
|
||||
let t_fn = ty::mk_fn(tcx, {proto: ast::proto_bare,
|
||||
inputs: input_tys,
|
||||
output: output_ty,
|
||||
ret_style: ast::return_val,
|
||||
constraints: []});
|
||||
let tpt = {bounds: bounds, ty: t_fn};
|
||||
tcx.tcache.insert(def_id, tpt);
|
||||
ret tpt;
|
||||
@ -1443,8 +1445,7 @@ fn require_pure_call(ccx: @crate_ctxt, caller_purity: ast::purity,
|
||||
ast::unsafe_fn { ret; }
|
||||
ast::impure_fn {
|
||||
alt ccx.tcx.def_map.find(callee.id) {
|
||||
some(ast::def_fn(_, ast::unsafe_fn)) |
|
||||
some(ast::def_native_fn(_, ast::unsafe_fn)) {
|
||||
some(ast::def_fn(_, ast::unsafe_fn)) {
|
||||
ccx.tcx.sess.span_err(
|
||||
sp,
|
||||
"safe function calls function marked unsafe");
|
||||
@ -1457,7 +1458,6 @@ fn require_pure_call(ccx: @crate_ctxt, caller_purity: ast::purity,
|
||||
ast::pure_fn {
|
||||
alt ccx.tcx.def_map.find(callee.id) {
|
||||
some(ast::def_fn(_, ast::pure_fn)) |
|
||||
some(ast::def_native_fn(_, ast::pure_fn)) |
|
||||
some(ast::def_variant(_, _)) { ret; }
|
||||
_ {
|
||||
ccx.tcx.sess.span_err
|
||||
@ -1626,7 +1626,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
|
||||
// Grab the argument types
|
||||
let arg_tys =
|
||||
alt sty {
|
||||
ty::ty_fn({inputs: arg_tys, _}) | ty::ty_native_fn(arg_tys, _) {
|
||||
ty::ty_fn({inputs: arg_tys, _}) {
|
||||
arg_tys
|
||||
}
|
||||
_ {
|
||||
@ -1726,16 +1726,14 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
|
||||
let bot = check_call(fcx, sp, f, args);
|
||||
|
||||
// Pull the return type out of the type of the function.
|
||||
let rt_1;
|
||||
let fty = ty::expr_ty(fcx.ccx.tcx, f);
|
||||
alt structure_of(fcx, sp, fty) {
|
||||
let rt_1 = alt structure_of(fcx, sp, fty) {
|
||||
ty::ty_fn(f) {
|
||||
bot |= f.ret_style == ast::noreturn;
|
||||
rt_1 = f.output;
|
||||
f.output
|
||||
}
|
||||
ty::ty_native_fn(_, rt) { rt_1 = rt; }
|
||||
_ { fcx.ccx.tcx.sess.span_fatal(sp, "calling non-function"); }
|
||||
}
|
||||
};
|
||||
write::ty_only_fixup(fcx, id, rt_1);
|
||||
ret bot;
|
||||
}
|
||||
@ -2086,13 +2084,6 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
|
||||
cf = f.ret_style;
|
||||
constrs = f.constraints;
|
||||
}
|
||||
ty::ty_native_fn(arg_tys_, rt_) {
|
||||
proto = ast::proto_bare;
|
||||
arg_tys = arg_tys_;
|
||||
rt = rt_;
|
||||
cf = ast::return_val;
|
||||
constrs = [];
|
||||
}
|
||||
_ { fail "LHS of bind expr didn't have a function type?!"; }
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,6 @@ enum def {
|
||||
def_binding(def_id),
|
||||
def_use(def_id),
|
||||
def_native_ty(def_id),
|
||||
def_native_fn(def_id, purity),
|
||||
def_upvar(def_id, @def, node_id), // node_id == expr_fn or expr_fn_block
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ fn def_id_of_def(d: def) -> def_id {
|
||||
def_native_mod(id) | def_const(id) | def_arg(id, _) | def_local(id, _) |
|
||||
def_variant(_, id) | def_ty(id) | def_ty_param(id, _) |
|
||||
def_binding(id) | def_use(id) | def_native_ty(id) |
|
||||
def_native_fn(id, _) | def_upvar(id, _, _) { id }
|
||||
def_upvar(id, _, _) { id }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -116,10 +116,6 @@ fn ty_to_str(cx: ctxt, typ: t) -> str {
|
||||
fn_to_str(cx, f.proto, none, f.inputs, f.output, f.ret_style,
|
||||
f.constraints)
|
||||
}
|
||||
ty_native_fn(inputs, output) {
|
||||
fn_to_str(cx, ast::proto_bare, none, inputs, output,
|
||||
ast::return_val, [])
|
||||
}
|
||||
ty_var(v) { "<T" + int::str(v) + ">" }
|
||||
ty_param(id, _) {
|
||||
"'" + str::unsafe_from_bytes([('a' as u8) + (id as u8)])
|
||||
|
Loading…
x
Reference in New Issue
Block a user