Skip to content

Commit 2dbaa05

Browse files
committed
Remove support for native types
Issue #1673
1 parent 856a544 commit 2dbaa05

File tree

18 files changed

+17
-124
lines changed

18 files changed

+17
-124
lines changed

src/comp/metadata/decoder.rs

-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ fn lookup_def(cnum: ast::crate_num, data: @[u8], did_: ast::def_id) ->
198198
'f' { ast::def_fn(did, ast::impure_fn) }
199199
'p' { ast::def_fn(did, ast::pure_fn) }
200200
'y' { ast::def_ty(did) }
201-
'T' { ast::def_native_ty(did) }
202201
't' { ast::def_ty(did) }
203202
'm' { ast::def_mod(did) }
204203
'n' { ast::def_native_mod(did) }

src/comp/metadata/encoder.rs

-6
Original file line numberDiff line numberDiff line change
@@ -423,12 +423,6 @@ fn encode_info_for_native_item(ecx: @encode_ctxt, ebml_w: ebml::writer,
423423
nitem: @native_item) {
424424
ebml::start_tag(ebml_w, tag_items_data_item);
425425
alt nitem.node {
426-
native_item_ty {
427-
encode_def_id(ebml_w, local_def(nitem.id));
428-
encode_family(ebml_w, 'T' as u8);
429-
encode_type(ecx, ebml_w,
430-
ty::mk_native(ecx.ccx.tcx, local_def(nitem.id)));
431-
}
432426
native_item_fn(fn_decl, tps) {
433427
let letter = alt fn_decl.purity {
434428
unsafe_fn { 'u' }

src/comp/metadata/tydecode.rs

-1
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,6 @@ fn parse_ty(st: @pstate, conv: conv_did) -> ty::t {
255255
ret ty::mk_res(st.tcx, def, inner, params);
256256
}
257257
'X' { ret ty::mk_var(st.tcx, parse_int(st)); }
258-
'E' { let def = parse_def(st, conv); ret ty::mk_native(st.tcx, def); }
259258
'Y' { ret ty::mk_type(st.tcx); }
260259
'y' { ret ty::mk_send_type(st.tcx); }
261260
'C' {

src/comp/metadata/tyencode.rs

-5
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,6 @@ fn enc_sty(w: io::writer, cx: @ctxt, st: ty::sty) {
163163
w.write_char(']');
164164
}
165165
ty::ty_var(id) { w.write_char('X'); w.write_str(int::str(id)); }
166-
ty::ty_native(def) {
167-
w.write_char('E');
168-
w.write_str(cx.ds(def));
169-
w.write_char('|');
170-
}
171166
ty::ty_param(id, did) {
172167
w.write_char('p');
173168
w.write_str(cx.ds(did));

src/comp/middle/alias.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ fn copy_is_expensive(tcx: ty::ctxt, ty: ty::t) -> bool {
560560
fn score_ty(tcx: ty::ctxt, ty: ty::t) -> uint {
561561
ret alt ty::struct(tcx, ty) {
562562
ty::ty_nil | ty::ty_bot | ty::ty_bool | ty::ty_int(_) |
563-
ty::ty_uint(_) | ty::ty_float(_) | ty::ty_type | ty::ty_native(_) |
563+
ty::ty_uint(_) | ty::ty_float(_) | ty::ty_type |
564564
ty::ty_ptr(_) { 1u }
565565
ty::ty_box(_) | ty::ty_iface(_, _) { 3u }
566566
ty::ty_constr(t, _) | ty::ty_res(_, t, _) { score_ty(tcx, t) }

src/comp/middle/gc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ fn type_is_gc_relevant(cx: ty::ctxt, ty: ty::t) -> bool {
103103
alt ty::struct(cx, ty) {
104104
ty::ty_nil | ty::ty_bot | ty::ty_bool | ty::ty_int(_) |
105105
ty::ty_float(_) | ty::ty_uint(_) | ty::ty_str |
106-
ty::ty_type | ty::ty_send_type | ty::ty_ptr(_) | ty::ty_native(_) {
106+
ty::ty_type | ty::ty_send_type | ty::ty_ptr(_) {
107107
ret false;
108108
}
109109
ty::ty_rec(fields) {

src/comp/middle/resolve.rs

-6
Original file line numberDiff line numberDiff line change
@@ -1358,11 +1358,6 @@ fn lookup_in_mie(e: env, mie: mod_index_entry, ns: namespace) ->
13581358
}
13591359
mie_native_item(native_item) {
13601360
alt native_item.node {
1361-
ast::native_item_ty {
1362-
if ns == ns_type {
1363-
ret some(ast::def_native_ty(local_def(native_item.id)));
1364-
}
1365-
}
13661361
ast::native_item_fn(decl, _) {
13671362
if ns == ns_val(ns_any_value) {
13681363
ret some(ast::def_fn(local_def(native_item.id),
@@ -1467,7 +1462,6 @@ fn ns_for_def(d: def) -> namespace {
14671462
ast::def_upvar(_, _, _) | ast::def_self(_) { ns_val(ns_any_value) }
14681463
ast::def_mod(_) | ast::def_native_mod(_) { ns_module }
14691464
ast::def_ty(_) | ast::def_binding(_) | ast::def_use(_) |
1470-
ast::def_native_ty(_) { ns_type }
14711465
ast::def_ty_param(_, _) { ns_type }
14721466
}
14731467
}

src/comp/middle/shape.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,7 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t, ty_param_map: [uint]) -> [u8] {
324324
ty::ty_bot { s += [shape_u8]; }
325325
ty::ty_int(ast::ty_i) { s += [s_int(ccx.tcx)]; }
326326
ty::ty_float(ast::ty_f) { s += [s_float(ccx.tcx)]; }
327-
ty::ty_uint(ast::ty_u) | ty::ty_ptr(_) |
328-
ty::ty_native(_) { s += [s_uint(ccx.tcx)]; }
327+
ty::ty_uint(ast::ty_u) | ty::ty_ptr(_) { s += [s_uint(ccx.tcx)]; }
329328
ty::ty_type { s += [s_tydesc(ccx.tcx)]; }
330329
ty::ty_send_type { s += [s_send_tydesc(ccx.tcx)]; }
331330
ty::ty_int(ast::ty_i8) { s += [shape_i8]; }

src/comp/middle/trans/base.rs

+3-15
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ fn type_of_inner(cx: @crate_ctxt, t: ty::t)
125125

126126
if cx.lltypes.contains_key(t) { ret cx.lltypes.get(t); }
127127
let llty = alt ty::struct(cx.tcx, t) {
128-
ty::ty_native(_) { T_ptr(T_i8()) }
129128
ty::ty_nil { T_nil() }
130129
ty::ty_bot {
131130
T_nil() /* ...I guess? */
@@ -1421,11 +1420,6 @@ fn compare_scalar_types(cx: @block_ctxt, lhs: ValueRef, rhs: ValueRef,
14211420
ty::ty_int(_) { ret rslt(cx, f(signed_int)); }
14221421
ty::ty_uint(_) { ret rslt(cx, f(unsigned_int)); }
14231422
ty::ty_float(_) { ret rslt(cx, f(floating_point)); }
1424-
ty::ty_native(_) {
1425-
let cx = trans_fail(cx, none::<span>,
1426-
"attempt to compare values of type native");
1427-
ret rslt(cx, C_nil());
1428-
}
14291423
ty::ty_type {
14301424
ret rslt(trans_fail(cx, none,
14311425
"attempt to compare values of type type"),
@@ -1922,7 +1916,7 @@ fn copy_val(cx: @block_ctxt, action: copy_action, dst: ValueRef,
19221916
fn copy_val_no_check(bcx: @block_ctxt, action: copy_action, dst: ValueRef,
19231917
src: ValueRef, t: ty::t) -> @block_ctxt {
19241918
let ccx = bcx_ccx(bcx), bcx = bcx;
1925-
if ty::type_is_scalar(ccx.tcx, t) || ty::type_is_native(ccx.tcx, t) {
1919+
if ty::type_is_scalar(ccx.tcx, t) {
19261920
Store(bcx, src, dst);
19271921
ret bcx;
19281922
}
@@ -1952,7 +1946,7 @@ fn move_val(cx: @block_ctxt, action: copy_action, dst: ValueRef,
19521946
src: lval_result, t: ty::t) -> @block_ctxt {
19531947
let src_val = src.val;
19541948
let tcx = bcx_tcx(cx), cx = cx;
1955-
if ty::type_is_scalar(tcx, t) || ty::type_is_native(tcx, t) {
1949+
if ty::type_is_scalar(tcx, t) {
19561950
if src.kind == owned { src_val = Load(cx, src_val); }
19571951
Store(cx, src_val, dst);
19581952
ret cx;
@@ -2905,8 +2899,7 @@ fn trans_cast(cx: @block_ctxt, e: @ast::expr, id: ast::node_id,
29052899
fn t_kind(tcx: ty::ctxt, t: ty::t) -> kind {
29062900
ret if ty::type_is_fp(tcx, t) {
29072901
float
2908-
} else if ty::type_is_native(tcx, t) ||
2909-
ty::type_is_unsafe_ptr(tcx, t) {
2902+
} else if ty::type_is_unsafe_ptr(tcx, t) {
29102903
pointer
29112904
} else if ty::type_is_integral(tcx, t) {
29122905
integral
@@ -4905,7 +4898,6 @@ fn trans_native_mod(lcx: @local_ctxt, native_mod: ast::native_mod,
49054898

49064899
for native_item in native_mod.items {
49074900
alt native_item.node {
4908-
ast::native_item_ty {}
49094901
ast::native_item_fn(fn_decl, tps) {
49104902
let id = native_item.id;
49114903
let tys = c_stack_tys(ccx, id);
@@ -5144,10 +5136,6 @@ fn native_fn_ty_param_count(cx: @crate_ctxt, id: ast::node_id) -> uint {
51445136
_ { cx.sess.bug("native_fn_ty_param_count\
51455137
given a non-native item"); } };
51465138
alt native_item.node {
5147-
ast::native_item_ty {
5148-
cx.sess.bug("register_native_fn(): native fn isn't \
5149-
actually a fn");
5150-
}
51515139
ast::native_item_fn(_, tps) {
51525140
count = vec::len::<ast::ty_param>(tps);
51535141
}

src/comp/middle/ty.rs

+9-39
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ export mk_vec;
6868
export mk_mach_int;
6969
export mk_mach_uint;
7070
export mk_mach_float;
71-
export mk_native;
7271
export mk_nil;
7372
export mk_iface;
7473
export mk_res;
@@ -116,7 +115,6 @@ export ty_fn_ret_style;
116115
export ty_int;
117116
export ty_str;
118117
export ty_vec;
119-
export ty_native;
120118
export ty_nil;
121119
export ty_iface;
122120
export ty_res;
@@ -153,7 +151,6 @@ export type_is_fp;
153151
export type_allows_implicit_copy;
154152
export type_is_integral;
155153
export type_is_numeric;
156-
export type_is_native;
157154
export type_is_nil;
158155
export type_is_pod;
159156
export type_is_scalar;
@@ -270,7 +267,6 @@ enum sty {
270267

271268
ty_type, // type_desc*
272269
ty_send_type, // type_desc* that has been cloned into exchange heap
273-
ty_native(def_id),
274270
ty_constr(t, [@type_constr]),
275271
ty_opaque_closure_ptr(closure_kind), // ptr to env for fn, fn@, fn~
276272
ty_named(t, @str),
@@ -458,10 +454,7 @@ fn mk_raw_ty(cx: ctxt, st: sty) -> @raw_t {
458454
}
459455
alt st {
460456
ty_nil | ty_bot | ty_bool | ty_int(_) | ty_float(_) | ty_uint(_) |
461-
ty_str | ty_type | ty_send_type | ty_native(_) |
462-
ty_opaque_closure_ptr(_) {
463-
/* no-op */
464-
}
457+
ty_str | ty_type | ty_send_type | ty_opaque_closure_ptr(_) {}
465458
ty_param(_, _) { has_params = true; }
466459
ty_var(_) { has_vars = true; }
467460
ty_enum(_, tys) | ty_iface(_, tys) {
@@ -607,8 +600,6 @@ fn mk_type(_cx: ctxt) -> t { ret idx_type; }
607600

608601
fn mk_send_type(_cx: ctxt) -> t { ret idx_send_type; }
609602

610-
fn mk_native(cx: ctxt, did: def_id) -> t { ret gen_ty(cx, ty_native(did)); }
611-
612603
fn mk_opaque_closure_ptr(cx: ctxt, ck: closure_kind) -> t {
613604
ret gen_ty(cx, ty_opaque_closure_ptr(ck));
614605
}
@@ -658,7 +649,7 @@ pure fn ty_name(cx: ctxt, typ: t) -> option<@str> {
658649
fn walk_ty(cx: ctxt, ty: t, f: fn(t)) {
659650
alt struct(cx, ty) {
660651
ty_nil | ty_bot | ty_bool | ty_int(_) | ty_uint(_) | ty_float(_) |
661-
ty_str | ty_send_type | ty_type | ty_native(_) |
652+
ty_str | ty_send_type | ty_type |
662653
ty_opaque_closure_ptr(_) | ty_var(_) | ty_param(_, _) {}
663654
ty_box(tm) | ty_vec(tm) | ty_ptr(tm) { walk_ty(cx, tm.ty, f); }
664655
ty_enum(_, subtys) | ty_iface(_, subtys) {
@@ -702,10 +693,7 @@ fn fold_ty(cx: ctxt, fld: fold_mode, ty_0: t) -> t {
702693
}
703694
alt interner::get(*cx.ts, ty).struct {
704695
ty_nil | ty_bot | ty_bool | ty_int(_) | ty_uint(_) | ty_float(_) |
705-
ty_str | ty_type | ty_send_type | ty_native(_) |
706-
ty_opaque_closure_ptr(_) {
707-
/* no-op */
708-
}
696+
ty_str | ty_type | ty_send_type | ty_opaque_closure_ptr(_) {}
709697
ty_box(tm) {
710698
ty = mk_box(cx, {ty: fold_ty(cx, fld, tm.ty), mut: tm.mut});
711699
}
@@ -889,15 +877,15 @@ pure fn type_is_unique(cx: ctxt, ty: t) -> bool {
889877
pure fn type_is_scalar(cx: ctxt, ty: t) -> bool {
890878
alt struct(cx, ty) {
891879
ty_nil | ty_bool | ty_int(_) | ty_float(_) | ty_uint(_) |
892-
ty_send_type | ty_type | ty_native(_) | ty_ptr(_) { true }
880+
ty_send_type | ty_type | ty_ptr(_) { true }
893881
_ { false }
894882
}
895883
}
896884

897885
// FIXME maybe inline this for speed?
898886
fn type_is_immediate(cx: ctxt, ty: t) -> bool {
899887
ret type_is_scalar(cx, ty) || type_is_boxed(cx, ty) ||
900-
type_is_unique(cx, ty) || type_is_native(cx, ty);
888+
type_is_unique(cx, ty);
901889
}
902890

903891
fn type_needs_drop(cx: ctxt, ty: t) -> bool {
@@ -910,7 +898,7 @@ fn type_needs_drop(cx: ctxt, ty: t) -> bool {
910898
let result = alt struct(cx, ty) {
911899
// scalar types
912900
ty_nil | ty_bot | ty_bool | ty_int(_) | ty_float(_) | ty_uint(_) |
913-
ty_type | ty_native(_) | ty_ptr(_) { false }
901+
ty_type | ty_ptr(_) { false }
914902
ty_rec(flds) {
915903
for f in flds { if type_needs_drop(cx, f.mt.ty) { accum = true; } }
916904
accum
@@ -993,8 +981,7 @@ fn type_kind(cx: ctxt, ty: t) -> kind {
993981
let result = alt struct(cx, ty) {
994982
// Scalar and unique types are sendable
995983
ty_nil | ty_bot | ty_bool | ty_int(_) | ty_uint(_) | ty_float(_) |
996-
ty_native(_) | ty_ptr(_) |
997-
ty_send_type | ty_str { kind_sendable }
984+
ty_ptr(_) | ty_send_type | ty_str { kind_sendable }
998985
ty_type { kind_copyable }
999986
ty_fn(f) { proto_kind(f.proto) }
1000987
ty_opaque_closure_ptr(ck_block) { kind_noncopyable }
@@ -1043,12 +1030,6 @@ fn type_kind(cx: ctxt, ty: t) -> kind {
10431030
ret result;
10441031
}
10451032

1046-
// FIXME: should we just return true for native types in
1047-
// type_is_scalar?
1048-
fn type_is_native(cx: ctxt, ty: t) -> bool {
1049-
alt struct(cx, ty) { ty_native(_) { ret true; } _ { ret false; } }
1050-
}
1051-
10521033
fn type_structurally_contains(cx: ctxt, ty: t, test: fn(sty) -> bool) ->
10531034
bool {
10541035
let sty = struct(cx, ty);
@@ -1168,7 +1149,7 @@ fn type_is_pod(cx: ctxt, ty: t) -> bool {
11681149
alt struct(cx, ty) {
11691150
// Scalar types
11701151
ty_nil | ty_bot | ty_bool | ty_int(_) | ty_float(_) | ty_uint(_) |
1171-
ty_send_type | ty_type | ty_native(_) | ty_ptr(_) { result = true; }
1152+
ty_send_type | ty_type | ty_ptr(_) { result = true; }
11721153
// Boxed types
11731154
ty_str | ty_box(_) | ty_uniq(_) | ty_vec(_) | ty_fn(_) |
11741155
ty_iface(_, _) { result = false; }
@@ -1359,7 +1340,6 @@ fn hash_type_structure(st: sty) -> uint {
13591340
ty_var(v) { ret hash_uint(30u, v as uint); }
13601341
ty_param(pid, _) { ret hash_uint(31u, pid); }
13611342
ty_type { ret 32u; }
1362-
ty_native(did) { ret hash_def(33u, did); }
13631343
ty_bot { ret 34u; }
13641344
ty_ptr(mt) { ret hash_subty(35u, mt.ty); }
13651345
ty_res(did, sub, tps) {
@@ -2082,16 +2062,6 @@ mod unify {
20822062
ty::ty_str | ty::ty_send_type {
20832063
ret struct_cmp(cx, expected, actual);
20842064
}
2085-
ty::ty_native(ex_id) {
2086-
alt struct(cx.tcx, actual) {
2087-
ty_native(act_id) {
2088-
if ex_id.crate == act_id.crate && ex_id.node == act_id.node {
2089-
ret ures_ok(actual);
2090-
} else { ret ures_err(terr_mismatch); }
2091-
}
2092-
_ { ret ures_err(terr_mismatch); }
2093-
}
2094-
}
20952065
ty::ty_param(expected_n, _) {
20962066
alt struct(cx.tcx, actual) {
20972067
ty::ty_param(actual_n, _) if expected_n == actual_n {
@@ -2515,7 +2485,7 @@ fn def_has_ty_params(def: ast::def) -> bool {
25152485
ast::def_mod(_) | ast::def_const(_) |
25162486
ast::def_arg(_, _) | ast::def_local(_, _) | ast::def_upvar(_, _, _) |
25172487
ast::def_ty_param(_, _) | ast::def_binding(_) | ast::def_use(_) |
2518-
ast::def_native_ty(_) | ast::def_self(_) | ast::def_ty(_) { false }
2488+
ast::def_self(_) | ast::def_ty(_) { false }
25192489
ast::def_fn(_, _) | ast::def_variant(_, _) { true }
25202490
_ { false } // ????
25212491
}

src/comp/middle/typeck.rs

-15
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,6 @@ fn ast_ty_to_ty(tcx: ty::ctxt, mode: mode, &&ast_ty: @ast::ty) -> ty::t {
338338
some(ast::def_ty(id)) {
339339
typ = instantiate(tcx, ast_ty.span, mode, id, path.node.types);
340340
}
341-
some(ast::def_native_ty(id)) { typ = getter(tcx, mode, id).ty; }
342341
some(ast::def_ty_param(id, n)) {
343342
typ = ty::mk_param(tcx, n, id);
344343
}
@@ -438,17 +437,6 @@ fn ty_of_native_item(tcx: ty::ctxt, mode: mode, it: @ast::native_item)
438437
ret ty_of_native_fn_decl(tcx, mode, fn_decl, params,
439438
local_def(it.id));
440439
}
441-
ast::native_item_ty {
442-
alt tcx.tcache.find(local_def(it.id)) {
443-
some(tpt) { ret tpt; }
444-
none { }
445-
}
446-
let t = ty::mk_native(tcx, local_def(it.id));
447-
let t = ty::mk_named(tcx, t, @it.ident);
448-
let tpt = {bounds: @[], ty: t};
449-
tcx.tcache.insert(local_def(it.id), tpt);
450-
ret tpt;
451-
}
452440
}
453441
}
454442
fn ty_of_arg(tcx: ty::ctxt, mode: mode, a: ast::arg) -> ty::arg {
@@ -762,9 +750,6 @@ mod collect {
762750
// table.
763751
let tpt = ty_of_native_item(cx.tcx, m_collect, i);
764752
alt i.node {
765-
ast::native_item_ty {
766-
// FIXME: Native types have no annotation. Should they? --pcw
767-
}
768753
ast::native_item_fn(_, _) {
769754
write_ty(cx.tcx, i.id, tpt.ty);
770755
}

src/comp/syntax/ast.rs

-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ enum def {
4545
def_ty_param(def_id, uint),
4646
def_binding(def_id),
4747
def_use(def_id),
48-
def_native_ty(def_id),
4948
def_upvar(def_id, @def, node_id), // node_id == expr_fn or expr_fn_block
5049
}
5150

@@ -477,7 +476,6 @@ type native_item =
477476
span: span};
478477

479478
enum native_item_ {
480-
native_item_ty,
481479
native_item_fn(fn_decl, [ty_param]),
482480
}
483481

src/comp/syntax/ast_util.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ fn def_id_of_def(d: def) -> def_id {
3030
def_fn(id, _) | def_self(id) | def_mod(id) |
3131
def_native_mod(id) | def_const(id) | def_arg(id, _) | def_local(id, _) |
3232
def_variant(_, id) | def_ty(id) | def_ty_param(id, _) |
33-
def_binding(id) | def_use(id) | def_native_ty(id) |
34-
def_upvar(id, _, _) { id }
33+
def_binding(id) | def_use(id) | def_upvar(id, _, _) { id }
3534
}
3635
}
3736

src/comp/syntax/fold.rs

-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,6 @@ fn noop_fold_native_item(&&ni: @native_item, fld: ast_fold) -> @native_item {
189189
attrs: vec::map(ni.attrs, fold_attribute),
190190
node:
191191
alt ni.node {
192-
native_item_ty { native_item_ty }
193192
native_item_fn(fdec, typms) {
194193
native_item_fn({inputs: vec::map(fdec.inputs, fold_arg),
195194
output: fld.fold_ty(fdec.output),

0 commit comments

Comments
 (0)