Skip to content

Commit 075a094

Browse files
committed
Now with more type inference.
1 parent 451e438 commit 075a094

File tree

1 file changed

+42
-43
lines changed

1 file changed

+42
-43
lines changed

src/comp/middle/ty.rs

+42-43
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import std::int;
32
import std::ivec;
43
import std::str;
@@ -360,27 +359,27 @@ type node_type_table =
360359
@smallintmap::smallintmap[ty::ty_param_substs_opt_and_ty];
361360

362361
fn populate_type_store(&ctxt cx) {
363-
intern(cx, ty_nil, none[str]);
364-
intern(cx, ty_bool, none[str]);
365-
intern(cx, ty_int, none[str]);
366-
intern(cx, ty_float, none[str]);
367-
intern(cx, ty_uint, none[str]);
368-
intern(cx, ty_machine(ast::ty_i8), none[str]);
369-
intern(cx, ty_machine(ast::ty_i16), none[str]);
370-
intern(cx, ty_machine(ast::ty_i32), none[str]);
371-
intern(cx, ty_machine(ast::ty_i64), none[str]);
372-
intern(cx, ty_machine(ast::ty_u8), none[str]);
373-
intern(cx, ty_machine(ast::ty_u16), none[str]);
374-
intern(cx, ty_machine(ast::ty_u32), none[str]);
375-
intern(cx, ty_machine(ast::ty_u64), none[str]);
376-
intern(cx, ty_machine(ast::ty_f32), none[str]);
377-
intern(cx, ty_machine(ast::ty_f64), none[str]);
378-
intern(cx, ty_char, none[str]);
379-
intern(cx, ty_str, none[str]);
380-
intern(cx, ty_istr, none[str]);
381-
intern(cx, ty_task, none[str]);
382-
intern(cx, ty_type, none[str]);
383-
intern(cx, ty_bot, none[str]);
362+
intern(cx, ty_nil, none);
363+
intern(cx, ty_bool, none);
364+
intern(cx, ty_int, none);
365+
intern(cx, ty_float, none);
366+
intern(cx, ty_uint, none);
367+
intern(cx, ty_machine(ast::ty_i8), none);
368+
intern(cx, ty_machine(ast::ty_i16), none);
369+
intern(cx, ty_machine(ast::ty_i32), none);
370+
intern(cx, ty_machine(ast::ty_i64), none);
371+
intern(cx, ty_machine(ast::ty_u8), none);
372+
intern(cx, ty_machine(ast::ty_u16), none);
373+
intern(cx, ty_machine(ast::ty_u32), none);
374+
intern(cx, ty_machine(ast::ty_u64), none);
375+
intern(cx, ty_machine(ast::ty_f32), none);
376+
intern(cx, ty_machine(ast::ty_f64), none);
377+
intern(cx, ty_char, none);
378+
intern(cx, ty_str, none);
379+
intern(cx, ty_istr, none);
380+
intern(cx, ty_task, none);
381+
intern(cx, ty_type, none);
382+
intern(cx, ty_bot, none);
384383
assert (ivec::len(cx.ts.vect) == idx_first_others);
385384
}
386385

@@ -530,7 +529,7 @@ fn gen_ty_full(&ctxt cx, &sty st, &option::t[str] cname) -> t {
530529

531530
// These are private constructors to this module. External users should always
532531
// use the mk_foo() functions below.
533-
fn gen_ty(&ctxt cx, &sty st) -> t { ret gen_ty_full(cx, st, none[str]); }
532+
fn gen_ty(&ctxt cx, &sty st) -> t { ret gen_ty_full(cx, st, none); }
534533

535534
fn mk_nil(&ctxt cx) -> t { ret idx_nil; }
536535

@@ -859,7 +858,7 @@ fn fold_ty(&ctxt cx, fold_mode fld, t ty_0) -> t {
859858
// Type utilities
860859

861860
fn rename(&ctxt cx, t typ, str new_cname) -> t {
862-
ret gen_ty_full(cx, struct(cx, typ), some[str](new_cname));
861+
ret gen_ty_full(cx, struct(cx, typ), some(new_cname));
863862
}
864863

865864
fn strip_cname(&ctxt cx, t typ) -> t {
@@ -1270,10 +1269,10 @@ fn type_owns_heap_mem(&ctxt cx, &t ty) -> bool {
12701269

12711270
fn type_param(&ctxt cx, &t ty) -> option::t[uint] {
12721271
alt (struct(cx, ty)) {
1273-
case (ty_param(?id)) { ret some[uint](id); }
1272+
case (ty_param(?id)) { ret some(id); }
12741273
case (_) {/* fall through */ }
12751274
}
1276-
ret none[uint];
1275+
ret none;
12771276
}
12781277

12791278
fn type_autoderef(&ctxt cx, &ty::t t) -> ty::t {
@@ -1737,7 +1736,7 @@ fn eq_raw_ty(&@raw_t a, &@raw_t b) -> bool {
17371736
alt (a.cname) {
17381737
case (none) {
17391738
alt (b.cname) {
1740-
case (none[str]) {/* ok */ }
1739+
case (none) { /* ok */ }
17411740
case (_) { ret false; }
17421741
}
17431742
}
@@ -2177,10 +2176,10 @@ mod unify {
21772176
// Unifies two mutability flags.
21782177
fn unify_mut(ast::mutability expected, ast::mutability actual) ->
21792178
option::t[ast::mutability] {
2180-
if (expected == actual) { ret some[ast::mutability](expected); }
2181-
if (expected == ast::maybe_mut) { ret some[ast::mutability](actual); }
2182-
if (actual == ast::maybe_mut) { ret some[ast::mutability](expected); }
2183-
ret none[ast::mutability];
2179+
if (expected == actual) { ret some(expected); }
2180+
if (expected == ast::maybe_mut) { ret some(actual); }
2181+
if (actual == ast::maybe_mut) { ret some(expected); }
2182+
ret none;
21842183
}
21852184
tag fn_common_res {
21862185
fn_common_res_err(result);
@@ -2332,8 +2331,8 @@ mod unify {
23322331
}
23332332
auto root_id = ufindivec::find(vb.sets, vid as uint);
23342333
alt (smallintmap::find[t](vb.types, root_id)) {
2335-
case (none[t]) { ret fix_err(vid); }
2336-
case (some[t](?rt)) { ret fix_ok(rt); }
2334+
case (none) { ret fix_err(vid); }
2335+
case (some(?rt)) { ret fix_ok(rt); }
23372336
}
23382337
}
23392338
case (_) { ret fix_ok(typ); }
@@ -2778,8 +2777,8 @@ mod unify {
27782777
}
27792778
auto typespec;
27802779
alt (smallintmap::find[t](vb.types, i)) {
2781-
case (none[t]) { typespec = ""; }
2782-
case (some[t](?typ)) {
2780+
case (none) { typespec = ""; }
2781+
case (some(?typ)) {
27832782
typespec = " =" + ty_to_str(tcx, typ);
27842783
}
27852784
}
@@ -2793,16 +2792,16 @@ mod unify {
27932792
fn subst_vars(ty_ctxt tcx, @var_bindings vb,
27942793
@mutable option::t[int] unresolved, int vid) -> t {
27952794
if (vid as uint >= ufindivec::set_count(vb.sets)) {
2796-
*unresolved = some[int](vid);
2795+
*unresolved = some(vid);
27972796
ret ty::mk_var(tcx, vid);
27982797
}
27992798
auto root_id = ufindivec::find(vb.sets, vid as uint);
28002799
alt (smallintmap::find[t](vb.types, root_id)) {
2801-
case (none[t]) {
2802-
*unresolved = some[int](vid);
2800+
case (none) {
2801+
*unresolved = some(vid);
28032802
ret ty::mk_var(tcx, vid);
28042803
}
2805-
case (some[t](?rt)) {
2804+
case (some(?rt)) {
28062805
ret fold_ty(tcx,
28072806
fm_var(bind subst_vars(tcx, vb, unresolved,
28082807
_)), rt);
@@ -2815,8 +2814,8 @@ mod unify {
28152814
typ);
28162815
auto ur = *unresolved;
28172816
alt (ur) {
2818-
case (none[int]) { ret fix_ok(rty); }
2819-
case (some[int](?var_id)) { ret fix_err(var_id); }
2817+
case (none) { ret fix_ok(rty); }
2818+
case (some(?var_id)) { ret fix_err(var_id); }
28202819
}
28212820
}
28222821
fn resolve_type_var(&ty_ctxt tcx, &@var_bindings vb, int vid) ->
@@ -2826,8 +2825,8 @@ mod unify {
28262825
}
28272826
auto root_id = ufindivec::find(vb.sets, vid as uint);
28282827
alt (smallintmap::find[t](vb.types, root_id)) {
2829-
case (none[t]) { ret fix_err(vid); }
2830-
case (some[t](?rt)) { ret fixup_vars(tcx, vb, rt); }
2828+
case (none) { ret fix_err(vid); }
2829+
case (some(?rt)) { ret fixup_vars(tcx, vb, rt); }
28312830
}
28322831
}
28332832
}

0 commit comments

Comments
 (0)