Skip to content

Commit ec4d05d

Browse files
committed
Remove ty_native_fn
It was being used as a clumsy synonym of ty_fn.
1 parent 566a4be commit ec4d05d

File tree

17 files changed

+38
-128
lines changed

17 files changed

+38
-128
lines changed

src/comp/metadata/decoder.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,6 @@ fn lookup_def(cnum: ast::crate_num, data: @[u8], did_: ast::def_id) ->
197197
'u' { ast::def_fn(did, ast::unsafe_fn) }
198198
'f' { ast::def_fn(did, ast::impure_fn) }
199199
'p' { ast::def_fn(did, ast::pure_fn) }
200-
'U' { ast::def_native_fn(did, ast::unsafe_fn) }
201-
'F' { ast::def_native_fn(did, ast::impure_fn) }
202-
'P' { ast::def_native_fn(did, ast::pure_fn) }
203200
'y' { ast::def_ty(did) }
204201
'T' { ast::def_native_ty(did) }
205202
't' { ast::def_ty(did) }

src/comp/metadata/encoder.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -427,12 +427,11 @@ fn encode_info_for_native_item(ecx: @encode_ctxt, ebml_w: ebml::writer,
427427
ty::mk_native(ecx.ccx.tcx, local_def(nitem.id)));
428428
}
429429
native_item_fn(fn_decl, tps) {
430-
let letter =
431-
alt fn_decl.purity {
432-
unsafe_fn { 'U' }
433-
pure_fn { 'P' } // this is currently impossible, but hey.
434-
impure_fn { 'F' }
435-
} as u8;
430+
let letter = alt fn_decl.purity {
431+
unsafe_fn { 'u' }
432+
pure_fn { 'p' } // this is currently impossible, but hey.
433+
impure_fn { 'f' }
434+
} as u8;
436435
encode_def_id(ebml_w, local_def(nitem.id));
437436
encode_family(ebml_w, letter);
438437
encode_type_param_bounds(ebml_w, ecx, tps);

src/comp/metadata/tydecode.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,10 +245,6 @@ fn parse_ty(st: @pstate, conv: conv_did) -> ty::t {
245245
let proto = parse_proto(next(st) as char);
246246
parse_ty_rust_fn(st, conv, proto)
247247
}
248-
'N' {
249-
let func = parse_ty_fn(st, conv);
250-
ret ty::mk_native_fn(st.tcx, func.inputs, func.output);
251-
}
252248
'r' {
253249
assert (next(st) as char == '[');
254250
let def = parse_def(st, conv);

src/comp/metadata/tyencode.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,6 @@ fn enc_sty(w: io::writer, cx: @ctxt, st: ty::sty) {
153153
enc_proto(w, f.proto);
154154
enc_ty_fn(w, cx, f);
155155
}
156-
ty::ty_native_fn(args, out) {
157-
w.write_char('N');
158-
enc_ty_fn(w, cx, {proto: proto_bare, inputs: args, output: out,
159-
ret_style: return_val, constraints: []});
160-
}
161156
ty::ty_res(def, ty, tps) {
162157
w.write_str("r[");
163158
w.write_str(cx.ds(def));

src/comp/middle/alias.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ fn copy_is_expensive(tcx: ty::ctxt, ty: ty::t) -> bool {
562562
ty::ty_ptr(_) { 1u }
563563
ty::ty_box(_) | ty::ty_iface(_, _) { 3u }
564564
ty::ty_constr(t, _) | ty::ty_res(_, t, _) { score_ty(tcx, t) }
565-
ty::ty_fn(_) | ty::ty_native_fn(_, _) { 4u }
565+
ty::ty_fn(_) { 4u }
566566
ty::ty_str | ty::ty_vec(_) | ty::ty_param(_, _) { 50u }
567567
ty::ty_uniq(mt) { 1u + score_ty(tcx, mt.ty) }
568568
ty::ty_enum(_, ts) | ty::ty_tup(ts) {

src/comp/middle/fn_usage.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ fn fn_usage_expr(expr: @ast::expr,
1919
ast::expr_path(path) {
2020
if !ctx.unsafe_fn_legal {
2121
alt ctx.tcx.def_map.find(expr.id) {
22-
some(ast::def_fn(_, ast::unsafe_fn)) |
23-
some(ast::def_native_fn(_, ast::unsafe_fn)) {
22+
some(ast::def_fn(_, ast::unsafe_fn)) {
2423
log(error, ("expr=", expr_to_str(expr)));
2524
ctx.tcx.sess.span_fatal(
2625
expr.span,

src/comp/middle/gc.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,7 @@ fn type_is_gc_relevant(cx: ty::ctxt, ty: ty::t) -> bool {
131131
}
132132
ty::ty_constr(sub, _) { ret type_is_gc_relevant(cx, sub); }
133133
ty::ty_box(_) | ty::ty_uniq(_) | ty::ty_fn(_) |
134-
ty::ty_native_fn(_, _) | ty::ty_param(_, _) |
135-
ty::ty_res(_, _, _) { ret true; }
134+
ty::ty_param(_, _) | ty::ty_res(_, _, _) { ret true; }
136135
ty::ty_var(_) {
137136
fail "ty_var in type_is_gc_relevant";
138137
}

src/comp/middle/resolve.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,9 +1365,8 @@ fn lookup_in_mie(e: env, mie: mod_index_entry, ns: namespace) ->
13651365
}
13661366
ast::native_item_fn(decl, _) {
13671367
if ns == ns_val(ns_any_value) {
1368-
ret some(ast::def_native_fn(
1369-
local_def(native_item.id),
1370-
decl.purity));
1368+
ret some(ast::def_fn(local_def(native_item.id),
1369+
decl.purity));
13711370
}
13721371
}
13731372
}
@@ -1462,8 +1461,7 @@ fn ns_for_def(d: def) -> namespace {
14621461
ast::def_variant(_, _) { ns_val(ns_a_enum) }
14631462
ast::def_fn(_, _) | ast::def_self(_) |
14641463
ast::def_const(_) | ast::def_arg(_, _) | ast::def_local(_, _) |
1465-
ast::def_upvar(_, _, _) | ast::def_native_fn(_, _) | ast::def_self(_)
1466-
{ ns_val(ns_any_value) }
1464+
ast::def_upvar(_, _, _) | ast::def_self(_) { ns_val(ns_any_value) }
14671465
ast::def_mod(_) | ast::def_native_mod(_) { ns_module }
14681466
ast::def_ty(_) | ast::def_binding(_) | ast::def_use(_) |
14691467
ast::def_native_ty(_) { ns_type }

src/comp/middle/shape.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,6 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t, ty_param_map: [uint]) -> [u8] {
413413
}
414414
add_substr(s, sub);
415415
}
416-
ty::ty_native_fn(_, _) { s += [shape_u32]; }
417416
ty::ty_iface(_, _) { s += [shape_iface]; }
418417
ty::ty_res(did, raw_subt, tps) {
419418
let subt = ty::substitute_type_params(ccx.tcx, tps, raw_subt);

src/comp/middle/trans.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,6 @@ fn type_of_inner(cx: @crate_ctxt, sp: span, t: ty::t)
169169
ty::ty_fn(_) {
170170
T_fn_pair(cx, type_of_fn_from_ty(cx, sp, t, []))
171171
}
172-
ty::ty_native_fn(args, out) {
173-
let nft = native_fn_wrapper_type(cx, sp, [], t);
174-
T_fn_pair(cx, nft)
175-
}
176172
ty::ty_iface(_, _) { T_opaque_iface_ptr(cx) }
177173
ty::ty_res(_, sub, tps) {
178174
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,
233229
let cx = lcx.ccx;
234230
let t = tpt.ty;
235231
alt ty::struct(cx.tcx, t) {
236-
ty::ty_fn(_) | ty::ty_native_fn(_, _) {
232+
ty::ty_fn(_) {
237233
ret type_of_fn_from_ty(cx, sp, t, *tpt.bounds);
238234
}
239235
_ {
@@ -1274,7 +1270,7 @@ fn make_take_glue(cx: @block_ctxt, v: ValueRef, t: ty::t) {
12741270
Store(bcx, s, v);
12751271
bcx
12761272
}
1277-
ty::ty_native_fn(_, _) | ty::ty_fn(_) {
1273+
ty::ty_fn(_) {
12781274
trans_closure::make_fn_glue(bcx, v, t, take_ty)
12791275
}
12801276
ty::ty_opaque_closure_ptr(ck) {
@@ -1350,7 +1346,7 @@ fn make_free_glue(bcx: @block_ctxt, v: ValueRef, t: ty::t) {
13501346
Call(bcx, ccx.upcalls.free_shared_type_desc, [v]);
13511347
bcx
13521348
}
1353-
ty::ty_native_fn(_, _) | ty::ty_fn(_) {
1349+
ty::ty_fn(_) {
13541350
trans_closure::make_fn_glue(bcx, v, t, free_ty)
13551351
}
13561352
ty::ty_opaque_closure_ptr(ck) {
@@ -1375,7 +1371,7 @@ fn make_drop_glue(bcx: @block_ctxt, v0: ValueRef, t: ty::t) {
13751371
ty::ty_res(did, inner, tps) {
13761372
trans_res_drop(bcx, v0, did, inner, tps)
13771373
}
1378-
ty::ty_native_fn(_, _) | ty::ty_fn(_) {
1374+
ty::ty_fn(_) {
13791375
trans_closure::make_fn_glue(bcx, v0, t, drop_ty)
13801376
}
13811377
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)
26372633
-> lval_maybe_callee {
26382634
let ccx = bcx_ccx(cx);
26392635
alt def {
2640-
ast::def_fn(did, _) | ast::def_native_fn(did, _) {
2636+
ast::def_fn(did, _) {
26412637
ret lval_static_fn(cx, did, id);
26422638
}
26432639
ast::def_variant(tid, vid) {
@@ -4697,7 +4693,7 @@ fn c_stack_tys(ccx: @crate_ctxt,
46974693
sp: span,
46984694
id: ast::node_id) -> @c_stack_tys {
46994695
alt ty::struct(ccx.tcx, ty::node_id_to_type(ccx.tcx, id)) {
4700-
ty::ty_native_fn(arg_tys, ret_ty) {
4696+
ty::ty_fn({inputs: arg_tys, output: ret_ty, _}) {
47014697
let tcx = ccx.tcx;
47024698
let llargtys = type_of_explicit_args(ccx, sp, arg_tys);
47034699
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,
51025098
param_bounds: [ty::param_bounds],
51035099
x: ty::t) -> TypeRef {
51045100
alt ty::struct(cx.tcx, x) {
5105-
ty::ty_native_fn(args, out) {
5101+
ty::ty_fn({inputs: args, output: out, _}) {
51065102
ret type_of_fn(cx, sp, args, out, param_bounds);
51075103
}
51085104
}

src/comp/middle/trans_closure.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -667,8 +667,8 @@ fn make_fn_glue(
667667
};
668668

669669
ret alt ty::struct(tcx, t) {
670-
ty::ty_native_fn(_, _) | ty::ty_fn({proto: ast::proto_bare, _}) { bcx }
671-
ty::ty_fn({proto: ast::proto_block, _}) { bcx }
670+
ty::ty_fn({proto: ast::proto_bare, _}) |
671+
ty::ty_fn({proto: ast::proto_block, _}) |
672672
ty::ty_fn({proto: ast::proto_any, _}) { bcx }
673673
ty::ty_fn({proto: ast::proto_uniq, _}) { fn_env(ty::ck_uniq) }
674674
ty::ty_fn({proto: ast::proto_box, _}) { fn_env(ty::ck_box) }

src/comp/middle/tstate/auxiliary.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1075,7 +1075,7 @@ fn callee_modes(fcx: fn_ctxt, callee: node_id) -> [ty::mode] {
10751075
ty::type_autoderef(fcx.ccx.tcx,
10761076
ty::node_id_to_type(fcx.ccx.tcx, callee));
10771077
alt ty::struct(fcx.ccx.tcx, ty) {
1078-
ty::ty_fn({inputs: args, _}) | ty::ty_native_fn(args, _) {
1078+
ty::ty_fn({inputs: args, _}) {
10791079
let modes = [];
10801080
for arg: ty::arg in args { modes += [arg.mode]; }
10811081
ret modes;

src/comp/middle/ty.rs

Lines changed: 4 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ export mk_mach_int;
7070
export mk_mach_uint;
7171
export mk_mach_float;
7272
export mk_native;
73-
export mk_native_fn;
7473
export mk_nil;
7574
export mk_iface;
7675
export mk_res;
@@ -106,7 +105,6 @@ export iface_methods, store_iface_methods, impl_iface;
106105
export enum_variant_with_id;
107106
export ty_param_substs_opt_and_ty;
108107
export ty_param_bounds_and_ty;
109-
export ty_native_fn;
110108
export ty_bool;
111109
export ty_bot;
112110
export ty_box;
@@ -265,7 +263,6 @@ enum sty {
265263
ty_ptr(mt),
266264
ty_rec([field]),
267265
ty_fn(fn_ty),
268-
ty_native_fn([arg], t),
269266
ty_iface(def_id, [t]),
270267
ty_res(def_id, t, [t]),
271268
ty_tup([t]),
@@ -493,9 +490,6 @@ fn mk_raw_ty(cx: ctxt, st: sty) -> @raw_t {
493490
ty_fn(f) {
494491
derive_flags_sig(cx, has_params, has_vars, f.inputs, f.output);
495492
}
496-
ty_native_fn(args, tt) {
497-
derive_flags_sig(cx, has_params, has_vars, args, tt);
498-
}
499493
ty_res(_, tt, tps) {
500494
derive_flags_t(cx, has_params, has_vars, tt);
501495
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 {
603597
ret gen_ty(cx, ty_fn(fty));
604598
}
605599

606-
fn mk_native_fn(cx: ctxt, args: [arg], ty: t) -> t {
607-
ret gen_ty(cx, ty_native_fn(args, ty));
608-
}
609-
610600
fn mk_iface(cx: ctxt, did: ast::def_id, tys: [t]) -> t {
611601
ret gen_ty(cx, ty_iface(did, tys));
612602
}
@@ -692,10 +682,6 @@ fn walk_ty(cx: ctxt, ty: t, walker: fn(t)) {
692682
for a: arg in f.inputs { walk_ty(cx, a.ty, walker); }
693683
walk_ty(cx, f.output, walker);
694684
}
695-
ty_native_fn(args, ret_ty) {
696-
for a: arg in args { walk_ty(cx, a.ty, walker); }
697-
walk_ty(cx, ret_ty, walker);
698-
}
699685
ty_res(_, sub, tps) {
700686
walk_ty(cx, sub, walker);
701687
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 {
774760
output: fold_ty(cx, fld, f.output)
775761
with f});
776762
}
777-
ty_native_fn(args, ret_ty) {
778-
let new_args: [arg] = [];
779-
for a: arg in args {
780-
let new_ty = fold_ty(cx, fld, a.ty);
781-
new_args += [{mode: a.mode, ty: new_ty}];
782-
}
783-
ty = mk_native_fn(cx, new_args, fold_ty(cx, fld, ret_ty));
784-
}
785763
ty_res(did, subty, tps) {
786764
let new_tps = [];
787765
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 {
823801
fn type_is_structural(cx: ctxt, ty: t) -> bool {
824802
alt struct(cx, ty) {
825803
ty_rec(_) | ty_tup(_) | ty_enum(_, _) | ty_fn(_) |
826-
ty_native_fn(_, _) | ty_res(_, _, _) { true }
804+
ty_res(_, _, _) { true }
827805
_ { false }
828806
}
829807
}
@@ -1025,7 +1003,7 @@ fn type_kind(cx: ctxt, ty: t) -> kind {
10251003
// Scalar and unique types are sendable
10261004
ty_nil | ty_bot | ty_bool | ty_int(_) | ty_uint(_) | ty_float(_) |
10271005
ty_native(_) | ty_ptr(_) |
1028-
ty_send_type | ty_str | ty_native_fn(_, _) { kind_sendable }
1006+
ty_send_type | ty_str { kind_sendable }
10291007
ty_type { kind_copyable }
10301008
ty_fn(f) { proto_kind(f.proto) }
10311009
ty_opaque_closure_ptr(ck_block) { kind_noncopyable }
@@ -1201,7 +1179,7 @@ fn type_is_pod(cx: ctxt, ty: t) -> bool {
12011179
ty_send_type | ty_type | ty_native(_) | ty_ptr(_) { result = true; }
12021180
// Boxed types
12031181
ty_str | ty_box(_) | ty_uniq(_) | ty_vec(_) | ty_fn(_) |
1204-
ty_native_fn(_, _) | ty_iface(_, _) { result = false; }
1182+
ty_iface(_, _) { result = false; }
12051183
// Structural types
12061184
ty_enum(did, tps) {
12071185
let variants = enum_variants(cx, did);
@@ -1384,7 +1362,6 @@ fn hash_type_structure(st: sty) -> uint {
13841362

13851363
// ???
13861364
ty_fn(f) { ret hash_fn(27u, f.inputs, f.output); }
1387-
ty_native_fn(args, rty) { ret hash_fn(28u, args, rty); }
13881365
ty_var(v) { ret hash_uint(30u, v as uint); }
13891366
ty_param(pid, _) { ret hash_uint(31u, pid); }
13901367
ty_type { ret 32u; }
@@ -1542,18 +1519,13 @@ fn type_contains_params(cx: ctxt, typ: t) -> bool {
15421519
fn ty_fn_args(cx: ctxt, fty: t) -> [arg] {
15431520
alt struct(cx, fty) {
15441521
ty::ty_fn(f) { ret f.inputs; }
1545-
ty::ty_native_fn(a, _) { ret a; }
15461522
_ { cx.sess.bug("ty_fn_args() called on non-fn type"); }
15471523
}
15481524
}
15491525

15501526
fn ty_fn_proto(cx: ctxt, fty: t) -> ast::proto {
15511527
alt struct(cx, fty) {
15521528
ty::ty_fn(f) { ret f.proto; }
1553-
ty::ty_native_fn(_, _) {
1554-
// FIXME: This should probably be proto_bare
1555-
ret ast::proto_box;
1556-
}
15571529
_ { cx.sess.bug("ty_fn_proto() called on non-fn type"); }
15581530
}
15591531
}
@@ -1562,7 +1534,6 @@ pure fn ty_fn_ret(cx: ctxt, fty: t) -> t {
15621534
let sty = struct(cx, fty);
15631535
alt sty {
15641536
ty::ty_fn(f) { ret f.output; }
1565-
ty::ty_native_fn(_, r) { ret r; }
15661537
_ {
15671538
// Unchecked is ok since we diverge here
15681539
// (might want to change the typechecker to allow
@@ -1577,15 +1548,13 @@ pure fn ty_fn_ret(cx: ctxt, fty: t) -> t {
15771548
fn ty_fn_ret_style(cx: ctxt, fty: t) -> ast::ret_style {
15781549
alt struct(cx, fty) {
15791550
ty::ty_fn(f) { f.ret_style }
1580-
ty::ty_native_fn(_, _) { ast::return_val }
15811551
_ { cx.sess.bug("ty_fn_ret_style() called on non-fn type"); }
15821552
}
15831553
}
15841554

15851555
fn is_fn_ty(cx: ctxt, fty: t) -> bool {
15861556
alt struct(cx, fty) {
15871557
ty::ty_fn(_) { ret true; }
1588-
ty::ty_native_fn(_, _) { ret true; }
15891558
_ { ret false; }
15901559
}
15911560
}
@@ -2005,19 +1974,6 @@ mod unify {
20051974
x { x }
20061975
}
20071976
}
2008-
fn unify_native_fn(cx: @ctxt, expected_inputs: [arg], expected_output: t,
2009-
actual_inputs: [arg], actual_output: t,
2010-
variance: variance) -> result {
2011-
let result_ins = alt unify_args(cx, expected_inputs,
2012-
actual_inputs, variance) {
2013-
either::left(err) { ret err; }
2014-
either::right(ts) { ts }
2015-
};
2016-
alt unify_step(cx, expected_output, actual_output, variance) {
2017-
ures_ok(out) { ures_ok(mk_native_fn(cx.tcx, result_ins, out)) }
2018-
err { err }
2019-
}
2020-
}
20211977

20221978
// If the given type is a variable, returns the structure of that type.
20231979
fn resolve_type_structure(tcx: ty_ctxt, vb: @var_bindings, typ: t) ->
@@ -2403,15 +2359,6 @@ mod unify {
24032359
_ { ret ures_err(terr_mismatch); }
24042360
}
24052361
}
2406-
ty::ty_native_fn(expected_inputs, expected_output) {
2407-
alt struct(cx.tcx, actual) {
2408-
ty::ty_native_fn(actual_inputs, actual_output) {
2409-
ret unify_native_fn(cx, expected_inputs, expected_output,
2410-
actual_inputs, actual_output, variance);
2411-
}
2412-
_ { ret ures_err(terr_mismatch); }
2413-
}
2414-
}
24152362
ty::ty_constr(expected_t, expected_constrs) {
24162363

24172364
// unify the base types...
@@ -2595,8 +2542,7 @@ fn def_has_ty_params(def: ast::def) -> bool {
25952542
ast::def_arg(_, _) | ast::def_local(_, _) | ast::def_upvar(_, _, _) |
25962543
ast::def_ty_param(_, _) | ast::def_binding(_) | ast::def_use(_) |
25972544
ast::def_native_ty(_) | ast::def_self(_) | ast::def_ty(_) { false }
2598-
ast::def_fn(_, _) | ast::def_variant(_, _) |
2599-
ast::def_native_fn(_, _) { true }
2545+
ast::def_fn(_, _) | ast::def_variant(_, _) { true }
26002546
}
26012547
}
26022548

0 commit comments

Comments
 (0)