about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2011-04-25 12:15:55 -0700
committerPatrick Walton <pcwalton@mimiga.net>2011-04-25 12:15:55 -0700
commite102413aadf4cb0e2740b26d249a710ad98cbd14 (patch)
tree6c47e65fddf38f01b3a1b32259ca70d595c2bef5 /src
parentb258060a94e629d3281697cedfa6620f5e75b0c3 (diff)
downloadrust-e102413aadf4cb0e2740b26d249a710ad98cbd14.tar.gz
rust-e102413aadf4cb0e2740b26d249a710ad98cbd14.zip
rustc: Pass a "type context" around instead of directly passing the type store; prep for removing type annotations
Diffstat (limited to 'src')
-rw-r--r--src/comp/driver/rustc.rs6
-rw-r--r--src/comp/front/creader.rs88
-rw-r--r--src/comp/middle/metadata.rs10
-rw-r--r--src/comp/middle/trans.rs456
-rw-r--r--src/comp/middle/ty.rs550
-rw-r--r--src/comp/middle/typeck.rs505
-rw-r--r--src/comp/util/common.rs4
7 files changed, 786 insertions, 833 deletions
diff --git a/src/comp/driver/rustc.rs b/src/comp/driver/rustc.rs
index afef226e27f..eabf03102e2 100644
--- a/src/comp/driver/rustc.rs
+++ b/src/comp/driver/rustc.rs
@@ -73,13 +73,13 @@ fn compile_input(session.session sess,
     crate = resolve.resolve_crate(sess, crate);
     capture.check_for_captures(sess, crate);
 
-    auto tystore = ty.mk_type_store();
-    auto typeck_result = typeck.check_crate(sess, tystore, crate);
+    auto ty_cx = ty.mk_ctxt();
+    auto typeck_result = typeck.check_crate(sess, ty_cx, crate);
     crate = typeck_result._0;
     auto type_cache = typeck_result._1;
     // FIXME: uncomment once typestate_check works
     // crate = typestate_check.check_crate(crate);
-    trans.trans_crate(sess, crate, tystore, type_cache, output, shared,
+    trans.trans_crate(sess, crate, ty_cx, type_cache, output, shared,
                       optimize, verify, ot);
 }
 
diff --git a/src/comp/front/creader.rs b/src/comp/front/creader.rs
index 99dbf6ad2f8..3ecf3058ab8 100644
--- a/src/comp/front/creader.rs
+++ b/src/comp/front/creader.rs
@@ -49,8 +49,7 @@ tag resolve_result {
 // Callback to translate defs to strs or back.
 type str_def = fn(str) -> ast.def_id;
 
-type pstate = rec(str rep, mutable uint pos, uint len,
-                  @ty.type_store tystore);
+type pstate = rec(str rep, mutable uint pos, uint len, ty.ctxt tcx);
 
 fn peek(@pstate st) -> u8 {
     if (st.pos < st.len) {ret st.rep.(st.pos) as u8;}
@@ -63,9 +62,9 @@ fn next(@pstate st) -> u8 {
     ret ch as u8;
 }
 
-fn parse_ty_str(str rep, str_def sd, @ty.type_store tystore) -> ty.t {
+fn parse_ty_str(str rep, str_def sd, ty.ctxt tcx) -> ty.t {
     auto len = _str.byte_len(rep);
-    auto st = @rec(rep=rep, mutable pos=0u, len=len, tystore=tystore);
+    auto st = @rec(rep=rep, mutable pos=0u, len=len, tcx=tcx);
     auto result = parse_ty(st, sd);
     if (st.pos != len) {
         log_err "parse_ty_str: incomplete parse, stopped at byte "
@@ -77,27 +76,27 @@ fn parse_ty_str(str rep, str_def sd, @ty.type_store tystore) -> ty.t {
 
 fn parse_ty(@pstate st, str_def sd) -> ty.t {
     alt (next(st) as char) {
-        case ('n') { ret ty.mk_nil(st.tystore); }
-        case ('b') { ret ty.mk_bool(st.tystore); }
-        case ('i') { ret ty.mk_int(st.tystore); }
-        case ('u') { ret ty.mk_uint(st.tystore); }
-        case ('l') { ret ty.mk_float(st.tystore); }
+        case ('n') { ret ty.mk_nil(st.tcx); }
+        case ('b') { ret ty.mk_bool(st.tcx); }
+        case ('i') { ret ty.mk_int(st.tcx); }
+        case ('u') { ret ty.mk_uint(st.tcx); }
+        case ('l') { ret ty.mk_float(st.tcx); }
         case ('M') {
             alt (next(st) as char) {
-                case ('b') { ret ty.mk_mach(st.tystore, common.ty_u8); }
-                case ('w') { ret ty.mk_mach(st.tystore, common.ty_u16); }
-                case ('l') { ret ty.mk_mach(st.tystore, common.ty_u32); }
-                case ('d') { ret ty.mk_mach(st.tystore, common.ty_u64); }
-                case ('B') { ret ty.mk_mach(st.tystore, common.ty_i8); }
-                case ('W') { ret ty.mk_mach(st.tystore, common.ty_i16); }
-                case ('L') { ret ty.mk_mach(st.tystore, common.ty_i32); }
-                case ('D') { ret ty.mk_mach(st.tystore, common.ty_i64); }
-                case ('f') { ret ty.mk_mach(st.tystore, common.ty_f32); }
-                case ('F') { ret ty.mk_mach(st.tystore, common.ty_f64); }
+                case ('b') { ret ty.mk_mach(st.tcx, common.ty_u8); }
+                case ('w') { ret ty.mk_mach(st.tcx, common.ty_u16); }
+                case ('l') { ret ty.mk_mach(st.tcx, common.ty_u32); }
+                case ('d') { ret ty.mk_mach(st.tcx, common.ty_u64); }
+                case ('B') { ret ty.mk_mach(st.tcx, common.ty_i8); }
+                case ('W') { ret ty.mk_mach(st.tcx, common.ty_i16); }
+                case ('L') { ret ty.mk_mach(st.tcx, common.ty_i32); }
+                case ('D') { ret ty.mk_mach(st.tcx, common.ty_i64); }
+                case ('f') { ret ty.mk_mach(st.tcx, common.ty_f32); }
+                case ('F') { ret ty.mk_mach(st.tcx, common.ty_f64); }
             }
         }
-        case ('c') { ret ty.mk_char(st.tystore); }
-        case ('s') { ret ty.mk_str(st.tystore); }
+        case ('c') { ret ty.mk_char(st.tcx); }
+        case ('s') { ret ty.mk_str(st.tcx); }
         case ('t') {
             check(next(st) as char == '[');
             auto def = parse_def(st, sd);
@@ -106,13 +105,13 @@ fn parse_ty(@pstate st, str_def sd) -> ty.t {
                 params += vec(parse_ty(st, sd));
             }
             st.pos = st.pos + 1u;
-            ret ty.mk_tag(st.tystore, def, params);
+            ret ty.mk_tag(st.tcx, def, params);
         }
-        case ('p') { ret ty.mk_param(st.tystore, parse_int(st) as uint); }
-        case ('@') { ret ty.mk_box(st.tystore, parse_mt(st, sd)); }
-        case ('V') { ret ty.mk_vec(st.tystore, parse_mt(st, sd)); }
-        case ('P') { ret ty.mk_port(st.tystore, parse_ty(st, sd)); }
-        case ('C') { ret ty.mk_chan(st.tystore, parse_ty(st, sd)); }
+        case ('p') { ret ty.mk_param(st.tcx, parse_int(st) as uint); }
+        case ('@') { ret ty.mk_box(st.tcx, parse_mt(st, sd)); }
+        case ('V') { ret ty.mk_vec(st.tcx, parse_mt(st, sd)); }
+        case ('P') { ret ty.mk_port(st.tcx, parse_ty(st, sd)); }
+        case ('C') { ret ty.mk_chan(st.tcx, parse_ty(st, sd)); }
         case ('T') {
             check(next(st) as char == '[');
             let vec[ty.mt] params = vec();
@@ -120,7 +119,7 @@ fn parse_ty(@pstate st, str_def sd) -> ty.t {
                 params += vec(parse_mt(st, sd));
             }
             st.pos = st.pos + 1u;
-            ret ty.mk_tup(st.tystore, params);
+            ret ty.mk_tup(st.tcx, params);
         }
         case ('R') {
             check(next(st) as char == '[');
@@ -134,15 +133,15 @@ fn parse_ty(@pstate st, str_def sd) -> ty.t {
                 fields += vec(rec(ident=name, mt=parse_mt(st, sd)));
             }
             st.pos = st.pos + 1u;
-            ret ty.mk_rec(st.tystore, fields);
+            ret ty.mk_rec(st.tcx, fields);
         }
         case ('F') {
             auto func = parse_ty_fn(st, sd);
-            ret ty.mk_fn(st.tystore, ast.proto_fn, func._0, func._1);
+            ret ty.mk_fn(st.tcx, ast.proto_fn, func._0, func._1);
         }
         case ('W') {
             auto func = parse_ty_fn(st, sd);
-            ret ty.mk_fn(st.tystore, ast.proto_iter, func._0, func._1);
+            ret ty.mk_fn(st.tcx, ast.proto_iter, func._0, func._1);
         }
         case ('N') {
             auto abi;
@@ -152,7 +151,7 @@ fn parse_ty(@pstate st, str_def sd) -> ty.t {
                 case ('l') {abi = ast.native_abi_llvm;}
             }
             auto func = parse_ty_fn(st, sd);
-            ret ty.mk_native_fn(st.tystore,abi,func._0,func._1);
+            ret ty.mk_native_fn(st.tcx,abi,func._0,func._1);
         }
         case ('O') {
             check(next(st) as char == '[');
@@ -174,11 +173,11 @@ fn parse_ty(@pstate st, str_def sd) -> ty.t {
                                    output=func._1));
             }
             st.pos += 1u;
-            ret ty.mk_obj(st.tystore, methods);
+            ret ty.mk_obj(st.tcx, methods);
         }
-        case ('X') { ret ty.mk_var(st.tystore, parse_int(st)); }
-        case ('E') { ret ty.mk_native(st.tystore); }
-        case ('Y') { ret ty.mk_type(st.tystore); }
+        case ('X') { ret ty.mk_var(st.tcx, parse_int(st)); }
+        case ('E') { ret ty.mk_native(st.tcx); }
+        case ('Y') { ret ty.mk_type(st.tcx); }
     }
 }
 
@@ -331,7 +330,7 @@ fn variant_tag_id(&ebml.doc d) -> ast.def_id {
     ret parse_def_id(ebml.doc_data(tagdoc));
 }
 
-fn item_type(&ebml.doc item, int this_cnum, @ty.type_store tystore) -> ty.t {
+fn item_type(&ebml.doc item, int this_cnum, ty.ctxt tcx) -> ty.t {
     fn parse_external_def_id(int this_cnum, str s) -> ast.def_id {
         // FIXME: This is completely wrong when linking against a crate
         // that, in turn, links against another crate. We need a mapping
@@ -344,7 +343,7 @@ fn item_type(&ebml.doc item, int this_cnum, @ty.type_store tystore) -> ty.t {
 
     auto tp = ebml.get_doc(item, metadata.tag_items_data_item_type);
     auto s = _str.unsafe_from_bytes(ebml.doc_data(tp));
-    ret parse_ty_str(s, bind parse_external_def_id(this_cnum, _), tystore);
+    ret parse_ty_str(s, bind parse_external_def_id(this_cnum, _), tcx);
 }
 
 fn item_ty_param_count(&ebml.doc item, int this_cnum) -> uint {
@@ -506,12 +505,12 @@ fn lookup_def(session.session sess, int cnum, vec[ast.ident] path)
     ret some[ast.def](def);
 }
 
-fn get_type(session.session sess, @ty.type_store tystore, ast.def_id def)
+fn get_type(session.session sess, ty.ctxt tcx, ast.def_id def)
         -> ty.ty_param_count_and_ty {
     auto external_crate_id = def._0;
     auto data = sess.get_external_crate(external_crate_id).data;
     auto item = lookup_item(def._1, data);
-    auto t = item_type(item, external_crate_id, tystore);
+    auto t = item_type(item, external_crate_id, tcx);
 
     auto tp_count;
     auto kind_ch = item_kind(item);
@@ -532,9 +531,8 @@ fn get_symbol(session.session sess, ast.def_id def) -> str {
     ret item_symbol(item);
 }
 
-fn get_tag_variants(session.session sess,
-                    @ty.type_store tystore,
-                    ast.def_id def) -> vec[trans.variant_info] {
+fn get_tag_variants(session.session sess, ty.ctxt tcx, ast.def_id def)
+        -> vec[trans.variant_info] {
     auto external_crate_id = def._0;
     auto data = sess.get_external_crate(external_crate_id).data;
     auto items = ebml.get_doc(ebml.new_doc(data), metadata.tag_items);
@@ -544,9 +542,9 @@ fn get_tag_variants(session.session sess,
     auto variant_ids = tag_variant_ids(item, external_crate_id);
     for (ast.def_id did in variant_ids) {
         auto item = find_item(did._1, items);
-        auto ctor_ty = item_type(item, external_crate_id, tystore);
+        auto ctor_ty = item_type(item, external_crate_id, tcx);
         let vec[ty.t] arg_tys = vec();
-        alt (ty.struct(tystore, ctor_ty)) {
+        alt (ty.struct(tcx, ctor_ty)) {
             case (ty.ty_fn(_, ?args, _)) {
                 for (ty.arg a in args) {
                     arg_tys += vec(a.ty);
diff --git a/src/comp/middle/metadata.rs b/src/comp/middle/metadata.rs
index bc4bce12892..fee92395579 100644
--- a/src/comp/middle/metadata.rs
+++ b/src/comp/middle/metadata.rs
@@ -53,11 +53,11 @@ mod Encode {
 
     type ctxt = rec(
         fn(ast.def_id) -> str ds,   // Callback to translate defs to strs.
-        @ty.type_store tystore      // The type store.
+        ty.ctxt tcx                 // The type context.
     );
 
     fn ty_str(@ctxt cx, ty.t t) -> str {
-        ret sty_str(cx, ty.struct(cx.tystore, t));
+        ret sty_str(cx, ty.struct(cx.tcx, t));
     }
 
     fn mt_str(@ctxt cx, &ty.mt mt) -> str {
@@ -337,7 +337,7 @@ fn encode_type(@trans.crate_ctxt cx, &ebml.writer ebml_w, ty.t typ) {
     ebml.start_tag(ebml_w, tag_items_data_item_type);
 
     auto f = def_to_str;
-    auto ty_str_ctxt = @rec(ds=f, tystore=cx.tystore);
+    auto ty_str_ctxt = @rec(ds=f, tcx=cx.tcx);
     ebml_w.writer.write(_str.bytes(Encode.ty_str(ty_str_ctxt, typ)));
 
     ebml.end_tag(ebml_w);
@@ -457,7 +457,7 @@ fn encode_info_for_item(@trans.crate_ctxt cx, &ebml.writer ebml_w,
             encode_def_id(ebml_w, odid.ty);
             encode_kind(ebml_w, 'y' as u8);
             encode_type_param_count(ebml_w, tps);
-            encode_type(cx, ebml_w, ty.ty_fn_ret(cx.tystore, fn_ty));
+            encode_type(cx, ebml_w, ty.ty_fn_ret(cx.tcx, fn_ty));
             ebml.end_tag(ebml_w);
         }
     }
@@ -470,7 +470,7 @@ fn encode_info_for_native_item(@trans.crate_ctxt cx, &ebml.writer ebml_w,
         case (ast.native_item_ty(_, ?did)) {
             encode_def_id(ebml_w, did);
             encode_kind(ebml_w, 'T' as u8);
-            encode_type(cx, ebml_w, ty.mk_native(cx.tystore));
+            encode_type(cx, ebml_w, ty.mk_native(cx.tcx));
         }
         case (ast.native_item_fn(_, _, _, ?tps, ?did, ?ann)) {
             encode_def_id(ebml_w, did);
diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs
index b294ffebb95..4a1242abb22 100644
--- a/src/comp/middle/trans.rs
+++ b/src/comp/middle/trans.rs
@@ -113,7 +113,7 @@ state type crate_ctxt = rec(session.session sess,
                             @glue_fns glues,
                             namegen names,
                             std.sha1.sha1 sha,
-                            @ty.type_store tystore);
+                            ty.ctxt tcx);
 
 type local_ctxt = rec(vec[str] path,
                       vec[str] module_path,
@@ -185,7 +185,7 @@ fn mangle_name_by_type(@crate_ctxt ccx, vec[str] path, ty.t t) -> str {
     ccx.sha.reset();
 
     auto f = metadata.def_to_str;
-    auto cx = @rec(ds=f, tystore=ccx.tystore);
+    auto cx = @rec(ds=f, tcx=ccx.tcx);
     ccx.sha.input_str(metadata.Encode.ty_str(cx, t));
 
     ret sep() + "rust" + sep()
@@ -558,9 +558,9 @@ fn T_opaque_obj_ptr(type_names tn) -> TypeRef {
 //
 // TODO: Enforce via a predicate.
 fn type_of(@crate_ctxt cx, ty.t t) -> TypeRef {
-    if (ty.type_has_dynamic_size(cx.tystore, t)) {
+    if (ty.type_has_dynamic_size(cx.tcx, t)) {
         log_err "type_of() called on a type with dynamic size: " +
-            ty.ty_to_str(cx.tystore, t);
+            ty.ty_to_str(cx.tcx, t);
         fail;
     }
 
@@ -570,7 +570,7 @@ fn type_of(@crate_ctxt cx, ty.t t) -> TypeRef {
 fn type_of_explicit_args(@crate_ctxt cx, vec[ty.arg] inputs) -> vec[TypeRef] {
     let vec[TypeRef] atys = vec();
     for (ty.arg arg in inputs) {
-        if (ty.type_has_dynamic_size(cx.tystore, arg.ty)) {
+        if (ty.type_has_dynamic_size(cx.tcx, arg.ty)) {
             check (arg.mode == ast.alias);
             atys += vec(T_typaram_ptr(cx.tn));
         } else {
@@ -605,7 +605,7 @@ fn type_of_fn_full(@crate_ctxt cx,
     let vec[TypeRef] atys = vec();
 
     // Arg 0: Output pointer.
-    if (ty.type_has_dynamic_size(cx.tystore, output)) {
+    if (ty.type_has_dynamic_size(cx.tcx, output)) {
         atys += vec(T_typaram_ptr(cx.tn));
     } else {
         atys += vec(T_ptr(type_of_inner(cx, output)));
@@ -642,7 +642,7 @@ fn type_of_fn_full(@crate_ctxt cx,
             vec(T_fn_pair(cx.tn,
                           type_of_fn_full(cx, ast.proto_fn, none[TypeRef],
                                           vec(rec(mode=ast.alias, ty=output)),
-                                          ty.mk_nil(cx.tystore), 0u)));
+                                          ty.mk_nil(cx.tcx), 0u)));
     }
 
     // ... then explicit args.
@@ -686,7 +686,7 @@ fn type_of_inner(@crate_ctxt cx, ty.t t) -> TypeRef {
 
     let TypeRef llty = 0 as TypeRef;
 
-    alt (ty.struct(cx.tystore, t)) {
+    alt (ty.struct(cx.tcx, t)) {
         case (ty.ty_native) { llty = T_ptr(T_i8()); }
         case (ty.ty_nil) { llty = T_nil(); }
         case (ty.ty_bool) { llty = T_bool(); }
@@ -710,7 +710,7 @@ fn type_of_inner(@crate_ctxt cx, ty.t t) -> TypeRef {
         case (ty.ty_char) { llty = T_char(); }
         case (ty.ty_str) { llty = T_ptr(T_str()); }
         case (ty.ty_tag(_, _)) {
-            if (ty.type_has_dynamic_size(cx.tystore, t)) {
+            if (ty.type_has_dynamic_size(cx.tcx, t)) {
                 llty = T_opaque_tag(cx.tn);
             } else {
                 auto size = static_size_of_tag(cx, t);
@@ -786,14 +786,13 @@ fn type_of_inner(@crate_ctxt cx, ty.t t) -> TypeRef {
     }
 
     check (llty as int != 0);
-    llvm.LLVMAddTypeName(cx.llmod, _str.buf(ty.ty_to_str(cx.tystore, t)),
-                         llty);
+    llvm.LLVMAddTypeName(cx.llmod, _str.buf(ty.ty_to_str(cx.tcx, t)), llty);
     cx.lltypes.insert(t, llty);
     ret llty;
 }
 
 fn type_of_arg(@local_ctxt cx, &ty.arg arg) -> TypeRef {
-    alt (ty.struct(cx.ccx.tystore, arg.ty)) {
+    alt (ty.struct(cx.ccx.tcx, arg.ty)) {
         case (ty.ty_param(_)) {
             if (arg.mode == ast.alias) {
                 ret T_typaram_ptr(cx.ccx.tn);
@@ -815,7 +814,7 @@ fn type_of_arg(@local_ctxt cx, &ty.arg arg) -> TypeRef {
 
 fn type_of_ty_param_count_and_ty(@local_ctxt lcx,
                                  ty.ty_param_count_and_ty tpt) -> TypeRef {
-    alt (ty.struct(lcx.ccx.tystore, tpt._1)) {
+    alt (ty.struct(lcx.ccx.tcx, tpt._1)) {
         case (ty.ty_fn(?proto, ?inputs, ?output)) {
             auto llfnty = type_of_fn(lcx.ccx, proto, inputs, output, tpt._0);
             ret T_fn_pair(lcx.ccx.tn, llfnty);
@@ -1124,14 +1123,14 @@ fn llalign_of(TypeRef t) -> ValueRef {
 }
 
 fn size_of(@block_ctxt cx, ty.t t) -> result {
-    if (!ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tystore, t)) {
+    if (!ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, t)) {
         ret res(cx, llsize_of(type_of(cx.fcx.lcx.ccx, t)));
     }
     ret dynamic_size_of(cx, t);
 }
 
 fn align_of(@block_ctxt cx, ty.t t) -> result {
-    if (!ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tystore, t)) {
+    if (!ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, t)) {
         ret res(cx, llalign_of(type_of(cx.fcx.lcx.ccx, t)));
     }
     ret dynamic_align_of(cx, t);
@@ -1152,20 +1151,20 @@ fn array_alloca(@block_ctxt cx, TypeRef t, ValueRef n) -> ValueRef {
 // types.
 fn simplify_type(@crate_ctxt ccx, ty.t typ) -> ty.t {
     fn simplifier(@crate_ctxt ccx, ty.t typ) -> ty.t {
-        alt (ty.struct(ccx.tystore, typ)) {
+        alt (ty.struct(ccx.tcx, typ)) {
             case (ty.ty_box(_)) {
-                ret ty.mk_imm_box(ccx.tystore, ty.mk_nil(ccx.tystore));
+                ret ty.mk_imm_box(ccx.tcx, ty.mk_nil(ccx.tcx));
             }
             case (_) { ret typ; }
         }
     }
     auto f = bind simplifier(ccx, _);
-    ret ty.fold_ty(ccx.tystore, f, typ);
+    ret ty.fold_ty(ccx.tcx, f, typ);
 }
 
 // Computes the size of the data part of a non-dynamically-sized tag.
 fn static_size_of_tag(@crate_ctxt cx, ty.t t) -> uint {
-    if (ty.type_has_dynamic_size(cx.tystore, t)) {
+    if (ty.type_has_dynamic_size(cx.tcx, t)) {
         log_err "dynamically sized type passed to static_size_of_tag()";
         fail;
     }
@@ -1176,7 +1175,7 @@ fn static_size_of_tag(@crate_ctxt cx, ty.t t) -> uint {
 
     auto tid;
     let vec[ty.t] subtys;
-    alt (ty.struct(cx.tystore, t)) {
+    alt (ty.struct(cx.tcx, t)) {
         case (ty.ty_tag(?tid_, ?subtys_)) {
             tid = tid_;
             subtys = subtys_;
@@ -1191,12 +1190,11 @@ fn static_size_of_tag(@crate_ctxt cx, ty.t t) -> uint {
     auto max_size = 0u;
     auto variants = tag_variants(cx, tid);
     for (variant_info variant in variants) {
-        auto tup_ty = simplify_type(cx,
-                                    ty.mk_imm_tup(cx.tystore, variant.args));
+        auto tup_ty = simplify_type(cx, ty.mk_imm_tup(cx.tcx, variant.args));
 
         // Perform any type parameter substitutions.
-        tup_ty = ty.bind_params_in_type(cx.tystore, tup_ty);
-        tup_ty = ty.substitute_type_params(cx.tystore, subtys, tup_ty);
+        tup_ty = ty.bind_params_in_type(cx.tcx, tup_ty);
+        tup_ty = ty.substitute_type_params(cx.tcx, subtys, tup_ty);
 
         // Here we possibly do a recursive call.
         auto this_size = llsize_of_real(cx, type_of(cx, tup_ty));
@@ -1236,7 +1234,7 @@ fn dynamic_size_of(@block_ctxt cx, ty.t t) -> result {
         ret res(bcx, off);
     }
 
-    alt (ty.struct(cx.fcx.lcx.ccx.tystore, t)) {
+    alt (ty.struct(cx.fcx.lcx.ccx.tcx, t)) {
         case (ty.ty_param(?p)) {
             auto szptr = field_of_tydesc(cx, t, abi.tydesc_field_size);
             ret res(szptr.bcx, szptr.bcx.build.Load(szptr.val));
@@ -1268,10 +1266,9 @@ fn dynamic_size_of(@block_ctxt cx, ty.t t) -> result {
                 let vec[ty.t] raw_tys = variant.args;
                 let vec[ty.t] tys = vec();
                 for (ty.t raw_ty in raw_tys) {
-                    auto t = ty.bind_params_in_type(cx.fcx.lcx.ccx.tystore,
+                    auto t = ty.bind_params_in_type(cx.fcx.lcx.ccx.tcx,
                                                     raw_ty);
-                    t = ty.substitute_type_params(cx.fcx.lcx.ccx.tystore, tps,
-                                                  t);
+                    t = ty.substitute_type_params(cx.fcx.lcx.ccx.tcx, tps, t);
                     tys += vec(t);
                 }
 
@@ -1291,7 +1288,7 @@ fn dynamic_size_of(@block_ctxt cx, ty.t t) -> result {
 }
 
 fn dynamic_align_of(@block_ctxt cx, ty.t t) -> result {
-    alt (ty.struct(cx.fcx.lcx.ccx.tystore, t)) {
+    alt (ty.struct(cx.fcx.lcx.ccx.tcx, t)) {
         case (ty.ty_param(?p)) {
             auto aptr = field_of_tydesc(cx, t, abi.tydesc_field_align);
             ret res(aptr.bcx, aptr.bcx.build.Load(aptr.val));
@@ -1331,11 +1328,11 @@ fn dynamic_align_of(@block_ctxt cx, ty.t t) -> result {
 fn GEP_tup_like(@block_ctxt cx, ty.t t,
                 ValueRef base, vec[int] ixs) -> result {
 
-    check (ty.type_is_tup_like(cx.fcx.lcx.ccx.tystore, t));
+    check (ty.type_is_tup_like(cx.fcx.lcx.ccx.tcx, t));
 
     // It might be a static-known type. Handle this.
 
-    if (! ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tystore, t)) {
+    if (! ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, t)) {
         let vec[ValueRef] v = vec();
         for (int i in ixs) {
             v += vec(C_int(i));
@@ -1386,11 +1383,11 @@ fn GEP_tup_like(@block_ctxt cx, ty.t t,
         let int i = 0;
         while (i < ix) {
             _vec.push[ty.t](prefix,
-                            ty.get_element_type(ccx.tystore, t, i as uint));
+                            ty.get_element_type(ccx.tcx, t, i as uint));
             i += 1 ;
         }
 
-        auto selected = ty.get_element_type(ccx.tystore, t, i as uint);
+        auto selected = ty.get_element_type(ccx.tcx, t, i as uint);
 
         if (n == len-1u) {
             // We are at the innermost index.
@@ -1411,14 +1408,14 @@ fn GEP_tup_like(@block_ctxt cx, ty.t t,
     // flattened the incoming structure.
 
     auto s = split_type(cx.fcx.lcx.ccx, t, ixs, 0u);
-    auto prefix_ty = ty.mk_imm_tup(cx.fcx.lcx.ccx.tystore, s.prefix);
+    auto prefix_ty = ty.mk_imm_tup(cx.fcx.lcx.ccx.tcx, s.prefix);
     auto bcx = cx;
     auto sz = size_of(bcx, prefix_ty);
     bcx = sz.bcx;
     auto raw = bcx.build.PointerCast(base, T_ptr(T_i8()));
     auto bumped = bcx.build.GEP(raw, vec(sz.val));
 
-    if (ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tystore, s.target)) {
+    if (ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, s.target)) {
         ret res(bcx, bumped);
     }
 
@@ -1442,12 +1439,12 @@ fn GEP_tag(@block_ctxt cx,
     // Synthesize a tuple type so that GEP_tup_like() can work its magic.
     // Separately, store the type of the element we're interested in.
     auto arg_tys = variant.args;
-    auto elem_ty = ty.mk_nil(cx.fcx.lcx.ccx.tystore); // typestate infelicity
+    auto elem_ty = ty.mk_nil(cx.fcx.lcx.ccx.tcx); // typestate infelicity
     auto i = 0;
     let vec[ty.t] true_arg_tys = vec();
     for (ty.t aty in arg_tys) {
-        auto arg_ty = ty.bind_params_in_type(cx.fcx.lcx.ccx.tystore, aty);
-        arg_ty = ty.substitute_type_params(cx.fcx.lcx.ccx.tystore, ty_substs,
+        auto arg_ty = ty.bind_params_in_type(cx.fcx.lcx.ccx.tcx, aty);
+        arg_ty = ty.substitute_type_params(cx.fcx.lcx.ccx.tcx, ty_substs,
                                            arg_ty);
         true_arg_tys += vec(arg_ty);
         if (i == ix) {
@@ -1457,12 +1454,12 @@ fn GEP_tag(@block_ctxt cx,
         i += 1;
     }
 
-    auto tup_ty = ty.mk_imm_tup(cx.fcx.lcx.ccx.tystore, true_arg_tys);
+    auto tup_ty = ty.mk_imm_tup(cx.fcx.lcx.ccx.tcx, true_arg_tys);
 
     // Cast the blob pointer to the appropriate type, if we need to (i.e. if
     // the blob pointer isn't dynamically sized).
     let ValueRef llunionptr;
-    if (!ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tystore, tup_ty)) {
+    if (!ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, tup_ty)) {
         auto llty = type_of(cx.fcx.lcx.ccx, tup_ty);
         llunionptr = cx.build.TruncOrBitCast(llblobptr, T_ptr(llty));
     } else {
@@ -1474,7 +1471,7 @@ fn GEP_tag(@block_ctxt cx,
 
     // Cast the result to the appropriate type, if necessary.
     auto val;
-    if (!ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tystore, elem_ty)) {
+    if (!ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, elem_ty)) {
         auto llelemty = type_of(rslt.bcx.fcx.lcx.ccx, elem_ty);
         val = rslt.bcx.build.PointerCast(rslt.val, T_ptr(llelemty));
     } else {
@@ -1497,10 +1494,9 @@ fn trans_raw_malloc(@block_ctxt cx, TypeRef llptr_ty, ValueRef llsize)
 fn trans_malloc_boxed(@block_ctxt cx, ty.t t) -> result {
     // Synthesize a fake box type structurally so we have something
     // to measure the size of.
-    auto boxed_body = ty.mk_imm_tup(cx.fcx.lcx.ccx.tystore,
-                                    vec(ty.mk_int(cx.fcx.lcx.ccx.tystore),
-                                        t));
-    auto box_ptr = ty.mk_imm_box(cx.fcx.lcx.ccx.tystore, t);
+    auto boxed_body = ty.mk_imm_tup(cx.fcx.lcx.ccx.tcx,
+                                    vec(ty.mk_int(cx.fcx.lcx.ccx.tcx), t));
+    auto box_ptr = ty.mk_imm_box(cx.fcx.lcx.ccx.tcx, t);
     auto sz = size_of(cx, boxed_body);
     auto llty = type_of(cx.fcx.lcx.ccx, box_ptr);
     ret trans_raw_malloc(sz.bcx, llty, sz.val);
@@ -1531,7 +1527,7 @@ fn linearize_ty_params(@block_ctxt cx, ty.t t) ->
                   mutable vec[uint] defs);
 
     fn linearizer(@rr r, ty.t t) {
-        alt(ty.struct(r.cx.fcx.lcx.ccx.tystore, t)) {
+        alt(ty.struct(r.cx.fcx.lcx.ccx.tcx, t)) {
             case (ty.ty_param(?pid)) {
                 let bool seen = false;
                 for (uint d in r.defs) {
@@ -1554,22 +1550,22 @@ fn linearize_ty_params(@block_ctxt cx, ty.t t) ->
                   mutable defs = param_defs);
 
     auto f = bind linearizer(x, _);
-    ty.walk_ty(cx.fcx.lcx.ccx.tystore, f, t);
+    ty.walk_ty(cx.fcx.lcx.ccx.tcx, f, t);
 
     ret tup(x.defs, x.vals);
 }
 
 fn get_tydesc(&@block_ctxt cx, ty.t t) -> result {
     // Is the supplied type a type param? If so, return the passed-in tydesc.
-    alt (ty.type_param(cx.fcx.lcx.ccx.tystore, t)) {
+    alt (ty.type_param(cx.fcx.lcx.ccx.tcx, t)) {
         case (some[uint](?id)) { ret res(cx, cx.fcx.lltydescs.(id)); }
         case (none[uint])      { /* fall through */ }
     }
 
     // Does it contain a type param? If so, generate a derived tydesc.
-    let uint n_params = ty.count_ty_params(cx.fcx.lcx.ccx.tystore, t);
+    let uint n_params = ty.count_ty_params(cx.fcx.lcx.ccx.tcx, t);
 
-    if (ty.count_ty_params(cx.fcx.lcx.ccx.tystore, t) > 0u) {
+    if (ty.count_ty_params(cx.fcx.lcx.ccx.tcx, t) > 0u) {
         auto tys = linearize_ty_params(cx, t);
 
         check (n_params == _vec.len[uint](tys._0));
@@ -1635,7 +1631,7 @@ fn declare_tydesc(@local_ctxt cx, ty.t t) {
 
     auto llsize;
     auto llalign;
-    if (!ty.type_has_dynamic_size(ccx.tystore, t)) {
+    if (!ty.type_has_dynamic_size(ccx.tcx, t)) {
         auto llty = type_of(ccx, t);
         llsize = llsize_of(llty);
         llalign = llalign_of(llty);
@@ -1649,7 +1645,7 @@ fn declare_tydesc(@local_ctxt cx, ty.t t) {
     auto glue_fn_ty = T_ptr(T_glue_fn(ccx.tn));
 
     auto name = sanitize(ccx.names.next("tydesc_" +
-        ty.ty_to_str(cx.ccx.tystore, t)));
+        ty.ty_to_str(cx.ccx.tcx, t)));
     auto gvar = llvm.LLVMAddGlobal(ccx.llmod, T_tydesc(ccx.tn),
                                    _str.buf(name));
     auto tydesc = C_struct(vec(C_null(T_ptr(T_ptr(T_tydesc(ccx.tn)))),
@@ -1722,7 +1718,7 @@ fn make_generic_glue(@local_ctxt cx,
     // passed by value.
 
     auto llty;
-    if (ty.type_has_dynamic_size(cx.ccx.tystore, t)) {
+    if (ty.type_has_dynamic_size(cx.ccx.tcx, t)) {
         llty = T_ptr(T_i8());
     } else {
         llty = T_ptr(type_of(cx.ccx, t));
@@ -1769,10 +1765,10 @@ fn make_generic_glue(@local_ctxt cx,
 fn make_take_glue(@block_ctxt cx, ValueRef v, ty.t t) {
     // NB: v is an *alias* of type t here, not a direct value.
     auto bcx;
-    if (ty.type_is_boxed(cx.fcx.lcx.ccx.tystore, t)) {
+    if (ty.type_is_boxed(cx.fcx.lcx.ccx.tcx, t)) {
         bcx = incr_refcnt_of_boxed(cx, cx.build.Load(v)).bcx;
 
-    } else if (ty.type_is_structural(cx.fcx.lcx.ccx.tystore, t)) {
+    } else if (ty.type_is_structural(cx.fcx.lcx.ccx.tcx, t)) {
         bcx = iter_structural_ty(cx, v, t,
                                  bind take_ty(_, _, _)).bcx;
     } else {
@@ -1803,7 +1799,7 @@ fn incr_refcnt_of_boxed(@block_ctxt cx, ValueRef box_ptr) -> result {
 fn make_drop_glue(@block_ctxt cx, ValueRef v0, ty.t t) {
     // NB: v0 is an *alias* of type t here, not a direct value.
     auto rslt;
-    alt (ty.struct(cx.fcx.lcx.ccx.tystore, t)) {
+    alt (ty.struct(cx.fcx.lcx.ccx.tcx, t)) {
         case (ty.ty_str) {
             auto v = cx.build.Load(v0);
             rslt = decr_refcnt_and_if_zero
@@ -1944,13 +1940,13 @@ fn make_drop_glue(@block_ctxt cx, ValueRef v0, ty.t t) {
         }
 
         case (_) {
-            if (ty.type_is_structural(cx.fcx.lcx.ccx.tystore, t)) {
+            if (ty.type_is_structural(cx.fcx.lcx.ccx.tcx, t)) {
                 rslt = iter_structural_ty(cx, v0, t,
                                           bind drop_ty(_, _, _));
 
-            } else if (ty.type_is_scalar(cx.fcx.lcx.ccx.tystore, t) ||
-                       ty.type_is_native(cx.fcx.lcx.ccx.tystore, t) ||
-                       ty.type_is_nil(cx.fcx.lcx.ccx.tystore, t)) {
+            } else if (ty.type_is_scalar(cx.fcx.lcx.ccx.tcx, t) ||
+                       ty.type_is_native(cx.fcx.lcx.ccx.tcx, t) ||
+                       ty.type_is_nil(cx.fcx.lcx.ccx.tcx, t)) {
                 rslt = res(cx, C_nil());
             }
         }
@@ -2012,10 +2008,10 @@ fn make_cmp_glue(@block_ctxt cx,
     auto lhs = load_if_immediate(cx, lhs0, t);
     auto rhs = load_if_immediate(cx, rhs0, t);
 
-    if (ty.type_is_scalar(cx.fcx.lcx.ccx.tystore, t)) {
+    if (ty.type_is_scalar(cx.fcx.lcx.ccx.tcx, t)) {
         make_scalar_cmp_glue(cx, lhs, rhs, t, llop);
 
-    } else if (ty.type_is_box(cx.fcx.lcx.ccx.tystore, t)) {
+    } else if (ty.type_is_box(cx.fcx.lcx.ccx.tcx, t)) {
         lhs = cx.build.GEP(lhs, vec(C_int(0), C_int(abi.box_rc_field_body)));
         rhs = cx.build.GEP(rhs, vec(C_int(0), C_int(abi.box_rc_field_body)));
         auto rslt = call_cmp_glue(cx, lhs, rhs, t, llop);
@@ -2023,8 +2019,8 @@ fn make_cmp_glue(@block_ctxt cx,
         rslt.bcx.build.Store(rslt.val, cx.fcx.llretptr);
         rslt.bcx.build.RetVoid();
 
-    } else if (ty.type_is_structural(cx.fcx.lcx.ccx.tystore, t)
-               || ty.type_is_sequence(cx.fcx.lcx.ccx.tystore, t)) {
+    } else if (ty.type_is_structural(cx.fcx.lcx.ccx.tcx, t)
+               || ty.type_is_sequence(cx.fcx.lcx.ccx.tcx, t)) {
 
         auto scx = new_sub_block_ctxt(cx, "structural compare start");
         auto next = new_sub_block_ctxt(cx, "structural compare end");
@@ -2058,7 +2054,7 @@ fn make_cmp_glue(@block_ctxt cx,
         llvm.LLVMSetValueName(flag, _str.buf("flag"));
 
         auto r;
-        if (ty.type_is_sequence(cx.fcx.lcx.ccx.tystore, t)) {
+        if (ty.type_is_sequence(cx.fcx.lcx.ccx.tcx, t)) {
 
             // If we hit == all the way through the minimum-shared-length
             // section, default to judging the relative sequence lengths.
@@ -2097,8 +2093,7 @@ fn make_cmp_glue(@block_ctxt cx,
                 // be i8, because the data part of a vector always has type
                 // i8[]. So we need to cast it to the proper type.
 
-                if (!ty.type_has_dynamic_size(last_cx.fcx.lcx.ccx.tystore,
-                                              t)) {
+                if (!ty.type_has_dynamic_size(last_cx.fcx.lcx.ccx.tcx, t)) {
                     auto llelemty = T_ptr(type_of(last_cx.fcx.lcx.ccx, t));
                     av = cx.build.PointerCast(av, llelemty);
                     bv = cx.build.PointerCast(bv, llelemty);
@@ -2120,7 +2115,7 @@ fn make_cmp_glue(@block_ctxt cx,
             ret res(cnt_cx, C_nil());
         }
 
-        if (ty.type_is_structural(cx.fcx.lcx.ccx.tystore, t)) {
+        if (ty.type_is_structural(cx.fcx.lcx.ccx.tcx, t)) {
             r = iter_structural_ty_full(r.bcx, lhs, rhs, t,
                                         bind inner(next, false, flag, llop,
                                                    _, _, _, _));
@@ -2130,7 +2125,7 @@ fn make_cmp_glue(@block_ctxt cx,
             auto min_len = umin(r.bcx, vec_fill(r.bcx, lhs),
                                 vec_fill(r.bcx, rhs));
             auto rhs_lim = r.bcx.build.GEP(rhs_p0, vec(min_len));
-            auto elt_ty = ty.sequence_element_type(cx.fcx.lcx.ccx.tystore, t);
+            auto elt_ty = ty.sequence_element_type(cx.fcx.lcx.ccx.tcx, t);
             r = size_of(r.bcx, elt_ty);
             r = iter_sequence_raw(r.bcx, lhs_p0, rhs_p0, rhs_lim, r.val,
                                   bind inner(next, true, flag, llop,
@@ -2148,25 +2143,25 @@ fn make_cmp_glue(@block_ctxt cx,
         // FIXME: compare obj, fn by pointer?
         trans_fail(cx, none[common.span],
                    "attempt to compare values of type " +
-                   ty.ty_to_str(cx.fcx.lcx.ccx.tystore, t));
+                   ty.ty_to_str(cx.fcx.lcx.ccx.tcx, t));
     }
 }
 
 // A helper function to create scalar comparison glue.
 fn make_scalar_cmp_glue(@block_ctxt cx, ValueRef lhs, ValueRef rhs, ty.t t,
                         ValueRef llop) {
-    if (ty.type_is_fp(cx.fcx.lcx.ccx.tystore, t)) {
+    if (ty.type_is_fp(cx.fcx.lcx.ccx.tcx, t)) {
         make_fp_cmp_glue(cx, lhs, rhs, t, llop);
         ret;
     }
 
-    if (ty.type_is_integral(cx.fcx.lcx.ccx.tystore, t) ||
-            ty.type_is_bool(cx.fcx.lcx.ccx.tystore, t)) {
+    if (ty.type_is_integral(cx.fcx.lcx.ccx.tcx, t) ||
+            ty.type_is_bool(cx.fcx.lcx.ccx.tcx, t)) {
         make_integral_cmp_glue(cx, lhs, rhs, t, llop);
         ret;
     }
 
-    if (ty.type_is_nil(cx.fcx.lcx.ccx.tystore, t)) {
+    if (ty.type_is_nil(cx.fcx.lcx.ccx.tcx, t)) {
         cx.build.Store(C_bool(true), cx.fcx.llretptr);
         cx.build.RetVoid();
         ret;
@@ -2174,7 +2169,7 @@ fn make_scalar_cmp_glue(@block_ctxt cx, ValueRef lhs, ValueRef rhs, ty.t t,
 
     trans_fail(cx, none[common.span],
                "attempt to compare values of type " +
-               ty.ty_to_str(cx.fcx.lcx.ccx.tystore, t));
+               ty.ty_to_str(cx.fcx.lcx.ccx.tcx, t));
 }
 
 // A helper function to create floating point comparison glue.
@@ -2254,7 +2249,7 @@ fn compare_integral_values(@block_ctxt cx, ValueRef lhs, ValueRef rhs,
 fn make_integral_cmp_glue(@block_ctxt cx, ValueRef lhs, ValueRef rhs,
                           ty.t intype, ValueRef llop) {
     auto r = compare_integral_values(cx, lhs, rhs,
-        ty.type_is_signed(cx.fcx.lcx.ccx.tystore, intype), llop);
+        ty.type_is_signed(cx.fcx.lcx.ccx.tcx, intype), llop);
     r.bcx.build.Store(r.val, r.bcx.fcx.llretptr);
     r.bcx.build.RetVoid();
 }
@@ -2267,7 +2262,7 @@ type variant_info = rec(vec[ty.t] args, ty.t ctor_ty, ast.def_id id);
 // Returns information about the variants in a tag.
 fn tag_variants(@crate_ctxt cx, ast.def_id id) -> vec[variant_info] {
     if (cx.sess.get_targ_crate_num() != id._0) {
-        ret creader.get_tag_variants(cx.sess, cx.tystore, id);
+        ret creader.get_tag_variants(cx.sess, cx.tcx, id);
     }
 
     check (cx.items.contains_key(id));
@@ -2278,7 +2273,7 @@ fn tag_variants(@crate_ctxt cx, ast.def_id id) -> vec[variant_info] {
                 auto ctor_ty = node_ann_type(cx, variant.node.ann);
                 let vec[ty.t] arg_tys = vec();
                 if (_vec.len[ast.variant_arg](variant.node.args) > 0u) {
-                    for (ty.arg a in ty.ty_fn_args(cx.tystore, ctor_ty)) {
+                    for (ty.arg a in ty.ty_fn_args(cx.tcx, ctor_ty)) {
                         arg_tys += vec(a.ty);
                     }
                 }
@@ -2350,8 +2345,8 @@ fn iter_structural_ty_full(@block_ctxt cx,
                   val_pair_and_ty_fn f) -> result {
         auto box_a_ptr = cx.build.Load(box_a_cell);
         auto box_b_ptr = cx.build.Load(box_b_cell);
-        auto tnil = ty.mk_nil(cx.fcx.lcx.ccx.tystore);
-        auto tbox = ty.mk_imm_box(cx.fcx.lcx.ccx.tystore, tnil);
+        auto tnil = ty.mk_nil(cx.fcx.lcx.ccx.tcx);
+        auto tbox = ty.mk_imm_box(cx.fcx.lcx.ccx.tcx, tnil);
 
         auto inner_cx = new_sub_block_ctxt(cx, "iter box");
         auto next_cx = new_sub_block_ctxt(cx, "next");
@@ -2363,7 +2358,7 @@ fn iter_structural_ty_full(@block_ctxt cx,
         ret res(next_cx, r.val);
     }
 
-    alt (ty.struct(cx.fcx.lcx.ccx.tystore, t)) {
+    alt (ty.struct(cx.fcx.lcx.ccx.tcx, t)) {
         case (ty.ty_tup(?args)) {
             let int i = 0;
             for (ty.mt arg in args) {
@@ -2417,7 +2412,7 @@ fn iter_structural_ty_full(@block_ctxt cx,
             // comparison know not to proceed when the discriminants differ.
             auto bcx = cx;
             bcx = f(bcx, lldiscrim_a, lldiscrim_b,
-                    ty.mk_int(cx.fcx.lcx.ccx.tystore)).bcx;
+                    ty.mk_int(cx.fcx.lcx.ccx.tcx)).bcx;
 
             auto unr_cx = new_sub_block_ctxt(bcx, "tag-iter-unr");
             unr_cx.build.Unreachable();
@@ -2437,7 +2432,7 @@ fn iter_structural_ty_full(@block_ctxt cx,
                 if (_vec.len[ty.t](variant.args) > 0u) {
                     // N-ary variant.
                     auto fn_ty = variant.ctor_ty;
-                    alt (ty.struct(bcx.fcx.lcx.ccx.tystore, fn_ty)) {
+                    alt (ty.struct(bcx.fcx.lcx.ccx.tcx, fn_ty)) {
                         case (ty.ty_fn(_, ?args, _)) {
                             auto j = 0;
                             for (ty.arg a in args) {
@@ -2454,9 +2449,9 @@ fn iter_structural_ty_full(@block_ctxt cx,
                                 variant_cx = rslt.bcx;
 
                                 auto ty_subst = ty.bind_params_in_type(
-                                    cx.fcx.lcx.ccx.tystore, a.ty);
+                                    cx.fcx.lcx.ccx.tcx, a.ty);
                                 ty_subst = ty.substitute_type_params(
-                                    cx.fcx.lcx.ccx.tystore, tps, ty_subst);
+                                    cx.fcx.lcx.ccx.tcx, tps, ty_subst);
 
                                 auto llfld_a =
                                     load_if_immediate(variant_cx,
@@ -2577,7 +2572,7 @@ fn iter_sequence_inner(@block_ctxt cx,
                   ValueRef dst,
                   ValueRef src) -> result {
         auto llptrty;
-        if (!ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tystore, elt_ty)) {
+        if (!ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, elt_ty)) {
             auto llty = type_of(cx.fcx.lcx.ccx, elt_ty);
             llptrty = T_ptr(llty);
         } else {
@@ -2612,7 +2607,7 @@ fn iter_sequence(@block_ctxt cx,
                                           C_int(abi.vec_elt_fill)));
 
         auto llunit_ty;
-        if (ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tystore, elt_ty)) {
+        if (ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, elt_ty)) {
             llunit_ty = T_i8();
         } else {
             llunit_ty = type_of(cx.fcx.lcx.ccx, elt_ty);
@@ -2633,12 +2628,12 @@ fn iter_sequence(@block_ctxt cx,
         ret iter_sequence_inner(cx, p0, p1, elt_ty, f);
     }
 
-    alt (ty.struct(cx.fcx.lcx.ccx.tystore, t)) {
+    alt (ty.struct(cx.fcx.lcx.ccx.tcx, t)) {
         case (ty.ty_vec(?elt)) {
             ret iter_sequence_body(cx, v, elt.ty, f, false);
         }
         case (ty.ty_str) {
-            auto et = ty.mk_mach(cx.fcx.lcx.ccx.tystore, common.ty_u8);
+            auto et = ty.mk_mach(cx.fcx.lcx.ccx.tcx, common.ty_u8);
             ret iter_sequence_body(cx, v, et, f, true);
         }
         case (_) { fail; }
@@ -2708,7 +2703,7 @@ fn call_cmp_glue(@block_ctxt cx, ValueRef lhs, ValueRef rhs, ty.t t,
 }
 
 fn take_ty(@block_ctxt cx, ValueRef v, ty.t t) -> result {
-    if (!ty.type_is_scalar(cx.fcx.lcx.ccx.tystore, t)) {
+    if (!ty.type_is_scalar(cx.fcx.lcx.ccx.tcx, t)) {
         call_tydesc_glue(cx, v, t, abi.tydesc_field_take_glue);
     }
     ret res(cx, C_nil());
@@ -2730,7 +2725,7 @@ fn drop_ty(@block_ctxt cx,
            ValueRef v,
            ty.t t) -> result {
 
-    if (!ty.type_is_scalar(cx.fcx.lcx.ccx.tystore, t)) {
+    if (!ty.type_is_scalar(cx.fcx.lcx.ccx.tcx, t)) {
         call_tydesc_glue(cx, v, t, abi.tydesc_field_drop_glue);
     }
     ret res(cx, C_nil());
@@ -2760,7 +2755,7 @@ fn memcpy_ty(@block_ctxt cx,
              ValueRef dst,
              ValueRef src,
              ty.t t) -> result {
-    if (ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tystore, t)) {
+    if (ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, t)) {
         auto llszptr = field_of_tydesc(cx, t, abi.tydesc_field_size);
         auto llsz = llszptr.bcx.build.Load(llszptr.val);
         ret call_memcpy(llszptr.bcx, dst, src, llsz);
@@ -2780,22 +2775,22 @@ fn copy_ty(@block_ctxt cx,
            ValueRef dst,
            ValueRef src,
            ty.t t) -> result {
-    if (ty.type_is_scalar(cx.fcx.lcx.ccx.tystore, t) ||
-            ty.type_is_native(cx.fcx.lcx.ccx.tystore, t)) {
+    if (ty.type_is_scalar(cx.fcx.lcx.ccx.tcx, t) ||
+            ty.type_is_native(cx.fcx.lcx.ccx.tcx, t)) {
         ret res(cx, cx.build.Store(src, dst));
 
-    } else if (ty.type_is_nil(cx.fcx.lcx.ccx.tystore, t)) {
+    } else if (ty.type_is_nil(cx.fcx.lcx.ccx.tcx, t)) {
         ret res(cx, C_nil());
 
-    } else if (ty.type_is_boxed(cx.fcx.lcx.ccx.tystore, t)) {
+    } else if (ty.type_is_boxed(cx.fcx.lcx.ccx.tcx, t)) {
         auto r = take_ty(cx, src, t);
         if (action == DROP_EXISTING) {
             r = drop_ty(r.bcx, r.bcx.build.Load(dst), t);
         }
         ret res(r.bcx, r.bcx.build.Store(src, dst));
 
-    } else if (ty.type_is_structural(cx.fcx.lcx.ccx.tystore, t) ||
-               ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tystore, t)) {
+    } else if (ty.type_is_structural(cx.fcx.lcx.ccx.tcx, t) ||
+               ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, t)) {
         auto r = take_ty(cx, src, t);
         if (action == DROP_EXISTING) {
             r = drop_ty(r.bcx, dst, t);
@@ -2804,7 +2799,7 @@ fn copy_ty(@block_ctxt cx,
     }
 
     cx.fcx.lcx.ccx.sess.bug("unexpected type in trans.copy_ty: " +
-                        ty.ty_to_str(cx.fcx.lcx.ccx.tystore, t));
+                        ty.ty_to_str(cx.fcx.lcx.ccx.tcx, t));
     fail;
 }
 
@@ -2861,16 +2856,16 @@ fn trans_lit(@crate_ctxt cx, &ast.lit lit, &ast.ann ann) -> ValueRef {
 }
 
 fn target_type(@crate_ctxt cx, ty.t t) -> ty.t {
-    alt (ty.struct(cx.tystore, t)) {
+    alt (ty.struct(cx.tcx, t)) {
         case (ty.ty_int) {
-            auto struct_ty = ty.mk_mach(cx.tystore,
+            auto struct_ty = ty.mk_mach(cx.tcx,
                                         cx.sess.get_targ_cfg().int_type);
-            ret ty.copy_cname(cx.tystore, struct_ty, t);
+            ret ty.copy_cname(cx.tcx, struct_ty, t);
         }
         case (ty.ty_uint) {
-            auto struct_ty = ty.mk_mach(cx.tystore,
+            auto struct_ty = ty.mk_mach(cx.tcx,
                                         cx.sess.get_targ_cfg().uint_type);
-            ret ty.copy_cname(cx.tystore, struct_ty, t);
+            ret ty.copy_cname(cx.tcx, struct_ty, t);
         }
         case (_) { /* fall through */ }
     }
@@ -2880,7 +2875,7 @@ fn target_type(@crate_ctxt cx, ty.t t) -> ty.t {
 
 // Converts an annotation to a type
 fn node_ann_type(@crate_ctxt cx, &ast.ann a) -> ty.t {
-    ret target_type(cx, ty.ann_to_monotype(cx.tystore, a));
+    ret target_type(cx, ty.ann_to_monotype(cx.tcx, a));
 }
 
 fn node_ann_ty_params(&ast.ann a) -> vec[ty.t] {
@@ -2909,23 +2904,23 @@ fn trans_unary(@block_ctxt cx, ast.unop op,
                @ast.expr e, &ast.ann a) -> result {
 
     auto sub = trans_expr(cx, e);
-    auto e_ty = ty.expr_ty(cx.fcx.lcx.ccx.tystore, e);
+    auto e_ty = ty.expr_ty(cx.fcx.lcx.ccx.tcx, e);
 
     alt (op) {
         case (ast.bitnot) {
             sub = autoderef(sub.bcx, sub.val,
-                            ty.expr_ty(cx.fcx.lcx.ccx.tystore, e));
+                            ty.expr_ty(cx.fcx.lcx.ccx.tcx, e));
             ret res(sub.bcx, sub.bcx.build.Not(sub.val));
         }
         case (ast.not) {
             sub = autoderef(sub.bcx, sub.val,
-                            ty.expr_ty(cx.fcx.lcx.ccx.tystore, e));
+                            ty.expr_ty(cx.fcx.lcx.ccx.tcx, e));
             ret res(sub.bcx, sub.bcx.build.Not(sub.val));
         }
         case (ast.neg) {
             sub = autoderef(sub.bcx, sub.val,
-                            ty.expr_ty(cx.fcx.lcx.ccx.tystore, e));
-            if(ty.struct(cx.fcx.lcx.ccx.tystore, e_ty) == ty.ty_float) {
+                            ty.expr_ty(cx.fcx.lcx.ccx.tcx, e));
+            if(ty.struct(cx.fcx.lcx.ccx.tcx, e_ty) == ty.ty_float) {
                 ret res(sub.bcx, sub.bcx.build.FNeg(sub.val));
             }
             else {
@@ -2933,7 +2928,7 @@ fn trans_unary(@block_ctxt cx, ast.unop op,
             }
         }
         case (ast.box(_)) {
-            auto e_ty = ty.expr_ty(cx.fcx.lcx.ccx.tystore, e);
+            auto e_ty = ty.expr_ty(cx.fcx.lcx.ccx.tcx, e);
             auto e_val = sub.val;
             auto box_ty = node_ann_type(sub.bcx.fcx.lcx.ccx, a);
             sub = trans_malloc_boxed(sub.bcx, e_ty);
@@ -2952,7 +2947,7 @@ fn trans_unary(@block_ctxt cx, ast.unop op,
             // Cast the body type to the type of the value. This is needed to
             // make tags work, since tags have a different LLVM type depending
             // on whether they're boxed or not.
-            if (!ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tystore, e_ty)) {
+            if (!ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, e_ty)) {
                 auto llety = T_ptr(type_of(sub.bcx.fcx.lcx.ccx, e_ty));
                 body = sub.bcx.build.PointerCast(body, llety);
             }
@@ -3013,10 +3008,10 @@ fn trans_compare(@block_ctxt cx0, ast.binop op, ty.t t0,
 fn trans_vec_append(@block_ctxt cx, ty.t t,
                     ValueRef lhs, ValueRef rhs) -> result {
 
-    auto elt_ty = ty.sequence_element_type(cx.fcx.lcx.ccx.tystore, t);
+    auto elt_ty = ty.sequence_element_type(cx.fcx.lcx.ccx.tcx, t);
 
     auto skip_null = C_bool(false);
-    alt (ty.struct(cx.fcx.lcx.ccx.tystore, t)) {
+    alt (ty.struct(cx.fcx.lcx.ccx.tcx, t)) {
         case (ty.ty_str) { skip_null = C_bool(true); }
         case (_) { }
     }
@@ -3056,7 +3051,7 @@ fn trans_eager_binop(@block_ctxt cx, ast.binop op, ty.t intype,
                      ValueRef lhs, ValueRef rhs) -> result {
 
     auto is_float = false;
-    alt (ty.struct(cx.fcx.lcx.ccx.tystore, intype)) {
+    alt (ty.struct(cx.fcx.lcx.ccx.tcx, intype)) {
         case (ty.ty_float) {
             is_float = true;
         }
@@ -3067,7 +3062,7 @@ fn trans_eager_binop(@block_ctxt cx, ast.binop op, ty.t intype,
 
     alt (op) {
         case (ast.add) {
-            if (ty.type_is_sequence(cx.fcx.lcx.ccx.tystore, intype)) {
+            if (ty.type_is_sequence(cx.fcx.lcx.ccx.tcx, intype)) {
                 ret trans_vec_add(cx, intype, lhs, rhs);
             }
             if (is_float) {
@@ -3099,7 +3094,7 @@ fn trans_eager_binop(@block_ctxt cx, ast.binop op, ty.t intype,
             if (is_float) {
                 ret res(cx, cx.build.FDiv(lhs, rhs));
             }
-            if (ty.type_is_signed(cx.fcx.lcx.ccx.tystore, intype)) {
+            if (ty.type_is_signed(cx.fcx.lcx.ccx.tcx, intype)) {
                 ret res(cx, cx.build.SDiv(lhs, rhs));
             } else {
                 ret res(cx, cx.build.UDiv(lhs, rhs));
@@ -3109,7 +3104,7 @@ fn trans_eager_binop(@block_ctxt cx, ast.binop op, ty.t intype,
             if (is_float) {
                 ret res(cx, cx.build.FRem(lhs, rhs));
             }
-            if (ty.type_is_signed(cx.fcx.lcx.ccx.tystore, intype)) {
+            if (ty.type_is_signed(cx.fcx.lcx.ccx.tcx, intype)) {
                 ret res(cx, cx.build.SRem(lhs, rhs));
             } else {
                 ret res(cx, cx.build.URem(lhs, rhs));
@@ -3134,7 +3129,7 @@ fn autoderef(@block_ctxt cx, ValueRef v, ty.t t) -> result {
     let ty.t t1 = t;
 
     while (true) {
-        alt (ty.struct(cx.fcx.lcx.ccx.tystore, t1)) {
+        alt (ty.struct(cx.fcx.lcx.ccx.tcx, t1)) {
             case (ty.ty_box(?mt)) {
                 auto body = cx.build.GEP(v1,
                                          vec(C_int(0),
@@ -3145,8 +3140,7 @@ fn autoderef(@block_ctxt cx, ValueRef v, ty.t t) -> result {
                 // to cast this pointer, since statically-sized tag types have
                 // different types depending on whether they're behind a box
                 // or not.
-                if (!ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tystore,
-                                              mt.ty)) {
+                if (!ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, mt.ty)) {
                     auto llty = type_of(cx.fcx.lcx.ccx, mt.ty);
                     v1 = cx.build.PointerCast(body, T_ptr(llty));
                 } else {
@@ -3166,7 +3160,7 @@ fn autoderefed_ty(@crate_ctxt ccx, ty.t t) -> ty.t {
     let ty.t t1 = t;
 
     while (true) {
-        alt (ty.struct(ccx.tystore, t1)) {
+        alt (ty.struct(ccx.tcx, t1)) {
             case (ty.ty_box(?mt)) {
                 t1 = mt.ty;
             }
@@ -3187,12 +3181,12 @@ fn trans_binary(@block_ctxt cx, ast.binop op,
             // Lazy-eval and
             auto lhs_res = trans_expr(cx, a);
             lhs_res = autoderef(lhs_res.bcx, lhs_res.val,
-                                ty.expr_ty(cx.fcx.lcx.ccx.tystore, a));
+                                ty.expr_ty(cx.fcx.lcx.ccx.tcx, a));
 
             auto rhs_cx = new_scope_block_ctxt(cx, "rhs");
             auto rhs_res = trans_expr(rhs_cx, b);
             rhs_res = autoderef(rhs_res.bcx, rhs_res.val,
-                                ty.expr_ty(cx.fcx.lcx.ccx.tystore, b));
+                                ty.expr_ty(cx.fcx.lcx.ccx.tcx, b));
 
             auto lhs_false_cx = new_scope_block_ctxt(cx, "lhs false");
             auto lhs_false_res = res(lhs_false_cx, C_bool(false));
@@ -3209,12 +3203,12 @@ fn trans_binary(@block_ctxt cx, ast.binop op,
             // Lazy-eval or
             auto lhs_res = trans_expr(cx, a);
             lhs_res = autoderef(lhs_res.bcx, lhs_res.val,
-                                ty.expr_ty(cx.fcx.lcx.ccx.tystore, a));
+                                ty.expr_ty(cx.fcx.lcx.ccx.tcx, a));
 
             auto rhs_cx = new_scope_block_ctxt(cx, "rhs");
             auto rhs_res = trans_expr(rhs_cx, b);
             rhs_res = autoderef(rhs_res.bcx, rhs_res.val,
-                                ty.expr_ty(cx.fcx.lcx.ccx.tystore, b));
+                                ty.expr_ty(cx.fcx.lcx.ccx.tcx, b));
 
             auto lhs_true_cx = new_scope_block_ctxt(cx, "lhs true");
             auto lhs_true_res = res(lhs_true_cx, C_bool(true));
@@ -3230,10 +3224,10 @@ fn trans_binary(@block_ctxt cx, ast.binop op,
         case (_) {
             // Remaining cases are eager:
             auto lhs = trans_expr(cx, a);
-            auto lhty = ty.expr_ty(cx.fcx.lcx.ccx.tystore, a);
+            auto lhty = ty.expr_ty(cx.fcx.lcx.ccx.tcx, a);
             lhs = autoderef(lhs.bcx, lhs.val, lhty);
             auto rhs = trans_expr(lhs.bcx, b);
-            auto rhty = ty.expr_ty(cx.fcx.lcx.ccx.tystore, b);
+            auto rhty = ty.expr_ty(cx.fcx.lcx.ccx.tcx, b);
             rhs = autoderef(rhs.bcx, rhs.val, rhty);
             ret trans_eager_binop(rhs.bcx, op,
                 autoderefed_ty(cx.fcx.lcx.ccx, lhty), lhs.val, rhs.val);
@@ -3310,12 +3304,12 @@ fn trans_if(@block_ctxt cx, @ast.expr cond,
             // If we have an else expression, then the entire
             // if expression can have a non-nil type.
             // FIXME: This isn't quite right, particularly re: dynamic types
-            auto expr_ty = ty.expr_ty(cx.fcx.lcx.ccx.tystore, elexpr);
-            if (ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tystore, expr_ty)) {
+            auto expr_ty = ty.expr_ty(cx.fcx.lcx.ccx.tcx, elexpr);
+            if (ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, expr_ty)) {
                 expr_llty = T_typaram_ptr(cx.fcx.lcx.ccx.tn);
             } else {
                 expr_llty = type_of(else_res.bcx.fcx.lcx.ccx, expr_ty);
-                if (ty.type_is_structural(cx.fcx.lcx.ccx.tystore, expr_ty)) {
+                if (ty.type_is_structural(cx.fcx.lcx.ccx.tcx, expr_ty)) {
                     expr_llty = T_ptr(expr_llty);
                 }
             }
@@ -3367,7 +3361,7 @@ fn trans_for(@block_ctxt cx,
     }
 
     auto next_cx = new_sub_block_ctxt(cx, "next");
-    auto seq_ty = ty.expr_ty(cx.fcx.lcx.ccx.tystore, seq);
+    auto seq_ty = ty.expr_ty(cx.fcx.lcx.ccx.tcx, seq);
     auto seq_res = trans_expr(cx, seq);
     auto it = iter_sequence(seq_res.bcx, seq_res.val, seq_ty,
                             bind inner(_, local, _, _, body, next_cx));
@@ -3469,7 +3463,7 @@ fn trans_for_each(@block_ctxt cx,
 
     auto lcx = cx.fcx.lcx;
     // FIXME: possibly support alias-mode here?
-    auto decl_ty = ty.mk_nil(lcx.ccx.tystore);
+    auto decl_ty = ty.mk_nil(lcx.ccx.tcx);
     auto decl_id;
     alt (decl.node) {
         case (ast.decl_local(?local)) {
@@ -3557,7 +3551,7 @@ fn trans_for_each(@block_ctxt cx,
         type_of_fn_full(lcx.ccx, ast.proto_fn,
                         none[TypeRef],
                         vec(rec(mode=ast.alias, ty=decl_ty)),
-                        ty.mk_nil(lcx.ccx.tystore), 0u);
+                        ty.mk_nil(lcx.ccx.tcx), 0u);
 
     let ValueRef lliterbody = decl_internal_fastcall_fn(lcx.ccx.llmod,
                                                        s, iter_body_llty);
@@ -3738,7 +3732,7 @@ fn trans_pat_match(@block_ctxt cx, @ast.pat pat, ValueRef llval,
                     matched_cx = rslt.bcx;
 
                     auto llsubval = load_if_immediate(matched_cx,
-                        llsubvalptr, pat_ty(cx.fcx.lcx.ccx.tystore, subpat));
+                        llsubvalptr, pat_ty(cx.fcx.lcx.ccx.tcx, subpat));
                     auto subpat_res = trans_pat_match(matched_cx, subpat,
                                                       llsubval, next_cx);
                     matched_cx = subpat_res.bcx;
@@ -3833,11 +3827,11 @@ fn trans_alt(@block_ctxt cx, @ast.expr expr,
     // FIXME: This isn't quite right, particularly re: dynamic types
     auto expr_ty = ty.ann_to_type(ann);
     auto expr_llty;
-    if (ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tystore, expr_ty)) {
+    if (ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, expr_ty)) {
         expr_llty = T_typaram_ptr(cx.fcx.lcx.ccx.tn);
     } else {
         expr_llty = type_of(cx.fcx.lcx.ccx, expr_ty);
-        if (ty.type_is_structural(cx.fcx.lcx.ccx.tystore, expr_ty)) {
+        if (ty.type_is_structural(cx.fcx.lcx.ccx.tcx, expr_ty)) {
             expr_llty = T_ptr(expr_llty);
         }
     }
@@ -3980,21 +3974,18 @@ fn trans_path(@block_ctxt cx, &ast.path p, &option.t[ast.def] dopt,
                 }
                 case (ast.def_fn(?did)) {
                     auto tyt = ty.lookup_item_type(cx.fcx.lcx.ccx.sess,
-                        cx.fcx.lcx.ccx.tystore,
-                        cx.fcx.lcx.ccx.type_cache, did);
+                        cx.fcx.lcx.ccx.tcx, cx.fcx.lcx.ccx.type_cache, did);
                     ret lval_generic_fn(cx, tyt, did, ann);
                 }
                 case (ast.def_obj(?did)) {
                     auto tyt = ty.lookup_item_type(cx.fcx.lcx.ccx.sess,
-                        cx.fcx.lcx.ccx.tystore,
-                        cx.fcx.lcx.ccx.type_cache, did);
+                        cx.fcx.lcx.ccx.tcx, cx.fcx.lcx.ccx.type_cache, did);
                     ret lval_generic_fn(cx, tyt, did, ann);
                 }
                 case (ast.def_variant(?tid, ?vid)) {
                     auto v_tyt = ty.lookup_item_type(cx.fcx.lcx.ccx.sess,
-                        cx.fcx.lcx.ccx.tystore,
-                        cx.fcx.lcx.ccx.type_cache, vid);
-                    alt (ty.struct(cx.fcx.lcx.ccx.tystore, v_tyt._1)) {
+                        cx.fcx.lcx.ccx.tcx, cx.fcx.lcx.ccx.type_cache, vid);
+                    alt (ty.struct(cx.fcx.lcx.ccx.tcx, v_tyt._1)) {
                         case (ty.ty_fn(_, _, _)) {
                             // N-ary variant.
                             ret lval_generic_fn(cx, v_tyt, vid, ann);
@@ -4010,8 +4001,8 @@ fn trans_path(@block_ctxt cx, &ast.path p, &option.t[ast.def] dopt,
                             auto lltagblob = alloc_result.val;
 
                             auto lltagty;
-                            if (ty.type_has_dynamic_size(
-                                    cx.fcx.lcx.ccx.tystore, tag_ty)) {
+                            if (ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx,
+                                                         tag_ty)) {
                                 lltagty = T_opaque_tag(cx.fcx.lcx.ccx.tn);
                             } else {
                                 lltagty = type_of(cx.fcx.lcx.ccx, tag_ty);
@@ -4035,7 +4026,7 @@ fn trans_path(@block_ctxt cx, &ast.path p, &option.t[ast.def] dopt,
                 }
                 case (ast.def_native_fn(?did)) {
                     auto tyt = ty.lookup_item_type(cx.fcx.lcx.ccx.sess,
-                        cx.fcx.lcx.ccx.tystore,
+                        cx.fcx.lcx.ccx.tcx,
                         cx.fcx.lcx.ccx.type_cache, did);
                     ret lval_generic_fn(cx, tyt, did, ann);
                 }
@@ -4057,7 +4048,7 @@ fn trans_field(@block_ctxt cx, &ast.span sp, ValueRef v, ty.t t0,
     auto r = autoderef(cx, v, t0);
     auto t = autoderefed_ty(cx.fcx.lcx.ccx, t0);
 
-    alt (ty.struct(cx.fcx.lcx.ccx.tystore, t)) {
+    alt (ty.struct(cx.fcx.lcx.ccx.tcx, t)) {
         case (ty.ty_tup(_)) {
             let uint ix = ty.field_num(cx.fcx.lcx.ccx.sess, sp, field);
             auto v = GEP_tup_like(r.bcx, t, r.val, vec(0, ix as int));
@@ -4080,7 +4071,7 @@ fn trans_field(@block_ctxt cx, &ast.span sp, ValueRef v, ty.t t0,
                                                 C_int(ix as int)));
 
             auto lvo = lval_mem(r.bcx, v);
-            let ty.t fn_ty = ty.method_ty_to_fn_ty(cx.fcx.lcx.ccx.tystore,
+            let ty.t fn_ty = ty.method_ty_to_fn_ty(cx.fcx.lcx.ccx.tcx,
                                                     methods.(ix));
             ret rec(llobj = some[ValueRef](r.val),
                     method_ty = some[ty.t](fn_ty)
@@ -4095,7 +4086,7 @@ fn trans_index(@block_ctxt cx, &ast.span sp, @ast.expr base,
                @ast.expr idx, &ast.ann ann) -> lval_result {
 
     auto lv = trans_expr(cx, base);
-    lv = autoderef(lv.bcx, lv.val, ty.expr_ty(cx.fcx.lcx.ccx.tystore, base));
+    lv = autoderef(lv.bcx, lv.val, ty.expr_ty(cx.fcx.lcx.ccx.tcx, base));
     auto ix = trans_expr(lv.bcx, idx);
     auto v = lv.val;
     auto bcx = ix.bcx;
@@ -4136,7 +4127,7 @@ fn trans_index(@block_ctxt cx, &ast.span sp, @ast.expr base,
 
     auto body = next_cx.build.GEP(v, vec(C_int(0), C_int(abi.vec_elt_data)));
     auto elt;
-    if (ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tystore, unit_ty)) {
+    if (ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, unit_ty)) {
         body = next_cx.build.PointerCast(body, T_ptr(T_array(T_i8(), 0u)));
         elt = next_cx.build.GEP(body, vec(C_int(0), scaled_ix));
     } else {
@@ -4161,7 +4152,7 @@ fn trans_lval(@block_ctxt cx, @ast.expr e) -> lval_result {
         }
         case (ast.expr_field(?base, ?ident, ?ann)) {
             auto r = trans_expr(cx, base);
-            auto t = ty.expr_ty(cx.fcx.lcx.ccx.tystore, base);
+            auto t = ty.expr_ty(cx.fcx.lcx.ccx.tcx, base);
             ret trans_field(r.bcx, e.span, r.val, t, ident, ann);
         }
         case (ast.expr_index(?base, ?idx, ?ann)) {
@@ -4203,16 +4194,16 @@ fn trans_cast(@block_ctxt cx, @ast.expr e, &ast.ann ann) -> result {
     auto llsrctype = val_ty(e_res.val);
     auto t = node_ann_type(cx.fcx.lcx.ccx, ann);
     auto lldsttype = type_of(cx.fcx.lcx.ccx, t);
-    if (!ty.type_is_fp(cx.fcx.lcx.ccx.tystore, t)) {
+    if (!ty.type_is_fp(cx.fcx.lcx.ccx.tcx, t)) {
         // TODO: native-to-native casts
-        if (ty.type_is_native(cx.fcx.lcx.ccx.tystore,
-                              ty.expr_ty(cx.fcx.lcx.ccx.tystore, e))) {
+        if (ty.type_is_native(cx.fcx.lcx.ccx.tcx,
+                              ty.expr_ty(cx.fcx.lcx.ccx.tcx, e))) {
             e_res.val = e_res.bcx.build.PtrToInt(e_res.val, lldsttype);
-        } else if (ty.type_is_native(cx.fcx.lcx.ccx.tystore, t)) {
+        } else if (ty.type_is_native(cx.fcx.lcx.ccx.tcx, t)) {
             e_res.val = e_res.bcx.build.IntToPtr(e_res.val, lldsttype);
         } else if (llvm.LLVMGetIntTypeWidth(lldsttype) >
             llvm.LLVMGetIntTypeWidth(llsrctype)) {
-            if (ty.type_is_signed(cx.fcx.lcx.ccx.tystore, t)) {
+            if (ty.type_is_signed(cx.fcx.lcx.ccx.tcx, t)) {
                 // Widening signed cast.
                 e_res.val =
                     e_res.bcx.build.SExtOrBitCast(e_res.val,
@@ -4255,7 +4246,7 @@ fn trans_bind_thunk(@local_ctxt cx,
     auto lltop = bcx.llbb;
 
     auto llclosure_ptr_ty =
-        type_of(cx.ccx, ty.mk_imm_box(cx.ccx.tystore, closure_ty));
+        type_of(cx.ccx, ty.mk_imm_box(cx.ccx.tcx, closure_ty));
     auto llclosure = bcx.build.PointerCast(fcx.llenv, llclosure_ptr_ty);
 
     auto lltarget = GEP_tup_like(bcx, closure_ty, llclosure,
@@ -4268,11 +4259,11 @@ fn trans_bind_thunk(@local_ctxt cx,
                                              C_int(abi.fn_field_box)));
     lltargetclosure = bcx.build.Load(lltargetclosure);
 
-    auto outgoing_ret_ty = ty.ty_fn_ret(cx.ccx.tystore, outgoing_fty);
-    auto outgoing_args = ty.ty_fn_args(cx.ccx.tystore, outgoing_fty);
+    auto outgoing_ret_ty = ty.ty_fn_ret(cx.ccx.tcx, outgoing_fty);
+    auto outgoing_args = ty.ty_fn_args(cx.ccx.tcx, outgoing_fty);
 
     auto llretptr = fcx.llretptr;
-    if (ty.type_has_dynamic_size(cx.ccx.tystore, outgoing_ret_ty)) {
+    if (ty.type_has_dynamic_size(cx.ccx.tcx, outgoing_ret_ty)) {
         llretptr = bcx.build.PointerCast(llretptr, T_typaram_ptr(cx.ccx.tn));
     }
 
@@ -4321,8 +4312,7 @@ fn trans_bind_thunk(@local_ctxt cx,
 
                 if (out_arg.mode == ast.val) {
                     val = bcx.build.Load(val);
-                } else if (ty.count_ty_params(cx.ccx.tystore,
-                                              out_arg.ty) > 0u) {
+                } else if (ty.count_ty_params(cx.ccx.tcx, out_arg.ty) > 0u) {
                     check (out_arg.mode == ast.alias);
                     val = bcx.build.PointerCast(val, llout_arg_ty);
                 }
@@ -4335,7 +4325,7 @@ fn trans_bind_thunk(@local_ctxt cx,
             case (none[@ast.expr]) {
                 let ValueRef passed_arg = llvm.LLVMGetParam(llthunk, a);
 
-                if (ty.count_ty_params(cx.ccx.tystore, out_arg.ty) > 0u) {
+                if (ty.count_ty_params(cx.ccx.tcx, out_arg.ty) > 0u) {
                     check (out_arg.mode == ast.alias);
                     passed_arg = bcx.build.PointerCast(passed_arg,
                                                        llout_arg_ty);
@@ -4357,7 +4347,7 @@ fn trans_bind_thunk(@local_ctxt cx,
     // Cast the outgoing function to the appropriate type (see the comments in
     // trans_bind below for why this is necessary).
     auto lltargetty = type_of_fn(bcx.fcx.lcx.ccx,
-                                 ty.ty_fn_proto(bcx.fcx.lcx.ccx.tystore,
+                                 ty.ty_fn_proto(bcx.fcx.lcx.ccx.tcx,
                                                 outgoing_fty),
                                  outgoing_args,
                                  outgoing_ret_ty,
@@ -4399,7 +4389,7 @@ fn trans_bind(@block_ctxt cx, @ast.expr f,
         let vec[ValueRef] lltydescs;
         alt (f_res.generic) {
             case (none[generic_info]) {
-                outgoing_fty = ty.expr_ty(cx.fcx.lcx.ccx.tystore, f);
+                outgoing_fty = ty.expr_ty(cx.fcx.lcx.ccx.tcx, f);
                 lltydescs = vec();
             }
             case (some[generic_info](?ginfo)) {
@@ -4427,19 +4417,19 @@ fn trans_bind(@block_ctxt cx, @ast.expr f,
 
                 _vec.push[ValueRef](bound_vals, arg.val);
                 _vec.push[ty.t](bound_tys,
-                                 ty.expr_ty(cx.fcx.lcx.ccx.tystore, e));
+                                 ty.expr_ty(cx.fcx.lcx.ccx.tcx, e));
 
                 i += 1u;
             }
 
             // Synthesize a closure type.
-            let ty.t bindings_ty = ty.mk_imm_tup(cx.fcx.lcx.ccx.tystore,
+            let ty.t bindings_ty = ty.mk_imm_tup(cx.fcx.lcx.ccx.tcx,
                                                   bound_tys);
 
             // NB: keep this in sync with T_closure_ptr; we're making
             // a ty.t structure that has the same "shape" as the LLVM type
             // it constructs.
-            let ty.t tydesc_ty = ty.mk_type(cx.fcx.lcx.ccx.tystore);
+            let ty.t tydesc_ty = ty.mk_type(cx.fcx.lcx.ccx.tcx);
 
             let vec[ty.t] captured_tys =
                 _vec.init_elt[ty.t](tydesc_ty, ty_param_count);
@@ -4448,9 +4438,9 @@ fn trans_bind(@block_ctxt cx, @ast.expr f,
                 vec(tydesc_ty,
                     outgoing_fty,
                     bindings_ty,
-                    ty.mk_imm_tup(cx.fcx.lcx.ccx.tystore, captured_tys));
+                    ty.mk_imm_tup(cx.fcx.lcx.ccx.tcx, captured_tys));
 
-            let ty.t closure_ty = ty.mk_imm_tup(cx.fcx.lcx.ccx.tystore,
+            let ty.t closure_ty = ty.mk_imm_tup(cx.fcx.lcx.ccx.tcx,
                                                  closure_tys);
 
             auto r = trans_malloc_boxed(bcx, closure_ty);
@@ -4481,9 +4471,9 @@ fn trans_bind(@block_ctxt cx, @ast.expr f,
             // function has, which type_of() doesn't, as only we know which
             // item the function refers to.
             auto llfnty = type_of_fn(bcx.fcx.lcx.ccx,
-                ty.ty_fn_proto(bcx.fcx.lcx.ccx.tystore, outgoing_fty),
-                ty.ty_fn_args(bcx.fcx.lcx.ccx.tystore, outgoing_fty),
-                ty.ty_fn_ret(bcx.fcx.lcx.ccx.tystore, outgoing_fty),
+                ty.ty_fn_proto(bcx.fcx.lcx.ccx.tcx, outgoing_fty),
+                ty.ty_fn_args(bcx.fcx.lcx.ccx.tcx, outgoing_fty),
+                ty.ty_fn_ret(bcx.fcx.lcx.ccx.tcx, outgoing_fty),
                 ty_param_count);
             auto llclosurety = T_ptr(T_fn_pair(bcx.fcx.lcx.ccx.tn, llfnty));
 
@@ -4570,9 +4560,9 @@ fn trans_arg_expr(@block_ctxt cx,
 
     auto val;
     auto bcx = cx;
-    auto e_ty = ty.expr_ty(cx.fcx.lcx.ccx.tystore, e);
+    auto e_ty = ty.expr_ty(cx.fcx.lcx.ccx.tcx, e);
 
-    if (ty.type_is_structural(cx.fcx.lcx.ccx.tystore, e_ty)) {
+    if (ty.type_is_structural(cx.fcx.lcx.ccx.tcx, e_ty)) {
         auto re = trans_expr(bcx, e);
         val = re.val;
         bcx = re.bcx;
@@ -4603,11 +4593,11 @@ fn trans_arg_expr(@block_ctxt cx,
         bcx = re.bcx;
     }
 
-    if (ty.count_ty_params(cx.fcx.lcx.ccx.tystore, arg.ty) > 0u) {
+    if (ty.count_ty_params(cx.fcx.lcx.ccx.tcx, arg.ty) > 0u) {
         auto lldestty = lldestty0;
         if (arg.mode == ast.val) {
             // FIXME: we'd prefer to use &&, but rustboot doesn't like it
-            if (ty.type_is_structural(cx.fcx.lcx.ccx.tystore, e_ty)) {
+            if (ty.type_is_structural(cx.fcx.lcx.ccx.tcx, e_ty)) {
                 lldestty = T_ptr(lldestty);
             }
         }
@@ -4616,7 +4606,7 @@ fn trans_arg_expr(@block_ctxt cx,
 
     if (arg.mode == ast.val) {
         // FIXME: we'd prefer to use &&, but rustboot doesn't like it
-        if (ty.type_is_structural(cx.fcx.lcx.ccx.tystore, e_ty)) {
+        if (ty.type_is_structural(cx.fcx.lcx.ccx.tcx, e_ty)) {
             // Until here we've been treating structures by pointer;
             // we are now passing it as an arg, so need to load it.
             val = bcx.build.Load(val);
@@ -4641,14 +4631,14 @@ fn trans_args(@block_ctxt cx,
               ty.t fn_ty)
     -> tup(@block_ctxt, vec[ValueRef], ValueRef) {
 
-    let vec[ty.arg] args = ty.ty_fn_args(cx.fcx.lcx.ccx.tystore, fn_ty);
+    let vec[ty.arg] args = ty.ty_fn_args(cx.fcx.lcx.ccx.tcx, fn_ty);
     let vec[ValueRef] llargs = vec();
     let vec[ValueRef] lltydescs = vec();
     let @block_ctxt bcx = cx;
 
 
     // Arg 0: Output pointer.
-    auto retty = ty.ty_fn_ret(cx.fcx.lcx.ccx.tystore, fn_ty);
+    auto retty = ty.ty_fn_ret(cx.fcx.lcx.ccx.tcx, fn_ty);
     auto llretslot_res = alloc_ty(bcx, retty);
     bcx = llretslot_res.bcx;
     auto llretslot = llretslot_res.val;
@@ -4656,16 +4646,16 @@ fn trans_args(@block_ctxt cx,
     alt (gen) {
         case (some[generic_info](?g)) {
             lltydescs = g.tydescs;
-            args = ty.ty_fn_args(cx.fcx.lcx.ccx.tystore, g.item_type);
-            retty = ty.ty_fn_ret(cx.fcx.lcx.ccx.tystore, g.item_type);
+            args = ty.ty_fn_args(cx.fcx.lcx.ccx.tcx, g.item_type);
+            retty = ty.ty_fn_ret(cx.fcx.lcx.ccx.tcx, g.item_type);
         }
         case (_) {
         }
     }
-    if (ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tystore, retty)) {
+    if (ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, retty)) {
         llargs += vec(bcx.build.PointerCast
                       (llretslot, T_typaram_ptr(cx.fcx.lcx.ccx.tn)));
-    } else if (ty.count_ty_params(cx.fcx.lcx.ccx.tystore, retty) != 0u) {
+    } else if (ty.count_ty_params(cx.fcx.lcx.ccx.tcx, retty) != 0u) {
         // It's possible that the callee has some generic-ness somewhere in
         // its return value -- say a method signature within an obj or a fn
         // type deep in a structure -- which the caller has a concrete view
@@ -4765,7 +4755,7 @@ fn trans_call(@block_ctxt cx, @ast.expr f,
         }
 
         case (_) {
-            fn_ty = ty.expr_ty(cx.fcx.lcx.ccx.tystore, f);
+            fn_ty = ty.expr_ty(cx.fcx.lcx.ccx.tcx, f);
 
         }
 
@@ -4795,7 +4785,7 @@ fn trans_call(@block_ctxt cx, @ast.expr f,
 
     alt (lliterbody) {
         case (none[ValueRef]) {
-            if (!ty.type_is_nil(cx.fcx.lcx.ccx.tystore, ret_ty)) {
+            if (!ty.type_is_nil(cx.fcx.lcx.ccx.tcx, ret_ty)) {
                 retval = load_if_immediate(bcx, llretslot, ret_ty);
                 // Retval doesn't correspond to anything really tangible in
                 // the frame, but it's a ref all the same, so we put a note
@@ -4826,7 +4816,7 @@ fn trans_tup(@block_ctxt cx, vec[ast.elt] elts,
     let int i = 0;
 
     for (ast.elt e in elts) {
-        auto e_ty = ty.expr_ty(cx.fcx.lcx.ccx.tystore, e.expr);
+        auto e_ty = ty.expr_ty(cx.fcx.lcx.ccx.tcx, e.expr);
         auto src_res = trans_expr(bcx, e.expr);
         bcx = src_res.bcx;
         auto dst_res = GEP_tup_like(bcx, t, tup_val, vec(0, i));
@@ -4841,7 +4831,7 @@ fn trans_vec(@block_ctxt cx, vec[@ast.expr] args,
              &ast.ann ann) -> result {
     auto t = node_ann_type(cx.fcx.lcx.ccx, ann);
     auto unit_ty = t;
-    alt (ty.struct(cx.fcx.lcx.ccx.tystore, t)) {
+    alt (ty.struct(cx.fcx.lcx.ccx.tcx, t)) {
         case (ty.ty_vec(?mt)) {
             unit_ty = mt.ty;
         }
@@ -4869,7 +4859,7 @@ fn trans_vec(@block_ctxt cx, vec[@ast.expr] args,
                                            C_int(abi.vec_elt_data)));
 
     auto pseudo_tup_ty =
-        ty.mk_imm_tup(cx.fcx.lcx.ccx.tystore,
+        ty.mk_imm_tup(cx.fcx.lcx.ccx.tcx,
                       _vec.init_elt[ty.t](unit_ty,
                                            _vec.len[@ast.expr](args)));
     let int i = 0;
@@ -4893,7 +4883,7 @@ fn trans_vec(@block_ctxt cx, vec[@ast.expr] args,
         // (5) "src_res" is derived from "unit_ty", which is not behind a box.
 
         auto dst_val;
-        if (!ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tystore, unit_ty)) {
+        if (!ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, unit_ty)) {
             auto llunit_ty = type_of(cx.fcx.lcx.ccx, unit_ty);
             dst_val = bcx.build.PointerCast(dst_res.val, T_ptr(llunit_ty));
         } else {
@@ -4935,7 +4925,7 @@ fn trans_rec(@block_ctxt cx, vec[ast.field] fields,
     }
 
     let vec[ty.field] ty_fields = vec();
-    alt (ty.struct(cx.fcx.lcx.ccx.tystore, t)) {
+    alt (ty.struct(cx.fcx.lcx.ccx.tcx, t)) {
         case (ty.ty_rec(?flds)) { ty_fields = flds; }
     }
 
@@ -5127,7 +5117,7 @@ fn trans_expr(@block_ctxt cx, @ast.expr e) -> result {
     // lval cases fall through to trans_lval and then
     // possibly load the result (if it's non-structural).
 
-    auto t = ty.expr_ty(cx.fcx.lcx.ccx.tystore, e);
+    auto t = ty.expr_ty(cx.fcx.lcx.ccx.tcx, e);
     auto sub = trans_lval(cx, e);
     ret res(sub.res.bcx, load_if_immediate(sub.res.bcx, sub.res.val, t));
 }
@@ -5139,9 +5129,9 @@ fn trans_expr(@block_ctxt cx, @ast.expr e) -> result {
 // immediate-ness of the type.
 
 fn type_is_immediate(@crate_ctxt ccx, ty.t t) -> bool {
-    ret ty.type_is_scalar(ccx.tystore, t) ||
-        ty.type_is_boxed(ccx.tystore, t) ||
-        ty.type_is_native(ccx.tystore, t);
+    ret ty.type_is_scalar(ccx.tcx, t) ||
+        ty.type_is_boxed(ccx.tcx, t) ||
+        ty.type_is_native(ccx.tcx, t);
 }
 
 fn do_spill(@block_ctxt cx, ValueRef v) -> ValueRef {
@@ -5188,12 +5178,12 @@ fn trans_log(int lvl, @block_ctxt cx, @ast.expr e) -> result {
     cx.build.CondBr(test, log_cx.llbb, after_cx.llbb);
 
     auto sub = trans_expr(log_cx, e);
-    auto e_ty = ty.expr_ty(cx.fcx.lcx.ccx.tystore, e);
+    auto e_ty = ty.expr_ty(cx.fcx.lcx.ccx.tcx, e);
 
-    if (ty.type_is_fp(cx.fcx.lcx.ccx.tystore, e_ty)) {
+    if (ty.type_is_fp(cx.fcx.lcx.ccx.tcx, e_ty)) {
         let TypeRef tr;
         let bool is32bit = false;
-        alt (ty.struct(cx.fcx.lcx.ccx.tystore, e_ty)) {
+        alt (ty.struct(cx.fcx.lcx.ccx.tcx, e_ty)) {
             case (ty.ty_machine(util.common.ty_f32)) {
                 tr = T_f32();
                 is32bit = true;
@@ -5219,7 +5209,7 @@ fn trans_log(int lvl, @block_ctxt cx, @ast.expr e) -> result {
             uval.bcx.build.Br(after_cx.llbb);
         }
     } else {
-        alt (ty.struct(cx.fcx.lcx.ccx.tystore, e_ty)) {
+        alt (ty.struct(cx.fcx.lcx.ccx.tcx, e_ty)) {
             case (ty.ty_str) {
                 auto v = vp2i(sub.bcx, sub.val);
                 trans_upcall(sub.bcx,
@@ -5300,7 +5290,7 @@ fn trans_put(@block_ctxt cx, &option.t[@ast.expr] e) -> result {
     alt (e) {
         case (none[@ast.expr]) { }
         case (some[@ast.expr](?x)) {
-            auto e_ty = ty.expr_ty(cx.fcx.lcx.ccx.tystore, x);
+            auto e_ty = ty.expr_ty(cx.fcx.lcx.ccx.tcx, x);
             auto arg = rec(mode=ast.alias, ty=e_ty);
             auto arg_tys = type_of_explicit_args(cx.fcx.lcx.ccx, vec(arg));
             auto r = trans_arg_expr(bcx, arg, arg_tys.(0), x);
@@ -5359,7 +5349,7 @@ fn trans_ret(@block_ctxt cx, &option.t[@ast.expr] e) -> result {
 
     alt (e) {
         case (some[@ast.expr](?x)) {
-            auto t = ty.expr_ty(cx.fcx.lcx.ccx.tystore, x);
+            auto t = ty.expr_ty(cx.fcx.lcx.ccx.tcx, x);
             auto r = trans_expr(cx, x);
             bcx = r.bcx;
             val = r.val;
@@ -5399,7 +5389,7 @@ fn trans_port(@block_ctxt cx, ast.ann ann) -> result {
 
     auto t = node_ann_type(cx.fcx.lcx.ccx, ann);
     auto unit_ty;
-    alt (ty.struct(cx.fcx.lcx.ccx.tystore, t)) {
+    alt (ty.struct(cx.fcx.lcx.ccx.tcx, t)) {
         case (ty.ty_port(?t)) {
             unit_ty = t;
         }
@@ -5454,7 +5444,7 @@ fn trans_send(@block_ctxt cx, @ast.expr lhs, @ast.expr rhs,
 
     auto chan_ty = node_ann_type(cx.fcx.lcx.ccx, ann);
     auto unit_ty;
-    alt (ty.struct(cx.fcx.lcx.ccx.tystore, chan_ty)) {
+    alt (ty.struct(cx.fcx.lcx.ccx.tcx, chan_ty)) {
         case (ty.ty_chan(?t)) {
             unit_ty = t;
         }
@@ -5546,7 +5536,7 @@ fn init_local(@block_ctxt cx, @ast.local local) -> result {
 
 fn zero_alloca(@block_ctxt cx, ValueRef llptr, ty.t t) -> result {
     auto bcx = cx;
-    if (ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tystore, t)) {
+    if (ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, t)) {
         auto llsz = size_of(bcx, t);
         bcx = call_bzero(llsz.bcx, llptr, llsz.val).bcx;
     } else {
@@ -5679,7 +5669,7 @@ fn llallocas_block_ctxt(@fn_ctxt fcx) -> @block_ctxt {
 
 fn alloc_ty(@block_ctxt cx, ty.t t) -> result {
     auto val = C_int(0);
-    if (ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tystore, t)) {
+    if (ty.type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, t)) {
 
         // NB: we have to run this particular 'size_of' in a
         // block_ctxt built on the llallocas block for the fn,
@@ -5734,8 +5724,8 @@ fn trans_block(@block_ctxt cx, &ast.block b) -> result {
             if (is_terminated(bcx)) {
                 ret r;
             } else {
-                auto r_ty = ty.expr_ty(cx.fcx.lcx.ccx.tystore, e);
-                if (!ty.type_is_nil(cx.fcx.lcx.ccx.tystore, r_ty)) {
+                auto r_ty = ty.expr_ty(cx.fcx.lcx.ccx.tcx, e);
+                if (!ty.type_is_nil(cx.fcx.lcx.ccx.tcx, r_ty)) {
                     // The value resulting from the block gets copied into an
                     // alloca created in an outer scope and its refcount
                     // bumped so that it can escape this block. This means
@@ -5932,7 +5922,7 @@ fn is_terminated(@block_ctxt cx) -> bool {
 }
 
 fn arg_tys_of_fn(@crate_ctxt ccx, ast.ann ann) -> vec[ty.arg] {
-    alt (ty.struct(ccx.tystore, ty.ann_to_type(ann))) {
+    alt (ty.struct(ccx.tcx, ty.ann_to_type(ann))) {
         case (ty.ty_fn(_, ?arg_tys, _)) {
             ret arg_tys;
         }
@@ -5941,7 +5931,7 @@ fn arg_tys_of_fn(@crate_ctxt ccx, ast.ann ann) -> vec[ty.arg] {
 }
 
 fn ret_ty_of_fn_ty(@crate_ctxt ccx, ty.t t) -> ty.t {
-    alt (ty.struct(ccx.tystore, t)) {
+    alt (ty.struct(ccx.tcx, t)) {
         case (ty.ty_fn(_, _, ?ret_ty)) {
             ret ret_ty;
         }
@@ -5965,7 +5955,7 @@ fn populate_fn_ctxt_from_llself(@fn_ctxt fcx, self_vt llself) {
 
     // Synthesize a tuple type for the fields so that GEP_tup_like() can work
     // its magic.
-    auto fields_tup_ty = ty.mk_imm_tup(fcx.lcx.ccx.tystore, field_tys);
+    auto fields_tup_ty = ty.mk_imm_tup(fcx.lcx.ccx.tcx, field_tys);
 
     auto n_typarams = _vec.len[ast.ty_param](bcx.fcx.lcx.obj_typarams);
     let TypeRef llobj_box_ty = T_obj_ptr(bcx.fcx.lcx.ccx.tn, n_typarams);
@@ -5992,7 +5982,7 @@ fn populate_fn_ctxt_from_llself(@fn_ctxt fcx, self_vt llself) {
     // If we can (i.e. the type is statically sized), then cast the resulting
     // fields pointer to the appropriate LLVM type. If not, just leave it as
     // i8 *.
-    if (!ty.type_has_dynamic_size(fcx.lcx.ccx.tystore, fields_tup_ty)) {
+    if (!ty.type_has_dynamic_size(fcx.lcx.ccx.tcx, fields_tup_ty)) {
         auto llfields_ty = type_of(fcx.lcx.ccx, fields_tup_ty);
         obj_fields = vi2p(bcx, obj_fields, T_ptr(llfields_ty));
     } else {
@@ -6077,7 +6067,7 @@ fn trans_vtbl(@local_ctxt cx,
     for (@ast.method m in meths) {
 
         auto llfnty = T_nil();
-        alt (ty.struct(cx.ccx.tystore, node_ann_type(cx.ccx, m.node.ann))) {
+        alt (ty.struct(cx.ccx.tcx, node_ann_type(cx.ccx, m.node.ann))) {
             case (ty.ty_fn(?proto, ?inputs, ?output)) {
                 llfnty = type_of_fn_full(cx.ccx, proto,
                                          some[TypeRef](llself_ty),
@@ -6116,7 +6106,7 @@ fn trans_dtor(@local_ctxt cx,
               &@ast.method dtor) -> ValueRef {
 
     auto llfnty = T_nil();
-    alt (ty.struct(cx.ccx.tystore, node_ann_type(cx.ccx, dtor.node.ann))) {
+    alt (ty.struct(cx.ccx.tcx, node_ann_type(cx.ccx, dtor.node.ann))) {
         case (ty.ty_fn(?proto, ?inputs, ?output)) {
             llfnty = type_of_fn_full(cx.ccx, proto,
                                      some[TypeRef](llself_ty),
@@ -6190,19 +6180,19 @@ fn trans_obj(@local_ctxt cx, &ast._obj ob, ast.def_id oid,
         }
 
         // Synthesize an obj body type.
-        auto tydesc_ty = ty.mk_type(cx.ccx.tystore);
+        auto tydesc_ty = ty.mk_type(cx.ccx.tcx);
         let vec[ty.t] tps = vec();
         for (ast.ty_param tp in ty_params) {
             _vec.push[ty.t](tps, tydesc_ty);
         }
 
-        let ty.t typarams_ty = ty.mk_imm_tup(cx.ccx.tystore, tps);
-        let ty.t fields_ty = ty.mk_imm_tup(cx.ccx.tystore, obj_fields);
-        let ty.t body_ty = ty.mk_imm_tup(cx.ccx.tystore,
+        let ty.t typarams_ty = ty.mk_imm_tup(cx.ccx.tcx, tps);
+        let ty.t fields_ty = ty.mk_imm_tup(cx.ccx.tcx, obj_fields);
+        let ty.t body_ty = ty.mk_imm_tup(cx.ccx.tcx,
                                           vec(tydesc_ty,
                                               typarams_ty,
                                               fields_ty));
-        let ty.t boxed_body_ty = ty.mk_imm_box(cx.ccx.tystore, body_ty);
+        let ty.t boxed_body_ty = ty.mk_imm_box(cx.ccx.tcx, body_ty);
 
         // Malloc a box for the body.
         auto box = trans_malloc_boxed(bcx, body_ty);
@@ -6304,7 +6294,7 @@ fn trans_tag_variant(@local_ctxt cx, ast.def_id tag_id,
     let vec[ty.t] ty_param_substs = vec();
     i = 0u;
     for (ast.ty_param tp in ty_params) {
-        ty_param_substs += vec(ty.mk_param(cx.ccx.tystore, i));
+        ty_param_substs += vec(ty.mk_param(cx.ccx.tcx, i));
         i += 1u;
     }
 
@@ -6340,8 +6330,8 @@ fn trans_tag_variant(@local_ctxt cx, ast.def_id tag_id,
 
         auto arg_ty = arg_tys.(i).ty;
         auto llargval;
-        if (ty.type_is_structural(cx.ccx.tystore, arg_ty) ||
-                ty.type_has_dynamic_size(cx.ccx.tystore, arg_ty)) {
+        if (ty.type_is_structural(cx.ccx.tcx, arg_ty) ||
+                ty.type_has_dynamic_size(cx.ccx.tcx, arg_ty)) {
             llargval = llargptr;
         } else {
             llargval = bcx.build.Load(llargptr);
@@ -6440,7 +6430,7 @@ fn decl_fn_and_pair(@crate_ctxt ccx,
 
     auto llfty;
     auto llpairty;
-    alt (ty.struct(ccx.tystore, node_ann_type(ccx, ann))) {
+    alt (ty.struct(ccx.tcx, node_ann_type(ccx, ann))) {
         case (ty.ty_fn(?proto, ?inputs, ?output)) {
             llfty = type_of_fn(ccx, proto, inputs, output,
                                _vec.len[ast.ty_param](ty_params));
@@ -6499,7 +6489,7 @@ fn native_fn_ty_param_count(@crate_ctxt cx, &ast.def_id id) -> uint {
 
 fn native_fn_wrapper_type(@crate_ctxt cx, uint ty_param_count, ty.t x)
         -> TypeRef {
-    alt (ty.struct(cx.tystore, x)) {
+    alt (ty.struct(cx.tcx, x)) {
         case (ty.ty_native_fn(?abi, ?args, ?out)) {
             ret type_of_fn(cx, ast.proto_fn, args, out, ty_param_count);
         }
@@ -6536,10 +6526,10 @@ fn decl_native_fn_and_pair(@crate_ctxt ccx,
     auto item = ccx.native_items.get(id);
     auto fn_type = node_ann_type(ccx, ann);  // NB: has no type params
 
-    auto abi = ty.ty_fn_abi(ccx.tystore, fn_type);
+    auto abi = ty.ty_fn_abi(ccx.tcx, fn_type);
     auto llfnty = type_of_native_fn(ccx, abi,
-        ty.ty_fn_args(ccx.tystore, fn_type),
-        ty.ty_fn_ret(ccx.tystore, fn_type), num_ty_param);
+        ty.ty_fn_args(ccx.tcx, fn_type),
+        ty.ty_fn_ret(ccx.tcx, fn_type), num_ty_param);
 
     let vec[ValueRef] call_args = vec();
     auto arg_n = 3u;
@@ -6570,7 +6560,7 @@ fn decl_native_fn_and_pair(@crate_ctxt ccx,
                 &mutable vec[ValueRef] args,
                 ValueRef v,
                 ty.t t) {
-        if (ty.type_is_integral(cx.fcx.lcx.ccx.tystore, t)) {
+        if (ty.type_is_integral(cx.fcx.lcx.ccx.tcx, t)) {
             auto lldsttype = T_int();
             auto llsrctype = type_of(cx.fcx.lcx.ccx, t);
             if (llvm.LLVMGetIntTypeWidth(lldsttype) >
@@ -6579,7 +6569,7 @@ fn decl_native_fn_and_pair(@crate_ctxt ccx,
             } else {
                 args += vec(cx.build.TruncOrBitCast(v, T_int()));
             }
-        } else if (ty.type_is_fp(cx.fcx.lcx.ccx.tystore, t)) {
+        } else if (ty.type_is_fp(cx.fcx.lcx.ccx.tcx, t)) {
             args += vec(cx.build.FPToSI(v, T_int()));
         } else {
             args += vec(vp2i(cx, v));
@@ -6588,7 +6578,7 @@ fn decl_native_fn_and_pair(@crate_ctxt ccx,
 
     auto r;
     auto rptr;
-    auto args = ty.ty_fn_args(ccx.tystore, fn_type);
+    auto args = ty.ty_fn_args(ccx.tcx, fn_type);
     if (abi == ast.native_abi_llvm) {
         let vec[ValueRef] call_args = vec();
         let vec[TypeRef] call_arg_tys = vec();
@@ -6601,7 +6591,7 @@ fn decl_native_fn_and_pair(@crate_ctxt ccx,
         }
         auto llnativefnty = T_fn(call_arg_tys,
                                  type_of(ccx,
-                                         ty.ty_fn_ret(ccx.tystore, fn_type)));
+                                         ty.ty_fn_ret(ccx.tcx, fn_type)));
         auto llnativefn = get_extern_fn(ccx.externs, ccx.llmod, name,
                                         lib.llvm.LLVMCCallConv, llnativefnty);
         r = bcx.build.Call(llnativefn, call_args);
@@ -7502,7 +7492,7 @@ fn create_crate_map(@crate_ctxt ccx) -> ValueRef {
     ret map;
 }
 
-fn trans_crate(session.session sess, @ast.crate crate, @ty.type_store tystore,
+fn trans_crate(session.session sess, @ast.crate crate, ty.ctxt tcx,
                &ty.type_cache type_cache, str output, bool shared,
                bool optimize, bool verify, output_type ot) {
     auto llmod =
@@ -7549,7 +7539,7 @@ fn trans_crate(session.session sess, @ast.crate crate, @ty.type_store tystore,
                     glues = glues,
                     names = namegen(0),
                     sha = std.sha1.mk_sha1(),
-                    tystore = tystore);
+                    tcx = tcx);
     auto cx = new_local_ctxt(ccx);
 
     create_typedefs(ccx);
diff --git a/src/comp/middle/ty.rs b/src/comp/middle/ty.rs
index 2381751f899..71a98e77e1f 100644
--- a/src/comp/middle/ty.rs
+++ b/src/comp/middle/ty.rs
@@ -44,10 +44,15 @@ type method = rec(ast.proto proto,
 
 type mt = rec(t ty, ast.mutability mut);
 
+// Contains information needed to resolve types and (in the future) look up
+// the types of AST nodes.
+type ctxt = rec(@type_store ts);
+type ty_ctxt = ctxt;    // Needed for disambiguation from Unify.ctxt.
+
 // Convert from method type to function type.  Pretty easy; we just drop
 // 'ident'.
-fn method_ty_to_fn_ty(@type_store tystore, method m) -> t {
-    ret mk_fn(tystore, m.proto, m.inputs, m.output);
+fn method_ty_to_fn_ty(ctxt cx, method m) -> t {
+    ret mk_fn(cx, m.proto, m.inputs, m.output);
 }
 
 // Never construct these manually. These are interned. Also don't assume that
@@ -186,12 +191,14 @@ fn mk_type_store() -> @type_store {
              others=map.mk_hashmap[t,t](hasher, eqer));
 }
 
+fn mk_ctxt() -> ctxt { ret rec(ts=mk_type_store()); }
+
 // Type constructors
 
 // These are private constructors to this module. External users should always
 // use the mk_foo() functions below.
-fn gen_ty(@type_store tystore, &sty st) -> t {
-    ret gen_ty_full(tystore, st, none[str]);
+fn gen_ty(ctxt cx, &sty st) -> t {
+    ret gen_ty_full(cx, st, none[str]);
 }
 
 fn mk_ty_full(&sty st, option.t[str] cname) -> t {
@@ -200,135 +207,130 @@ fn mk_ty_full(&sty st, option.t[str] cname) -> t {
     ret @rec(struct=st, cname=cname, magic=magic, hash=h);
 }
 
-fn gen_ty_full(@type_store tystore, &sty st, option.t[str] cname) -> t {
+fn gen_ty_full(ctxt cx, &sty st, option.t[str] cname) -> t {
     auto new_type = mk_ty_full(st, cname);
     // Is it interned?
-    alt (tystore.others.find(new_type)) {
+    alt (cx.ts.others.find(new_type)) {
         case (some[t](?typ)) {
             ret typ;
         }
         case (none[t]) {
             // Nope. Insert it and return.
-            tystore.others.insert(new_type, new_type);
+            cx.ts.others.insert(new_type, new_type);
             ret new_type;
         }
     }
 }
 
-fn mk_nil(@type_store ts) -> t          { ret ts.t_nil; }
-fn mk_bool(@type_store ts) -> t         { ret ts.t_bool; }
-fn mk_int(@type_store ts) -> t          { ret ts.t_int; }
-fn mk_float(@type_store ts) -> t        { ret ts.t_float; }
-fn mk_uint(@type_store ts) -> t         { ret ts.t_uint; }
+fn mk_nil(ctxt cx) -> t     { ret cx.ts.t_nil; }
+fn mk_bool(ctxt cx) -> t    { ret cx.ts.t_bool; }
+fn mk_int(ctxt cx) -> t     { ret cx.ts.t_int; }
+fn mk_float(ctxt cx) -> t   { ret cx.ts.t_float; }
+fn mk_uint(ctxt cx) -> t    { ret cx.ts.t_uint; }
 
-fn mk_mach(@type_store ts, util.common.ty_mach tm) -> t {
+fn mk_mach(ctxt cx, util.common.ty_mach tm) -> t {
     alt (tm) {
-        case (ty_u8) { ret ts.t_u8; }
-        case (ty_u16) { ret ts.t_u16; }
-        case (ty_u32) { ret ts.t_u32; }
-        case (ty_u64) { ret ts.t_u64; }
+        case (ty_u8)  { ret cx.ts.t_u8; }
+        case (ty_u16) { ret cx.ts.t_u16; }
+        case (ty_u32) { ret cx.ts.t_u32; }
+        case (ty_u64) { ret cx.ts.t_u64; }
 
-        case (ty_i8) { ret ts.t_i8; }
-        case (ty_i16) { ret ts.t_i16; }
-        case (ty_i32) { ret ts.t_i32; }
-        case (ty_i64) { ret ts.t_i64; }
+        case (ty_i8)  { ret cx.ts.t_i8; }
+        case (ty_i16) { ret cx.ts.t_i16; }
+        case (ty_i32) { ret cx.ts.t_i32; }
+        case (ty_i64) { ret cx.ts.t_i64; }
 
-        case (ty_f32) { ret ts.t_f32; }
-        case (ty_f64) { ret ts.t_f64; }
+        case (ty_f32) { ret cx.ts.t_f32; }
+        case (ty_f64) { ret cx.ts.t_f64; }
     }
     fail;
 }
 
-fn mk_char(@type_store ts) -> t         { ret ts.t_char; }
-fn mk_str(@type_store ts) -> t          { ret ts.t_str; }
+fn mk_char(ctxt cx) -> t    { ret cx.ts.t_char; }
+fn mk_str(ctxt cx) -> t     { ret cx.ts.t_str; }
 
-fn mk_tag(@type_store ts, ast.def_id did, vec[t] tys) -> t {
-    ret gen_ty(ts, ty_tag(did, tys));
+fn mk_tag(ctxt cx, ast.def_id did, vec[t] tys) -> t {
+    ret gen_ty(cx, ty_tag(did, tys));
 }
 
-fn mk_box(@type_store ts, mt tm) -> t {
-    ret gen_ty(ts, ty_box(tm));
+fn mk_box(ctxt cx, mt tm) -> t {
+    ret gen_ty(cx, ty_box(tm));
 }
 
-fn mk_imm_box(@type_store ts, t ty) -> t {
-    ret mk_box(ts, rec(ty=ty, mut=ast.imm));
+fn mk_imm_box(ctxt cx, t ty) -> t {
+    ret mk_box(cx, rec(ty=ty, mut=ast.imm));
 }
 
-fn mk_vec(@type_store ts, mt tm) -> t   { ret gen_ty(ts, ty_vec(tm)); }
-fn mk_port(@type_store ts, t ty) -> t   { ret gen_ty(ts, ty_port(ty)); }
-fn mk_chan(@type_store ts, t ty) -> t   { ret gen_ty(ts, ty_chan(ty)); }
-fn mk_task(@type_store ts) -> t         { ret gen_ty(ts, ty_task); }
+fn mk_vec(ctxt cx, mt tm) -> t  { ret gen_ty(cx, ty_vec(tm)); }
+fn mk_port(ctxt cx, t ty) -> t  { ret gen_ty(cx, ty_port(ty)); }
+fn mk_chan(ctxt cx, t ty) -> t  { ret gen_ty(cx, ty_chan(ty)); }
+fn mk_task(ctxt cx) -> t        { ret gen_ty(cx, ty_task); }
 
-fn mk_tup(@type_store ts, vec[mt] tms) -> t {
-    ret gen_ty(ts, ty_tup(tms));
-}
+fn mk_tup(ctxt cx, vec[mt] tms) -> t { ret gen_ty(cx, ty_tup(tms)); }
 
-fn mk_imm_tup(@type_store ts, vec[t] tys) -> t {
+fn mk_imm_tup(ctxt cx, vec[t] tys) -> t {
     // TODO: map
     let vec[ty.mt] mts = vec();
     for (t typ in tys) {
         mts += vec(rec(ty=typ, mut=ast.imm));
     }
-    ret mk_tup(ts, mts);
+    ret mk_tup(cx, mts);
 }
 
-fn mk_rec(@type_store ts, vec[field] fs) -> t {
-    ret gen_ty(ts, ty_rec(fs));
-}
+fn mk_rec(ctxt cx, vec[field] fs) -> t { ret gen_ty(cx, ty_rec(fs)); }
 
-fn mk_fn(@type_store ts, ast.proto proto, vec[arg] args, t ty) -> t {
-    ret gen_ty(ts, ty_fn(proto, args, ty));
+fn mk_fn(ctxt cx, ast.proto proto, vec[arg] args, t ty) -> t {
+    ret gen_ty(cx, ty_fn(proto, args, ty));
 }
 
-fn mk_native_fn(@type_store ts, ast.native_abi abi, vec[arg] args, t ty)
-        -> t {
-    ret gen_ty(ts, ty_native_fn(abi, args, ty));
+fn mk_native_fn(ctxt cx, ast.native_abi abi, vec[arg] args, t ty) -> t {
+    ret gen_ty(cx, ty_native_fn(abi, args, ty));
 }
 
-fn mk_obj(@type_store ts, vec[method] meths) -> t {
-    ret gen_ty(ts, ty_obj(meths));
+fn mk_obj(ctxt cx, vec[method] meths) -> t {
+    ret gen_ty(cx, ty_obj(meths));
 }
 
-fn mk_var(@type_store ts, int v) -> t    {
-    let int i = _vec.len[t](ts.t_vars) as int;
+fn mk_var(ctxt cx, int v) -> t    {
+    let int i = _vec.len[t](cx.ts.t_vars) as int;
     while (i <= v) {
-        ts.t_vars += vec(mk_ty_full(ty_var(i), none[str]));
+        cx.ts.t_vars += vec(mk_ty_full(ty_var(i), none[str]));
         i += 1;
     }
-    ret ts.t_vars.(v);
+    ret cx.ts.t_vars.(v);
 }
 
-fn mk_local(@type_store ts, ast.def_id did) -> t {
-    ret gen_ty(ts, ty_local(did));
+fn mk_local(ctxt cx, ast.def_id did) -> t {
+    ret gen_ty(cx, ty_local(did));
 }
 
-fn mk_param(@type_store ts, uint n) -> t {
-    let uint i = _vec.len[t](ts.t_params);
+fn mk_param(ctxt cx, uint n) -> t {
+    let uint i = _vec.len[t](cx.ts.t_params);
     while (i <= n) {
-        ts.t_params += vec(mk_ty_full(ty_param(i), none[str]));
+        cx.ts.t_params += vec(mk_ty_full(ty_param(i), none[str]));
         i += 1u;
     }
-    ret ts.t_params.(n);
+    ret cx.ts.t_params.(n);
 }
 
-fn mk_bound_param(@type_store ts, uint n) -> t {
-    let uint i = _vec.len[t](ts.t_bound_params);
+fn mk_bound_param(ctxt cx, uint n) -> t {
+    let uint i = _vec.len[t](cx.ts.t_bound_params);
     while (i <= n) {
-        ts.t_bound_params += vec(mk_ty_full(ty_bound_param(i), none[str]));
+        cx.ts.t_bound_params += vec(mk_ty_full(ty_bound_param(i), none[str]));
         i += 1u;
     }
-    ret ts.t_bound_params.(n);
+    ret cx.ts.t_bound_params.(n);
 }
 
-fn mk_type(@type_store ts) -> t          { ret ts.t_type; }
-fn mk_native(@type_store ts) -> t        { ret ts.t_native; }
+fn mk_type(ctxt cx) -> t    { ret cx.ts.t_type; }
+fn mk_native(ctxt cx) -> t  { ret cx.ts.t_native; }
 
 
 // Returns the one-level-deep type structure of the given type.
-fn struct(@type_store tystore, t typ) -> sty { ret typ.struct; }
+fn struct(ctxt cx, t typ) -> sty { ret typ.struct; }
 
 // Returns the canonical name of the given type.
-fn cname(@type_store tystore, t typ) -> option.t[str] { ret typ.cname; }
+fn cname(ctxt cx, t typ) -> option.t[str] { ret typ.cname; }
 
 
 // Stringification
@@ -344,10 +346,9 @@ fn path_to_str(&ast.path pth) -> str {
     ret result;
 }
 
-fn ty_to_str(@type_store ts, &t typ) -> str {
+fn ty_to_str(ctxt cx, &t typ) -> str {
 
-    fn fn_input_to_str(@type_store tystore,
-                       &rec(ast.mode mode, t ty) input) -> str {
+    fn fn_input_to_str(ctxt cx, &rec(ast.mode mode, t ty) input) -> str {
         auto s;
         if (mode_is_alias(input.mode)) {
             s = "&";
@@ -355,14 +356,14 @@ fn ty_to_str(@type_store ts, &t typ) -> str {
             s = "";
         }
 
-        ret s + ty_to_str(tystore, input.ty);
+        ret s + ty_to_str(cx, input.ty);
     }
 
-    fn fn_to_str(@type_store tystore,
+    fn fn_to_str(ctxt cx,
                  ast.proto proto,
                  option.t[ast.ident] ident,
                  vec[arg] inputs, t output) -> str {
-            auto f = bind fn_input_to_str(tystore, _);
+            auto f = bind fn_input_to_str(cx, _);
 
             auto s;
             alt (proto) {
@@ -386,22 +387,22 @@ fn ty_to_str(@type_store ts, &t typ) -> str {
             s += _str.connect(_vec.map[arg,str](f, inputs), ", ");
             s += ")";
 
-            if (struct(tystore, output) != ty_nil) {
-                s += " -> " + ty_to_str(tystore, output);
+            if (struct(cx, output) != ty_nil) {
+                s += " -> " + ty_to_str(cx, output);
             }
             ret s;
     }
 
-    fn method_to_str(@type_store tystore, &method m) -> str {
-        ret fn_to_str(tystore, m.proto, some[ast.ident](m.ident),
+    fn method_to_str(ctxt cx, &method m) -> str {
+        ret fn_to_str(cx, m.proto, some[ast.ident](m.ident),
                       m.inputs, m.output) + ";";
     }
 
-    fn field_to_str(@type_store tystore, &field f) -> str {
-        ret mt_to_str(tystore, f.mt) + " " + f.ident;
+    fn field_to_str(ctxt cx, &field f) -> str {
+        ret mt_to_str(cx, f.mt) + " " + f.ident;
     }
 
-    fn mt_to_str(@type_store tystore, &mt m) -> str {
+    fn mt_to_str(ctxt cx, &mt m) -> str {
         auto mstr;
         alt (m.mut) {
             case (ast.mut)       { mstr = "mutable "; }
@@ -409,11 +410,11 @@ fn ty_to_str(@type_store ts, &t typ) -> str {
             case (ast.maybe_mut) { mstr = "mutable? "; }
         }
 
-        ret mstr + ty_to_str(tystore, m.ty);
+        ret mstr + ty_to_str(cx, m.ty);
     }
 
     auto s = "";
-    alt (struct(ts, typ)) {
+    alt (struct(cx, typ)) {
         case (ty_native)       { s += "native";                         }
         case (ty_nil)          { s += "()";                             }
         case (ty_bool)         { s += "bool";                           }
@@ -423,20 +424,20 @@ fn ty_to_str(@type_store ts, &t typ) -> str {
         case (ty_machine(?tm)) { s += common.ty_mach_to_str(tm);        }
         case (ty_char)         { s += "char";                           }
         case (ty_str)          { s += "str";                            }
-        case (ty_box(?tm))     { s += "@" + mt_to_str(ts, tm);          }
-        case (ty_vec(?tm))     { s += "vec[" + mt_to_str(ts, tm) + "]"; }
-        case (ty_port(?t))     { s += "port[" + ty_to_str(ts, t) + "]"; }
-        case (ty_chan(?t))     { s += "chan[" + ty_to_str(ts, t) + "]"; }
+        case (ty_box(?tm))     { s += "@" + mt_to_str(cx, tm);          }
+        case (ty_vec(?tm))     { s += "vec[" + mt_to_str(cx, tm) + "]"; }
+        case (ty_port(?t))     { s += "port[" + ty_to_str(cx, t) + "]"; }
+        case (ty_chan(?t))     { s += "chan[" + ty_to_str(cx, t) + "]"; }
         case (ty_type)         { s += "type";                           }
 
         case (ty_tup(?elems)) {
-            auto f = bind mt_to_str(ts, _);
+            auto f = bind mt_to_str(cx, _);
             auto strs = _vec.map[mt,str](f, elems);
             s += "tup(" + _str.connect(strs, ",") + ")";
         }
 
         case (ty_rec(?elems)) {
-            auto f = bind field_to_str(ts, _);
+            auto f = bind field_to_str(cx, _);
             auto strs = _vec.map[field,str](f, elems);
             s += "rec(" + _str.connect(strs, ",") + ")";
         }
@@ -446,27 +447,27 @@ fn ty_to_str(@type_store ts, &t typ) -> str {
             s += "<tag#" + util.common.istr(id._0) + ":" +
                 util.common.istr(id._1) + ">";
             if (_vec.len[t](tps) > 0u) {
-                auto f = bind ty_to_str(ts, _);
+                auto f = bind ty_to_str(cx, _);
                 auto strs = _vec.map[t,str](f, tps);
                 s += "[" + _str.connect(strs, ",") + "]";
             }
         }
 
         case (ty_fn(?proto, ?inputs, ?output)) {
-            s += fn_to_str(ts, proto, none[ast.ident], inputs, output);
+            s += fn_to_str(cx, proto, none[ast.ident], inputs, output);
         }
 
         case (ty_native_fn(_, ?inputs, ?output)) {
-            s += fn_to_str(ts, ast.proto_fn, none[ast.ident], inputs, output);
+            s += fn_to_str(cx, ast.proto_fn, none[ast.ident], inputs, output);
         }
 
         case (ty_obj(?meths)) {
-            alt (cname(ts, typ)) {
+            alt (cname(cx, typ)) {
                 case (some[str](?cs)) {
                     s += cs;
                 }
                 case (_) {
-                    auto f = bind method_to_str(ts, _);
+                    auto f = bind method_to_str(cx, _);
                     auto m = _vec.map[method,str](f, meths);
                     s += "obj {\n\t" + _str.connect(m, "\n\t") + "\n}";
                 }
@@ -498,8 +499,8 @@ fn ty_to_str(@type_store ts, &t typ) -> str {
 
 type ty_walk = fn(t);
 
-fn walk_ty(@type_store tystore, ty_walk walker, t ty) {
-    alt (struct(tystore, ty)) {
+fn walk_ty(ctxt cx, ty_walk walker, t ty) {
+    alt (struct(cx, ty)) {
         case (ty_nil)           { /* no-op */ }
         case (ty_bool)          { /* no-op */ }
         case (ty_int)           { /* no-op */ }
@@ -510,44 +511,44 @@ fn walk_ty(@type_store tystore, ty_walk walker, t ty) {
         case (ty_str)           { /* no-op */ }
         case (ty_type)          { /* no-op */ }
         case (ty_native)        { /* no-op */ }
-        case (ty_box(?tm))      { walk_ty(tystore, walker, tm.ty); }
-        case (ty_vec(?tm))      { walk_ty(tystore, walker, tm.ty); }
-        case (ty_port(?subty))  { walk_ty(tystore, walker, subty); }
-        case (ty_chan(?subty))  { walk_ty(tystore, walker, subty); }
+        case (ty_box(?tm))      { walk_ty(cx, walker, tm.ty); }
+        case (ty_vec(?tm))      { walk_ty(cx, walker, tm.ty); }
+        case (ty_port(?subty))  { walk_ty(cx, walker, subty); }
+        case (ty_chan(?subty))  { walk_ty(cx, walker, subty); }
         case (ty_tag(?tid, ?subtys)) {
             for (t subty in subtys) {
-                walk_ty(tystore, walker, subty);
+                walk_ty(cx, walker, subty);
             }
         }
         case (ty_tup(?mts)) {
             for (mt tm in mts) {
-                walk_ty(tystore, walker, tm.ty);
+                walk_ty(cx, walker, tm.ty);
             }
         }
         case (ty_rec(?fields)) {
             for (field fl in fields) {
-                walk_ty(tystore, walker, fl.mt.ty);
+                walk_ty(cx, walker, fl.mt.ty);
             }
         }
         case (ty_fn(?proto, ?args, ?ret_ty)) {
             for (arg a in args) {
-                walk_ty(tystore, walker, a.ty);
+                walk_ty(cx, walker, a.ty);
             }
-            walk_ty(tystore, walker, ret_ty);
+            walk_ty(cx, walker, ret_ty);
         }
         case (ty_native_fn(?abi, ?args, ?ret_ty)) {
             for (arg a in args) {
-                walk_ty(tystore, walker, a.ty);
+                walk_ty(cx, walker, a.ty);
             }
-            walk_ty(tystore, walker, ret_ty);
+            walk_ty(cx, walker, ret_ty);
         }
         case (ty_obj(?methods)) {
             let vec[method] new_methods = vec();
             for (method m in methods) {
                 for (arg a in m.inputs) {
-                    walk_ty(tystore, walker, a.ty);
+                    walk_ty(cx, walker, a.ty);
                 }
-                walk_ty(tystore, walker, m.output);
+                walk_ty(cx, walker, m.output);
             }
         }
         case (ty_var(_))         { /* no-op */ }
@@ -561,9 +562,9 @@ fn walk_ty(@type_store tystore, ty_walk walker, t ty) {
 
 type ty_fold = fn(t) -> t;
 
-fn fold_ty(@type_store tystore, ty_fold fld, t ty_0) -> t {
+fn fold_ty(ctxt cx, ty_fold fld, t ty_0) -> t {
     auto ty = ty_0;
-    alt (struct(tystore, ty)) {
+    alt (struct(cx, ty)) {
         case (ty_nil)           { /* no-op */ }
         case (ty_bool)          { /* no-op */ }
         case (ty_int)           { /* no-op */ }
@@ -575,67 +576,60 @@ fn fold_ty(@type_store tystore, ty_fold fld, t ty_0) -> t {
         case (ty_type)          { /* no-op */ }
         case (ty_native)        { /* no-op */ }
         case (ty_box(?tm)) {
-            ty = copy_cname(tystore,
-                            mk_box(tystore,
-                                   rec(ty=fold_ty(tystore, fld, tm.ty),
-                                       mut=tm.mut)), ty);
+            ty = copy_cname(cx, mk_box(cx, rec(ty=fold_ty(cx, fld, tm.ty),
+                                               mut=tm.mut)), ty);
         }
         case (ty_vec(?tm)) {
-            ty = copy_cname(tystore,
-                mk_vec(tystore, rec(ty=fold_ty(tystore, fld, tm.ty),
-                                    mut=tm.mut)), ty);
+            ty = copy_cname(cx, mk_vec(cx, rec(ty=fold_ty(cx, fld, tm.ty),
+                                                          mut=tm.mut)), ty);
         }
         case (ty_port(?subty)) {
-            ty = copy_cname(tystore,
-                mk_port(tystore, fold_ty(tystore, fld, subty)), ty);
+            ty = copy_cname(cx, mk_port(cx, fold_ty(cx, fld, subty)), ty);
         }
         case (ty_chan(?subty)) {
-            ty = copy_cname(tystore,
-                mk_chan(tystore, fold_ty(tystore, fld, subty)), ty);
+            ty = copy_cname(cx, mk_chan(cx, fold_ty(cx, fld, subty)), ty);
         }
         case (ty_tag(?tid, ?subtys)) {
             let vec[t] new_subtys = vec();
             for (t subty in subtys) {
-                new_subtys += vec(fold_ty(tystore, fld, subty));
+                new_subtys += vec(fold_ty(cx, fld, subty));
             }
-            ty = copy_cname(tystore, mk_tag(tystore, tid, new_subtys), ty);
+            ty = copy_cname(cx, mk_tag(cx, tid, new_subtys), ty);
         }
         case (ty_tup(?mts)) {
             let vec[mt] new_mts = vec();
             for (mt tm in mts) {
-                auto new_subty = fold_ty(tystore, fld, tm.ty);
+                auto new_subty = fold_ty(cx, fld, tm.ty);
                 new_mts += vec(rec(ty=new_subty, mut=tm.mut));
             }
-            ty = copy_cname(tystore, mk_tup(tystore, new_mts), ty);
+            ty = copy_cname(cx, mk_tup(cx, new_mts), ty);
         }
         case (ty_rec(?fields)) {
             let vec[field] new_fields = vec();
             for (field fl in fields) {
-                auto new_ty = fold_ty(tystore, fld, fl.mt.ty);
+                auto new_ty = fold_ty(cx, fld, fl.mt.ty);
                 auto new_mt = rec(ty=new_ty, mut=fl.mt.mut);
                 new_fields += vec(rec(ident=fl.ident, mt=new_mt));
             }
-            ty = copy_cname(tystore, mk_rec(tystore, new_fields), ty);
+            ty = copy_cname(cx, mk_rec(cx, new_fields), ty);
         }
         case (ty_fn(?proto, ?args, ?ret_ty)) {
             let vec[arg] new_args = vec();
             for (arg a in args) {
-                auto new_ty = fold_ty(tystore, fld, a.ty);
+                auto new_ty = fold_ty(cx, fld, a.ty);
                 new_args += vec(rec(mode=a.mode, ty=new_ty));
             }
-            ty = copy_cname(tystore, mk_fn(tystore, proto, new_args,
-                                  fold_ty(tystore, fld, ret_ty)),
-                            ty);
+            ty = copy_cname(cx, mk_fn(cx, proto, new_args,
+                                      fold_ty(cx, fld, ret_ty)), ty);
         }
         case (ty_native_fn(?abi, ?args, ?ret_ty)) {
             let vec[arg] new_args = vec();
             for (arg a in args) {
-                auto new_ty = fold_ty(tystore, fld, a.ty);
+                auto new_ty = fold_ty(cx, fld, a.ty);
                 new_args += vec(rec(mode=a.mode, ty=new_ty));
             }
-            ty = copy_cname(tystore, mk_native_fn(tystore, abi, new_args,
-                                         fold_ty(tystore, fld, ret_ty)),
-                            ty);
+            ty = copy_cname(cx, mk_native_fn(cx, abi, new_args,
+                                             fold_ty(cx, fld, ret_ty)), ty);
         }
         case (ty_obj(?methods)) {
             let vec[method] new_methods = vec();
@@ -643,14 +637,13 @@ fn fold_ty(@type_store tystore, ty_fold fld, t ty_0) -> t {
                 let vec[arg] new_args = vec();
                 for (arg a in m.inputs) {
                     new_args += vec(rec(mode=a.mode,
-                                        ty=fold_ty(tystore, fld, a.ty)));
+                                        ty=fold_ty(cx, fld, a.ty)));
                 }
                 new_methods += vec(rec(proto=m.proto, ident=m.ident,
                                        inputs=new_args,
-                                       output=fold_ty(tystore, fld,
-                                                      m.output)));
+                                       output=fold_ty(cx, fld, m.output)));
             }
-            ty = copy_cname(tystore, mk_obj(tystore, new_methods), ty);
+            ty = copy_cname(cx, mk_obj(cx, new_methods), ty);
         }
         case (ty_var(_))         { /* no-op */ }
         case (ty_local(_))       { /* no-op */ }
@@ -663,14 +656,14 @@ fn fold_ty(@type_store tystore, ty_fold fld, t ty_0) -> t {
 
 // Type utilities
 
-fn rename(@type_store tystore, t typ, str new_cname) -> t {
-    ret gen_ty_full(tystore, struct(tystore, typ), some[str](new_cname));
+fn rename(ctxt cx, t typ, str new_cname) -> t {
+    ret gen_ty_full(cx, struct(cx, typ), some[str](new_cname));
 }
 
 // Returns a type with the structural part taken from `struct_ty` and the
 // canonical name from `cname_ty`.
-fn copy_cname(@type_store tystore, t struct_ty, t cname_ty) -> t {
-    ret gen_ty_full(tystore, struct(tystore, struct_ty), cname_ty.cname);
+fn copy_cname(ctxt cx, t struct_ty, t cname_ty) -> t {
+    ret gen_ty_full(cx, struct(cx, struct_ty), cname_ty.cname);
 }
 
 // FIXME: remove me when == works on these tags.
@@ -682,24 +675,24 @@ fn mode_is_alias(ast.mode m) -> bool {
     fail;
 }
 
-fn type_is_nil(@type_store tystore, t ty) -> bool {
-    alt (struct(tystore, ty)) {
+fn type_is_nil(ctxt cx, t ty) -> bool {
+    alt (struct(cx, ty)) {
         case (ty_nil) { ret true; }
         case (_) { ret false; }
     }
     fail;
 }
 
-fn type_is_bool(@type_store tystore, t ty) -> bool {
-    alt (struct(tystore, ty)) {
+fn type_is_bool(ctxt cx, t ty) -> bool {
+    alt (struct(cx, ty)) {
         case (ty_bool) { ret true; }
         case (_) { ret false; }
     }
 }
 
 
-fn type_is_structural(@type_store tystore, t ty) -> bool {
-    alt (struct(tystore, ty)) {
+fn type_is_structural(ctxt cx, t ty) -> bool {
+    alt (struct(cx, ty)) {
         case (ty_tup(_))    { ret true; }
         case (ty_rec(_))    { ret true; }
         case (ty_tag(_,_))  { ret true; }
@@ -710,8 +703,8 @@ fn type_is_structural(@type_store tystore, t ty) -> bool {
     fail;
 }
 
-fn type_is_sequence(@type_store tystore, t ty) -> bool {
-    alt (struct(tystore, ty)) {
+fn type_is_sequence(ctxt cx, t ty) -> bool {
+    alt (struct(cx, ty)) {
         case (ty_str)    { ret true; }
         case (ty_vec(_))    { ret true; }
         case (_)            { ret false; }
@@ -719,17 +712,17 @@ fn type_is_sequence(@type_store tystore, t ty) -> bool {
     fail;
 }
 
-fn sequence_element_type(@type_store tystore, t ty) -> t {
-    alt (struct(tystore, ty)) {
-        case (ty_str)      { ret mk_mach(tystore, common.ty_u8); }
+fn sequence_element_type(ctxt cx, t ty) -> t {
+    alt (struct(cx, ty)) {
+        case (ty_str)      { ret mk_mach(cx, common.ty_u8); }
         case (ty_vec(?mt)) { ret mt.ty; }
     }
     fail;
 }
 
 
-fn type_is_tup_like(@type_store tystore, t ty) -> bool {
-    alt (struct(tystore, ty)) {
+fn type_is_tup_like(ctxt cx, t ty) -> bool {
+    alt (struct(cx, ty)) {
         case (ty_box(_))    { ret true; }
         case (ty_tup(_))    { ret true; }
         case (ty_rec(_))    { ret true; }
@@ -739,9 +732,9 @@ fn type_is_tup_like(@type_store tystore, t ty) -> bool {
     fail;
 }
 
-fn get_element_type(@type_store tystore, t ty, uint i) -> t {
-    check (type_is_tup_like(tystore, ty));
-    alt (struct(tystore, ty)) {
+fn get_element_type(ctxt cx, t ty, uint i) -> t {
+    check (type_is_tup_like(cx, ty));
+    alt (struct(cx, ty)) {
         case (ty_tup(?mts)) {
             ret mts.(i).ty;
         }
@@ -752,16 +745,16 @@ fn get_element_type(@type_store tystore, t ty, uint i) -> t {
     fail;
 }
 
-fn type_is_box(@type_store tystore, t ty) -> bool {
-    alt (struct(tystore, ty)) {
+fn type_is_box(ctxt cx, t ty) -> bool {
+    alt (struct(cx, ty)) {
         case (ty_box(_)) { ret true; }
         case (_) { ret false; }
     }
     fail;
 }
 
-fn type_is_boxed(@type_store tystore, t ty) -> bool {
-    alt (struct(tystore, ty)) {
+fn type_is_boxed(ctxt cx, t ty) -> bool {
+    alt (struct(cx, ty)) {
         case (ty_str) { ret true; }
         case (ty_vec(_)) { ret true; }
         case (ty_box(_)) { ret true; }
@@ -772,8 +765,8 @@ fn type_is_boxed(@type_store tystore, t ty) -> bool {
     fail;
 }
 
-fn type_is_scalar(@type_store tystore, t ty) -> bool {
-    alt (struct(tystore, ty)) {
+fn type_is_scalar(ctxt cx, t ty) -> bool {
+    alt (struct(cx, ty)) {
         case (ty_nil) { ret true; }
         case (ty_bool) { ret true; }
         case (ty_int) { ret true; }
@@ -790,27 +783,27 @@ fn type_is_scalar(@type_store tystore, t ty) -> bool {
 
 // FIXME: should we just return true for native types in
 // type_is_scalar?
-fn type_is_native(@type_store tystore, t ty) -> bool {
-    alt (struct(tystore, ty)) {
+fn type_is_native(ctxt cx, t ty) -> bool {
+    alt (struct(cx, ty)) {
         case (ty_native) { ret true; }
         case (_) { ret false; }
     }
     fail;
 }
 
-fn type_has_dynamic_size(@type_store tystore, t ty) -> bool {
-    alt (struct(tystore, ty)) {
+fn type_has_dynamic_size(ctxt cx, t ty) -> bool {
+    alt (struct(cx, ty)) {
         case (ty_tup(?mts)) {
             auto i = 0u;
             while (i < _vec.len[mt](mts)) {
-                if (type_has_dynamic_size(tystore, mts.(i).ty)) { ret true; }
+                if (type_has_dynamic_size(cx, mts.(i).ty)) { ret true; }
                 i += 1u;
             }
         }
         case (ty_rec(?fields)) {
             auto i = 0u;
             while (i < _vec.len[field](fields)) {
-                if (type_has_dynamic_size(tystore, fields.(i).mt.ty)) {
+                if (type_has_dynamic_size(cx, fields.(i).mt.ty)) {
                     ret true;
                 }
                 i += 1u;
@@ -819,7 +812,7 @@ fn type_has_dynamic_size(@type_store tystore, t ty) -> bool {
         case (ty_tag(_, ?subtys)) {
             auto i = 0u;
             while (i < _vec.len[t](subtys)) {
-                if (type_has_dynamic_size(tystore, subtys.(i))) { ret true; }
+                if (type_has_dynamic_size(cx, subtys.(i))) { ret true; }
                 i += 1u;
             }
         }
@@ -829,8 +822,8 @@ fn type_has_dynamic_size(@type_store tystore, t ty) -> bool {
     ret false;
 }
 
-fn type_is_integral(@type_store tystore, t ty) -> bool {
-    alt (struct(tystore, ty)) {
+fn type_is_integral(ctxt cx, t ty) -> bool {
+    alt (struct(cx, ty)) {
         case (ty_int) { ret true; }
         case (ty_uint) { ret true; }
         case (ty_machine(?m)) {
@@ -853,8 +846,8 @@ fn type_is_integral(@type_store tystore, t ty) -> bool {
     fail;
 }
 
-fn type_is_fp(@type_store tystore, t ty) -> bool {
-    alt (struct(tystore, ty)) {
+fn type_is_fp(ctxt cx, t ty) -> bool {
+    alt (struct(cx, ty)) {
         case (ty_machine(?tm)) {
             alt (tm) {
                 case (common.ty_f32) { ret true; }
@@ -870,8 +863,8 @@ fn type_is_fp(@type_store tystore, t ty) -> bool {
     fail;
 }
 
-fn type_is_signed(@type_store tystore, t ty) -> bool {
-    alt (struct(tystore, ty)) {
+fn type_is_signed(ctxt cx, t ty) -> bool {
+    alt (struct(cx, ty)) {
         case (ty_int) { ret true; }
         case (ty_machine(?tm)) {
             alt (tm) {
@@ -887,8 +880,8 @@ fn type_is_signed(@type_store tystore, t ty) -> bool {
     fail;
 }
 
-fn type_param(@type_store tystore, t ty) -> option.t[uint] {
-    alt (struct(tystore, ty)) {
+fn type_param(ctxt cx, t ty) -> option.t[uint] {
+    alt (struct(cx, ty)) {
         case (ty_param(?id)) { ret some[uint](id); }
         case (_)             { /* fall through */  }
     }
@@ -1436,7 +1429,7 @@ fn ann_to_type_params(&ast.ann ann) -> vec[t] {
 
 // Returns the type of an annotation, with type parameter substitutions
 // performed if applicable.
-fn ann_to_monotype(@type_store tystore, ast.ann a) -> t {
+fn ann_to_monotype(ctxt cx, ast.ann a) -> t {
     // TODO: Refactor to use recursive pattern matching when we're more
     // confident that it works.
     alt (a) {
@@ -1448,7 +1441,7 @@ fn ann_to_monotype(@type_store tystore, ast.ann a) -> t {
             alt (tps_opt) {
                 case (none[vec[t]]) { ret typ; }
                 case (some[vec[t]](?tps)) {
-                    ret substitute_type_params(tystore, tps, typ);
+                    ret substitute_type_params(cx, tps, typ);
                 }
             }
         }
@@ -1461,9 +1454,9 @@ fn triv_ann(t typ) -> ast.ann {
 }
 
 // Returns the number of distinct type parameters in the given type.
-fn count_ty_params(@type_store tystore, t ty) -> uint {
-    fn counter(@type_store tystore, @mutable vec[uint] param_indices, t ty) {
-        alt (struct(tystore, ty)) {
+fn count_ty_params(ctxt cx, t ty) -> uint {
+    fn counter(ctxt cx, @mutable vec[uint] param_indices, t ty) {
+        alt (struct(cx, ty)) {
             case (ty_param(?param_idx)) {
                 auto seen = false;
                 for (uint other_param_idx in *param_indices) {
@@ -1481,87 +1474,87 @@ fn count_ty_params(@type_store tystore, t ty) -> uint {
 
     let vec[uint] v = vec();    // FIXME: typechecker botch
     let @mutable vec[uint] param_indices = @mutable v;
-    auto f = bind counter(tystore, param_indices, _);
-    walk_ty(tystore, f, ty);
+    auto f = bind counter(cx, param_indices, _);
+    walk_ty(cx, f, ty);
     ret _vec.len[uint](*param_indices);
 }
 
-fn type_contains_vars(@type_store tystore, t typ) -> bool {
-    fn checker(@type_store tystore, @mutable bool flag, t typ) {
-        alt (struct(tystore, typ)) {
+fn type_contains_vars(ctxt cx, t typ) -> bool {
+    fn checker(ctxt cx, @mutable bool flag, t typ) {
+        alt (struct(cx, typ)) {
             case (ty_var(_)) { *flag = true; }
             case (_) { /* fall through */ }
         }
     }
 
     let @mutable bool flag = @mutable false;
-    auto f = bind checker(tystore, flag, _);
-    walk_ty(tystore, f, typ);
+    auto f = bind checker(cx, flag, _);
+    walk_ty(cx, f, typ);
     ret *flag;
 }
 
-fn type_contains_params(@type_store tystore, t typ) -> bool {
-    fn checker(@type_store tystore, @mutable bool flag, t typ) {
-        alt (struct(tystore, typ)) {
+fn type_contains_params(ctxt cx, t typ) -> bool {
+    fn checker(ctxt cx, @mutable bool flag, t typ) {
+        alt (struct(cx, typ)) {
             case (ty_param(_)) { *flag = true; }
             case (_) { /* fall through */ }
         }
     }
 
     let @mutable bool flag = @mutable false;
-    auto f = bind checker(tystore, flag, _);
-    walk_ty(tystore, f, typ);
+    auto f = bind checker(cx, flag, _);
+    walk_ty(cx, f, typ);
     ret *flag;
 }
 
-fn type_contains_bound_params(@type_store tystore, t typ) -> bool {
-    fn checker(@type_store tystore, @mutable bool flag, t typ) {
-        alt (struct(tystore, typ)) {
+fn type_contains_bound_params(ctxt cx, t typ) -> bool {
+    fn checker(ctxt cx, @mutable bool flag, t typ) {
+        alt (struct(cx, typ)) {
             case (ty_bound_param(_)) { *flag = true; }
             case (_) { /* fall through */ }
         }
     }
 
     let @mutable bool flag = @mutable false;
-    auto f = bind checker(tystore, flag, _);
-    walk_ty(tystore, f, typ);
+    auto f = bind checker(cx, flag, _);
+    walk_ty(cx, f, typ);
     ret *flag;
 }
 
 // Type accessors for substructures of types
 
-fn ty_fn_args(@type_store tystore, t fty) -> vec[arg] {
-    alt (struct(tystore, fty)) {
+fn ty_fn_args(ctxt cx, t fty) -> vec[arg] {
+    alt (struct(cx, fty)) {
         case (ty.ty_fn(_, ?a, _)) { ret a; }
         case (ty.ty_native_fn(_, ?a, _)) { ret a; }
     }
     fail;
 }
 
-fn ty_fn_proto(@type_store tystore, t fty) -> ast.proto {
-    alt (struct(tystore, fty)) {
+fn ty_fn_proto(ctxt cx, t fty) -> ast.proto {
+    alt (struct(cx, fty)) {
         case (ty.ty_fn(?p, _, _)) { ret p; }
     }
     fail;
 }
 
-fn ty_fn_abi(@type_store tystore, t fty) -> ast.native_abi {
-    alt (struct(tystore, fty)) {
+fn ty_fn_abi(ctxt cx, t fty) -> ast.native_abi {
+    alt (struct(cx, fty)) {
         case (ty.ty_native_fn(?a, _, _)) { ret a; }
     }
     fail;
 }
 
-fn ty_fn_ret(@type_store tystore, t fty) -> t {
-    alt (struct(tystore, fty)) {
+fn ty_fn_ret(ctxt cx, t fty) -> t {
+    alt (struct(cx, fty)) {
         case (ty.ty_fn(_, _, ?r)) { ret r; }
         case (ty.ty_native_fn(_, _, ?r)) { ret r; }
     }
     fail;
 }
 
-fn is_fn_ty(@type_store tystore, t fty) -> bool {
-    alt (struct(tystore, fty)) {
+fn is_fn_ty(ctxt cx, t fty) -> bool {
+    alt (struct(cx, fty)) {
         case (ty.ty_fn(_, _, _)) { ret true; }
         case (ty.ty_native_fn(_, _, _)) { ret true; }
         case (_) { ret false; }
@@ -1618,32 +1611,32 @@ fn item_ty(@ast.item it) -> ty_param_count_and_ty {
     ret tup(ty_param_count, result_ty);
 }
 
-fn stmt_ty(@type_store tystore, @ast.stmt s) -> t {
+fn stmt_ty(ctxt cx, @ast.stmt s) -> t {
     alt (s.node) {
         case (ast.stmt_expr(?e,_)) {
-            ret expr_ty(tystore, e);
+            ret expr_ty(cx, e);
         }
         case (_) {
-            ret mk_nil(tystore);
+            ret mk_nil(cx);
         }
     }
 }
 
-fn block_ty(@type_store tystore, &ast.block b) -> t {
+fn block_ty(ctxt cx, &ast.block b) -> t {
     alt (b.node.expr) {
-        case (some[@ast.expr](?e)) { ret expr_ty(tystore, e); }
-        case (none[@ast.expr])     { ret mk_nil(tystore); }
+        case (some[@ast.expr](?e)) { ret expr_ty(cx, e); }
+        case (none[@ast.expr])     { ret mk_nil(cx); }
     }
 }
 
 // Returns the type of a pattern as a monotype. Like @expr_ty, this function
 // doesn't provide type parameter substitutions.
-fn pat_ty(@type_store ts, @ast.pat pat) -> t {
+fn pat_ty(ctxt cx, @ast.pat pat) -> t {
     alt (pat.node) {
-        case (ast.pat_wild(?ann))           { ret ann_to_monotype(ts, ann); }
-        case (ast.pat_lit(_, ?ann))         { ret ann_to_monotype(ts, ann); }
-        case (ast.pat_bind(_, _, ?ann))     { ret ann_to_monotype(ts, ann); }
-        case (ast.pat_tag(_, _, _, ?ann))   { ret ann_to_monotype(ts, ann); }
+        case (ast.pat_wild(?ann))           { ret ann_to_monotype(cx, ann); }
+        case (ast.pat_lit(_, ?ann))         { ret ann_to_monotype(cx, ann); }
+        case (ast.pat_bind(_, _, ?ann))     { ret ann_to_monotype(cx, ann); }
+        case (ast.pat_tag(_, _, _, ?ann))   { ret ann_to_monotype(cx, ann); }
     }
     fail;   // not reached
 }
@@ -1700,19 +1693,18 @@ fn expr_ann(@ast.expr expr) -> option.t[ast.ann] {
 // ask for the type of "id" in "id(3)", it will return "fn(&int) -> int"
 // instead of "fn(&T) -> T with T = int". If this isn't what you want, see
 // expr_ty_params_and_ty() below.
-fn expr_ty(@type_store tystore, @ast.expr expr) -> t {
+fn expr_ty(ctxt cx, @ast.expr expr) -> t {
     alt (expr_ann(expr)) {
-        case (none[ast.ann])     { ret mk_nil(tystore); }
-        case (some[ast.ann](?a)) { ret ann_to_monotype(tystore, a); }
+        case (none[ast.ann])     { ret mk_nil(cx); }
+        case (some[ast.ann](?a)) { ret ann_to_monotype(cx, a); }
     }
 }
 
-fn expr_ty_params_and_ty(@type_store tystore, @ast.expr expr)
-        -> tup(vec[t], t) {
+fn expr_ty_params_and_ty(ctxt cx, @ast.expr expr) -> tup(vec[t], t) {
     alt (expr_ann(expr)) {
         case (none[ast.ann]) {
             let vec[t] tps = vec();
-            ret tup(tps, mk_nil(tystore));
+            ret tup(tps, mk_nil(cx));
         }
         case (some[ast.ann](?a)) {
             ret tup(ann_to_type_params(a), ann_to_type(a));
@@ -1863,7 +1855,7 @@ mod Unify {
                     hashmap[int,uint] var_ids,
                     mutable vec[mutable vec[t]] types,
                     unify_handler handler,
-                    @type_store tystore);
+                    ty_ctxt tcx);
 
     // Wraps the given type in an appropriate cname.
     //
@@ -1874,7 +1866,7 @@ mod Unify {
 
     // Simple structural type comparison.
     fn struct_cmp(@ctxt cx, t expected, t actual) -> result {
-        if (struct(cx.tystore, expected) == struct(cx.tystore, actual)) {
+        if (struct(cx.tcx, expected) == struct(cx.tcx, actual)) {
             ret ures_ok(expected);
         }
 
@@ -1978,7 +1970,7 @@ mod Unify {
                 ret r;
             }
             case (fn_common_res_ok(?result_ins, ?result_out)) {
-                auto t2 = mk_fn(cx.tystore, e_proto, result_ins, result_out);
+                auto t2 = mk_fn(cx.tcx, e_proto, result_ins, result_out);
                 ret ures_ok(t2);
             }
         }
@@ -2004,7 +1996,7 @@ mod Unify {
                 ret r;
             }
             case (fn_common_res_ok(?result_ins, ?result_out)) {
-                auto t2 = mk_native_fn(cx.tystore, e_abi, result_ins,
+                auto t2 = mk_native_fn(cx.tcx, e_abi, result_ins,
                                        result_out);
                 ret ures_ok(t2);
             }
@@ -2039,7 +2031,7 @@ mod Unify {
                           a_meth.inputs, a_meth.output);
         alt (r) {
             case (ures_ok(?tfn)) {
-                alt (struct(cx.tystore, tfn)) {
+                alt (struct(cx.tcx, tfn)) {
                     case (ty_fn(?proto, ?ins, ?out)) {
                         result_meths += vec(rec(inputs = ins,
                                                 output = out
@@ -2053,7 +2045,7 @@ mod Unify {
         }
         i += 1u;
       }
-      auto t = mk_obj(cx.tystore, result_meths);
+      auto t = mk_obj(cx.tcx, result_meths);
       ret ures_ok(t);
     }
 
@@ -2079,12 +2071,12 @@ mod Unify {
         // Fast path.
         if (eq_ty(expected, actual)) { ret ures_ok(expected); }
 
-        alt (struct(cx.tystore, actual)) {
+        alt (struct(cx.tcx, actual)) {
             // If the RHS is a variable type, then just do the appropriate
             // binding.
             case (ty.ty_var(?actual_id)) {
                 auto actual_n = get_or_create_set(cx, actual_id);
-                alt (struct(cx.tystore, expected)) {
+                alt (struct(cx.tcx, expected)) {
                     case (ty.ty_var(?expected_id)) {
                         auto expected_n = get_or_create_set(cx, expected_id);
                         UFind.union(cx.sets, expected_n, actual_n);
@@ -2120,7 +2112,7 @@ mod Unify {
                 ret ures_ok(result_ty);
             }
             case (ty.ty_bound_param(?actual_id)) {
-                alt (struct(cx.tystore, expected)) {
+                alt (struct(cx.tcx, expected)) {
                     case (ty.ty_local(_)) {
                         log_err "TODO: bound param unifying with local";
                         fail;
@@ -2134,7 +2126,7 @@ mod Unify {
             case (_) { /* empty */ }
         }
 
-        alt (struct(cx.tystore, expected)) {
+        alt (struct(cx.tcx, expected)) {
             case (ty.ty_nil)        { ret struct_cmp(cx, expected, actual); }
             case (ty.ty_bool)       { ret struct_cmp(cx, expected, actual); }
             case (ty.ty_int)        { ret struct_cmp(cx, expected, actual); }
@@ -2148,7 +2140,7 @@ mod Unify {
             case (ty.ty_param(_))   { ret struct_cmp(cx, expected, actual); }
 
             case (ty.ty_tag(?expected_id, ?expected_tps)) {
-                alt (struct(cx.tystore, actual)) {
+                alt (struct(cx.tcx, actual)) {
                     case (ty.ty_tag(?actual_id, ?actual_tps)) {
                         if (expected_id._0 != actual_id._0 ||
                                 expected_id._1 != actual_id._1) {
@@ -2180,8 +2172,7 @@ mod Unify {
                             i += 1u;
                         }
 
-                        ret ures_ok(mk_tag(cx.tystore, expected_id,
-                                           result_tps));
+                        ret ures_ok(mk_tag(cx.tcx, expected_id, result_tps));
                     }
                     case (_) { /* fall through */ }
                 }
@@ -2190,7 +2181,7 @@ mod Unify {
             }
 
             case (ty.ty_box(?expected_mt)) {
-                alt (struct(cx.tystore, actual)) {
+                alt (struct(cx.tcx, actual)) {
                     case (ty.ty_box(?actual_mt)) {
                         auto mut;
                         alt (unify_mut(expected_mt.mut, actual_mt.mut)) {
@@ -2207,7 +2198,7 @@ mod Unify {
                         alt (result) {
                             case (ures_ok(?result_sub)) {
                                 auto mt = rec(ty=result_sub, mut=mut);
-                                ret ures_ok(mk_box(cx.tystore, mt));
+                                ret ures_ok(mk_box(cx.tcx, mt));
                             }
                             case (_) {
                                 ret result;
@@ -2222,7 +2213,7 @@ mod Unify {
             }
 
             case (ty.ty_vec(?expected_mt)) {
-                alt (struct(cx.tystore, actual)) {
+                alt (struct(cx.tcx, actual)) {
                     case (ty.ty_vec(?actual_mt)) {
                         auto mut;
                         alt (unify_mut(expected_mt.mut, actual_mt.mut)) {
@@ -2239,7 +2230,7 @@ mod Unify {
                         alt (result) {
                             case (ures_ok(?result_sub)) {
                                 auto mt = rec(ty=result_sub, mut=mut);
-                                ret ures_ok(mk_vec(cx.tystore, mt));
+                                ret ures_ok(mk_vec(cx.tcx, mt));
                             }
                             case (_) {
                                 ret result;
@@ -2254,14 +2245,14 @@ mod Unify {
             }
 
             case (ty.ty_port(?expected_sub)) {
-                alt (struct(cx.tystore, actual)) {
+                alt (struct(cx.tcx, actual)) {
                     case (ty.ty_port(?actual_sub)) {
                         auto result = unify_step(cx,
                                                  expected_sub,
                                                  actual_sub);
                         alt (result) {
                             case (ures_ok(?result_sub)) {
-                                ret ures_ok(mk_port(cx.tystore, result_sub));
+                                ret ures_ok(mk_port(cx.tcx, result_sub));
                             }
                             case (_) {
                                 ret result;
@@ -2276,14 +2267,14 @@ mod Unify {
             }
 
             case (ty.ty_chan(?expected_sub)) {
-                alt (struct(cx.tystore, actual)) {
+                alt (struct(cx.tcx, actual)) {
                     case (ty.ty_chan(?actual_sub)) {
                         auto result = unify_step(cx,
                                                  expected_sub,
                                                  actual_sub);
                         alt (result) {
                             case (ures_ok(?result_sub)) {
-                                ret ures_ok(mk_chan(cx.tystore, result_sub));
+                                ret ures_ok(mk_chan(cx.tcx, result_sub));
                             }
                             case (_) {
                                 ret result;
@@ -2298,7 +2289,7 @@ mod Unify {
             }
 
             case (ty.ty_tup(?expected_elems)) {
-                alt (struct(cx.tystore, actual)) {
+                alt (struct(cx.tcx, actual)) {
                     case (ty.ty_tup(?actual_elems)) {
                         auto expected_len = _vec.len[ty.mt](expected_elems);
                         auto actual_len = _vec.len[ty.mt](actual_elems);
@@ -2342,7 +2333,7 @@ mod Unify {
                             i += 1u;
                         }
 
-                        ret ures_ok(mk_tup(cx.tystore, result_elems));
+                        ret ures_ok(mk_tup(cx.tcx, result_elems));
                     }
 
                     case (_) {
@@ -2352,7 +2343,7 @@ mod Unify {
             }
 
             case (ty.ty_rec(?expected_fields)) {
-                alt (struct(cx.tystore, actual)) {
+                alt (struct(cx.tcx, actual)) {
                     case (ty.ty_rec(?actual_fields)) {
                         auto expected_len = _vec.len[field](expected_fields);
                         auto actual_len = _vec.len[field](actual_fields);
@@ -2406,7 +2397,7 @@ mod Unify {
                             i += 1u;
                         }
 
-                        ret ures_ok(mk_rec(cx.tystore, result_fields));
+                        ret ures_ok(mk_rec(cx.tcx, result_fields));
                     }
 
                     case (_) {
@@ -2416,7 +2407,7 @@ mod Unify {
             }
 
             case (ty.ty_fn(?ep, ?expected_inputs, ?expected_output)) {
-                alt (struct(cx.tystore, actual)) {
+                alt (struct(cx.tcx, actual)) {
                     case (ty.ty_fn(?ap, ?actual_inputs, ?actual_output)) {
                         ret unify_fn(cx, ep, ap,
                                      expected, actual,
@@ -2432,7 +2423,7 @@ mod Unify {
 
             case (ty.ty_native_fn(?e_abi, ?expected_inputs,
                                   ?expected_output)) {
-                alt (struct(cx.tystore, actual)) {
+                alt (struct(cx.tcx, actual)) {
                     case (ty.ty_native_fn(?a_abi, ?actual_inputs,
                                           ?actual_output)) {
                         ret unify_native_fn(cx, e_abi, a_abi,
@@ -2447,7 +2438,7 @@ mod Unify {
             }
 
             case (ty.ty_obj(?expected_meths)) {
-                alt (struct(cx.tystore, actual)) {
+                alt (struct(cx.tcx, actual)) {
                     case (ty.ty_obj(?actual_meths)) {
                         ret unify_obj(cx, expected, actual,
                                       expected_meths, actual_meths);
@@ -2500,7 +2491,7 @@ mod Unify {
     // Performs type binding substitution.
     fn substitute(@ctxt cx, vec[t] set_types, t typ) -> t {
         fn substituter(@ctxt cx, vec[t] types, t typ) -> t {
-            alt (struct(cx.tystore, typ)) {
+            alt (struct(cx.tcx, typ)) {
                 case (ty_var(?id)) {
                     alt (cx.var_ids.find(id)) {
                         case (some[uint](?n)) {
@@ -2515,7 +2506,7 @@ mod Unify {
         }
 
         auto f = bind substituter(cx, set_types, _);
-        ret fold_ty(cx.tystore, f, typ);
+        ret fold_ty(cx.tcx, f, typ);
     }
 
     fn unify_sets(@ctxt cx) -> vec[t] {
@@ -2551,7 +2542,7 @@ mod Unify {
     fn unify(t expected,
              t actual,
              &unify_handler handler,
-             @type_store tystore) -> result {
+             ty_ctxt tcx) -> result {
         let vec[t] throwaway = vec();
         let vec[mutable vec[t]] types = vec(mutable throwaway);
         _vec.pop[mutable vec[t]](types);   // FIXME: botch
@@ -2560,7 +2551,7 @@ mod Unify {
                        var_ids=common.new_int_hash[uint](),
                        mutable types=types,
                        handler=handler,
-                       tystore=tystore);
+                       tcx=tcx);
 
         auto ures = unify_step(cx, expected, actual);
         alt (ures) {
@@ -2629,14 +2620,12 @@ fn type_err_to_str(&ty.type_err err) -> str {
 
 // Performs bound type parameter replacement using the supplied mapping from
 // parameter IDs to types.
-fn substitute_type_params(@type_store tystore,
-                          vec[t] bindings,
-                          t typ) -> t {
-    if (!type_contains_bound_params(tystore, typ)) {
+fn substitute_type_params(ctxt cx, vec[t] bindings, t typ) -> t {
+    if (!type_contains_bound_params(cx, typ)) {
         ret typ;
     }
-    fn replacer(@type_store tystore, vec[t] bindings, t typ) -> t {
-        alt (struct(tystore, typ)) {
+    fn replacer(ctxt cx, vec[t] bindings, t typ) -> t {
+        alt (struct(cx, typ)) {
             case (ty_bound_param(?param_index)) {
                 ret bindings.(param_index);
             }
@@ -2644,29 +2633,28 @@ fn substitute_type_params(@type_store tystore,
         }
     }
 
-    auto f = bind replacer(tystore, bindings, _);
-    ret fold_ty(tystore, f, typ);
+    auto f = bind replacer(cx, bindings, _);
+    ret fold_ty(cx, f, typ);
 }
 
 // Converts type parameters in a type to bound type parameters.
-fn bind_params_in_type(@type_store tystore, t typ) -> t {
-    if (!type_contains_params(tystore, typ)) {
-        ret typ;
-    }
-    fn binder(@type_store tystore, t typ) -> t {
-        alt (struct(tystore, typ)) {
+fn bind_params_in_type(ctxt cx, t typ) -> t {
+    if (!type_contains_params(cx, typ)) { ret typ; }
+
+    fn binder(ctxt cx, t typ) -> t {
+        alt (struct(cx, typ)) {
             case (ty_bound_param(?index)) {
                 log_err "bind_params_in_type() called on type that already " +
                     "has bound params in it";
                 fail;
             }
-            case (ty_param(?index)) { ret mk_bound_param(tystore, index); }
+            case (ty_param(?index)) { ret mk_bound_param(cx, index); }
             case (_) { ret typ; }
         }
     }
 
-    auto f = bind binder(tystore, _);
-    ret fold_ty(tystore, f, typ);
+    auto f = bind binder(cx, _);
+    ret fold_ty(cx, f, typ);
 }
 
 
@@ -2692,7 +2680,7 @@ fn def_has_ty_params(&ast.def def) -> bool {
 // If the given item is in an external crate, looks up its type and adds it to
 // the type cache. Returns the type parameters and type.
 fn lookup_item_type(session.session sess,
-                    @type_store tystore,
+                    ctxt cx,
                     &type_cache cache,
                     ast.def_id did) -> ty_param_count_and_ty {
     if (did._0 == sess.get_targ_crate_num()) {
@@ -2704,7 +2692,7 @@ fn lookup_item_type(session.session sess,
     alt (cache.find(did)) {
         case (some[ty_param_count_and_ty](?tpt)) { ret tpt; }
         case (none[ty_param_count_and_ty]) {
-            auto tyt = creader.get_type(sess, tystore, did);
+            auto tyt = creader.get_type(sess, cx, did);
             cache.insert(did, tyt);
             ret tyt;
         }
diff --git a/src/comp/middle/typeck.rs b/src/comp/middle/typeck.rs
index 9aef66aaf68..fc13319df71 100644
--- a/src/comp/middle/typeck.rs
+++ b/src/comp/middle/typeck.rs
@@ -64,7 +64,7 @@ type crate_ctxt = rec(session.session sess,
                       unify_cache unify_cache,
                       mutable uint cache_hits,
                       mutable uint cache_misses,
-                      @ty.type_store tystore);
+                      ty.ctxt tcx);
 
 type fn_ctxt = rec(ty.t ret_ty,
                    @ty_table locals,
@@ -81,7 +81,7 @@ fn substitute_ty_params(&@crate_ctxt ccx,
                         vec[ty.t] supplied,
                         &span sp) -> ty.t {
     fn substituter(@crate_ctxt ccx, vec[ty.t] supplied, ty.t typ) -> ty.t {
-        alt (struct(ccx.tystore, typ)) {
+        alt (struct(ccx.tcx, typ)) {
             case (ty.ty_bound_param(?pid)) { ret supplied.(pid); }
             case (_) { ret typ; }
         }
@@ -97,7 +97,7 @@ fn substitute_ty_params(&@crate_ctxt ccx,
     }
 
     auto f = bind substituter(ccx, supplied, _);
-    ret ty.fold_ty(ccx.tystore, f, typ);
+    ret ty.fold_ty(ccx.tcx, f, typ);
 }
 
 
@@ -113,7 +113,7 @@ fn ty_param_count_and_ty_for_def(@fn_ctxt fcx, &ast.def defn)
             auto t;
             alt (fcx.locals.find(id)) {
                 case (some[ty.t](?t1)) { t = t1; }
-                case (none[ty.t]) { t = ty.mk_local(fcx.ccx.tystore, id); }
+                case (none[ty.t]) { t = ty.mk_local(fcx.ccx.tcx, id); }
             }
             ret tup(0u, t);
         }
@@ -122,19 +122,19 @@ fn ty_param_count_and_ty_for_def(@fn_ctxt fcx, &ast.def defn)
             ret tup(0u, fcx.locals.get(id));
         }
         case (ast.def_fn(?id)) {
-            ret ty.lookup_item_type(fcx.ccx.sess, fcx.ccx.tystore,
+            ret ty.lookup_item_type(fcx.ccx.sess, fcx.ccx.tcx,
                                     fcx.ccx.type_cache, id);
         }
         case (ast.def_native_fn(?id)) {
-            ret ty.lookup_item_type(fcx.ccx.sess, fcx.ccx.tystore,
+            ret ty.lookup_item_type(fcx.ccx.sess, fcx.ccx.tcx,
                                     fcx.ccx.type_cache, id);
         }
         case (ast.def_const(?id)) {
-            ret ty.lookup_item_type(fcx.ccx.sess, fcx.ccx.tystore,
+            ret ty.lookup_item_type(fcx.ccx.sess, fcx.ccx.tcx,
                                     fcx.ccx.type_cache, id);
         }
         case (ast.def_variant(_, ?vid)) {
-            ret ty.lookup_item_type(fcx.ccx.sess, fcx.ccx.tystore,
+            ret ty.lookup_item_type(fcx.ccx.sess, fcx.ccx.tcx,
                                     fcx.ccx.type_cache, vid);
         }
         case (ast.def_binding(?id)) {
@@ -142,14 +142,14 @@ fn ty_param_count_and_ty_for_def(@fn_ctxt fcx, &ast.def defn)
             ret tup(0u, fcx.locals.get(id));
         }
         case (ast.def_obj(?id)) {
-            ret ty.lookup_item_type(fcx.ccx.sess, fcx.ccx.tystore,
+            ret ty.lookup_item_type(fcx.ccx.sess, fcx.ccx.tcx,
                                     fcx.ccx.type_cache, id);
         }
 
         case (ast.def_mod(_)) {
             // Hopefully part of a path.
             // TODO: return a type that's more poisonous, perhaps?
-            ret tup(0u, ty.mk_nil(fcx.ccx.tystore));
+            ret tup(0u, ty.mk_nil(fcx.ccx.tcx));
         }
 
         case (ast.def_ty(_)) {
@@ -170,7 +170,7 @@ fn ty_param_count_and_ty_for_def(@fn_ctxt fcx, &ast.def defn)
 fn instantiate_path(@fn_ctxt fcx, &ast.path pth, &ty_param_count_and_ty tpt,
         &span sp) -> ast.ann {
     auto ty_param_count = tpt._0;
-    auto t = bind_params_in_type(fcx.ccx.tystore, tpt._1);
+    auto t = bind_params_in_type(fcx.ccx.tcx, tpt._1);
 
     auto ty_substs_opt;
     auto ty_substs_len = _vec.len[@ast.ty](pth.node.types);
@@ -205,23 +205,21 @@ fn instantiate_path(@fn_ctxt fcx, &ast.path pth, &ty_param_count_and_ty tpt,
 // Parses the programmer's textual representation of a type into our internal
 // notion of a type. `getter` is a function that returns the type
 // corresponding to a definition ID.
-fn ast_ty_to_ty(@ty.type_store tystore,
-                ty_getter getter,
-                &@ast.ty ast_ty) -> ty.t {
-    fn ast_arg_to_arg(@ty.type_store tystore,
+fn ast_ty_to_ty(ty.ctxt tcx, ty_getter getter, &@ast.ty ast_ty) -> ty.t {
+    fn ast_arg_to_arg(ty.ctxt tcx,
                       ty_getter getter,
                       &rec(ast.mode mode, @ast.ty ty) arg)
             -> rec(ast.mode mode, ty.t ty) {
-        ret rec(mode=arg.mode, ty=ast_ty_to_ty(tystore, getter, arg.ty));
+        ret rec(mode=arg.mode, ty=ast_ty_to_ty(tcx, getter, arg.ty));
     }
 
-    fn ast_mt_to_mt(@ty.type_store tystore,
+    fn ast_mt_to_mt(ty.ctxt tcx,
                     ty_getter getter,
                     &ast.mt mt) -> ty.mt {
-        ret rec(ty=ast_ty_to_ty(tystore, getter, mt.ty), mut=mt.mut);
+        ret rec(ty=ast_ty_to_ty(tcx, getter, mt.ty), mut=mt.mut);
     }
 
-    fn instantiate(@ty.type_store tystore,
+    fn instantiate(ty.ctxt tcx,
                    ty_getter getter,
                    ast.def_id id,
                    vec[@ast.ty] args) -> ty.t {
@@ -237,75 +235,75 @@ fn ast_ty_to_ty(@ty.type_store tystore,
         //
         // TODO: Make sure the number of supplied bindings matches the number
         // of type parameters in the typedef. Emit a friendly error otherwise.
-        auto bound_ty = bind_params_in_type(tystore, params_opt_and_ty._1);
+        auto bound_ty = bind_params_in_type(tcx, params_opt_and_ty._1);
         let vec[ty.t] param_bindings = vec();
         for (@ast.ty ast_ty in args) {
-            param_bindings += vec(ast_ty_to_ty(tystore, getter, ast_ty));
+            param_bindings += vec(ast_ty_to_ty(tcx, getter, ast_ty));
         }
-        ret ty.substitute_type_params(tystore, param_bindings, bound_ty);
+        ret ty.substitute_type_params(tcx, param_bindings, bound_ty);
     }
 
     auto mut = ast.imm;
     auto typ;
     auto cname = none[str];
     alt (ast_ty.node) {
-        case (ast.ty_nil)          { typ = ty.mk_nil(tystore); }
-        case (ast.ty_bool)         { typ = ty.mk_bool(tystore); }
-        case (ast.ty_int)          { typ = ty.mk_int(tystore); }
-        case (ast.ty_uint)         { typ = ty.mk_uint(tystore); }
-        case (ast.ty_float)        { typ = ty.mk_float(tystore); }
-        case (ast.ty_machine(?tm)) { typ = ty.mk_mach(tystore, tm); }
-        case (ast.ty_char)         { typ = ty.mk_char(tystore); }
-        case (ast.ty_str)          { typ = ty.mk_str(tystore); }
+        case (ast.ty_nil)          { typ = ty.mk_nil(tcx); }
+        case (ast.ty_bool)         { typ = ty.mk_bool(tcx); }
+        case (ast.ty_int)          { typ = ty.mk_int(tcx); }
+        case (ast.ty_uint)         { typ = ty.mk_uint(tcx); }
+        case (ast.ty_float)        { typ = ty.mk_float(tcx); }
+        case (ast.ty_machine(?tm)) { typ = ty.mk_mach(tcx, tm); }
+        case (ast.ty_char)         { typ = ty.mk_char(tcx); }
+        case (ast.ty_str)          { typ = ty.mk_str(tcx); }
         case (ast.ty_box(?mt)) {
-            typ = ty.mk_box(tystore, ast_mt_to_mt(tystore, getter, mt));
+            typ = ty.mk_box(tcx, ast_mt_to_mt(tcx, getter, mt));
         }
         case (ast.ty_vec(?mt)) {
-            typ = ty.mk_vec(tystore, ast_mt_to_mt(tystore, getter, mt));
+            typ = ty.mk_vec(tcx, ast_mt_to_mt(tcx, getter, mt));
         }
 
         case (ast.ty_port(?t)) {
-            typ = ty.mk_port(tystore, ast_ty_to_ty(tystore, getter, t));
+            typ = ty.mk_port(tcx, ast_ty_to_ty(tcx, getter, t));
         }
 
         case (ast.ty_chan(?t)) {
-            typ = ty.mk_chan(tystore, ast_ty_to_ty(tystore, getter, t));
+            typ = ty.mk_chan(tcx, ast_ty_to_ty(tcx, getter, t));
         }
 
         case (ast.ty_tup(?fields)) {
             let vec[ty.mt] flds = vec();
             for (ast.mt field in fields) {
-                _vec.push[ty.mt](flds, ast_mt_to_mt(tystore, getter, field));
+                _vec.push[ty.mt](flds, ast_mt_to_mt(tcx, getter, field));
             }
-            typ = ty.mk_tup(tystore, flds);
+            typ = ty.mk_tup(tcx, flds);
         }
         case (ast.ty_rec(?fields)) {
             let vec[field] flds = vec();
             for (ast.ty_field f in fields) {
-                auto tm = ast_mt_to_mt(tystore, getter, f.mt);
+                auto tm = ast_mt_to_mt(tcx, getter, f.mt);
                 _vec.push[field](flds, rec(ident=f.ident, mt=tm));
             }
-            typ = ty.mk_rec(tystore, flds);
+            typ = ty.mk_rec(tcx, flds);
         }
 
         case (ast.ty_fn(?proto, ?inputs, ?output)) {
-            auto f = bind ast_arg_to_arg(tystore, getter, _);
+            auto f = bind ast_arg_to_arg(tcx, getter, _);
             auto i = _vec.map[ast.ty_arg, arg](f, inputs);
-            auto out_ty = ast_ty_to_ty(tystore, getter, output);
-            typ = ty.mk_fn(tystore, proto, i, out_ty);
+            auto out_ty = ast_ty_to_ty(tcx, getter, output);
+            typ = ty.mk_fn(tcx, proto, i, out_ty);
         }
 
         case (ast.ty_path(?path, ?def)) {
             check (def != none[ast.def]);
             alt (option.get[ast.def](def)) {
                 case (ast.def_ty(?id)) {
-                    typ = instantiate(tystore, getter, id, path.node.types);
+                    typ = instantiate(tcx, getter, id, path.node.types);
                 }
                 case (ast.def_native_ty(?id)) { typ = getter(id)._1; }
                 case (ast.def_obj(?id)) {
-                    typ = instantiate(tystore, getter, id, path.node.types);
+                    typ = instantiate(tcx, getter, id, path.node.types);
                 }
-                case (ast.def_ty_arg(?id)) { typ = ty.mk_param(tystore, id); }
+                case (ast.def_ty_arg(?id)) { typ = ty.mk_param(tcx, id); }
                 case (_)                   { fail; }
             }
 
@@ -314,10 +312,10 @@ fn ast_ty_to_ty(@ty.type_store tystore,
 
         case (ast.ty_obj(?meths)) {
             let vec[ty.method] tmeths = vec();
-            auto f = bind ast_arg_to_arg(tystore, getter, _);
+            auto f = bind ast_arg_to_arg(tcx, getter, _);
             for (ast.ty_method m in meths) {
                 auto ins = _vec.map[ast.ty_arg, arg](f, m.inputs);
-                auto out = ast_ty_to_ty(tystore, getter, m.output);
+                auto out = ast_ty_to_ty(tcx, getter, m.output);
                 _vec.push[ty.method](tmeths,
                                   rec(proto=m.proto,
                                       ident=m.ident,
@@ -325,14 +323,14 @@ fn ast_ty_to_ty(@ty.type_store tystore,
                                       output=out));
             }
 
-            typ = ty.mk_obj(tystore, ty.sort_methods(tmeths));
+            typ = ty.mk_obj(tcx, ty.sort_methods(tmeths));
         }
     }
 
     alt (cname) {
         case (none[str]) { /* no-op */ }
         case (some[str](?cname_str)) {
-            typ = ty.rename(tystore, typ, cname_str);
+            typ = ty.rename(tcx, typ, cname_str);
         }
     }
     ret typ;
@@ -342,10 +340,10 @@ fn ast_ty_to_ty(@ty.type_store tystore,
 // ast_ty_to_ty.
 fn ast_ty_to_ty_crate(@crate_ctxt ccx, &@ast.ty ast_ty) -> ty.t {
     fn getter(@crate_ctxt ccx, ast.def_id id) -> ty.ty_param_count_and_ty {
-        ret ty.lookup_item_type(ccx.sess, ccx.tystore, ccx.type_cache, id);
+        ret ty.lookup_item_type(ccx.sess, ccx.tcx, ccx.type_cache, id);
     }
     auto f = bind getter(ccx, _);
-    ret ast_ty_to_ty(ccx.tystore, f, ast_ty);
+    ret ast_ty_to_ty(ccx.tcx, f, ast_ty);
 }
 
 
@@ -364,7 +362,7 @@ mod Collect {
     type ctxt = rec(session.session sess,
                     @ty_item_table id_to_ty_item,
                     ty.type_cache type_cache,
-                    @ty.type_store tystore);
+                    ty.ctxt tcx);
     type env = rec(@ctxt cx, ast.native_abi abi);
 
     fn ty_of_fn_decl(@ctxt cx,
@@ -376,7 +374,7 @@ mod Collect {
                      ast.def_id def_id) -> ty.ty_param_count_and_ty {
         auto input_tys = _vec.map[ast.arg,arg](ty_of_arg, decl.inputs);
         auto output_ty = convert(decl.output);
-        auto t_fn = ty.mk_fn(cx.tystore, proto, input_tys, output_ty);
+        auto t_fn = ty.mk_fn(cx.tcx, proto, input_tys, output_ty);
         auto ty_param_count = _vec.len[ast.ty_param](ty_params);
         auto tpt = tup(ty_param_count, t_fn);
         cx.type_cache.insert(def_id, tpt);
@@ -392,7 +390,7 @@ mod Collect {
                             ast.def_id def_id) -> ty.ty_param_count_and_ty {
         auto input_tys = _vec.map[ast.arg,arg](ty_of_arg, decl.inputs);
         auto output_ty = convert(decl.output);
-        auto t_fn = ty.mk_native_fn(cx.tystore, abi, input_tys, output_ty);
+        auto t_fn = ty.mk_native_fn(cx.tcx, abi, input_tys, output_ty);
         auto ty_param_count = _vec.len[ast.ty_param](ty_params);
         auto tpt = tup(ty_param_count, t_fn);
         cx.type_cache.insert(def_id, tpt);
@@ -403,7 +401,7 @@ mod Collect {
 
         if (id._0 != cx.sess.get_targ_crate_num()) {
             // This is a type we need to load in from the crate reader.
-            ret creader.get_type(cx.sess, cx.tystore, id);
+            ret creader.get_type(cx.sess, cx.tcx, id);
         }
 
         // check (cx.id_to_ty_item.contains_key(id));
@@ -422,12 +420,12 @@ mod Collect {
 
     fn ty_of_arg(@ctxt cx, &ast.arg a) -> arg {
         auto f = bind getter(cx, _);
-        ret rec(mode=a.mode, ty=ast_ty_to_ty(cx.tystore, f, a.ty));
+        ret rec(mode=a.mode, ty=ast_ty_to_ty(cx.tcx, f, a.ty));
     }
 
     fn ty_of_method(@ctxt cx, &@ast.method m) -> method {
         auto get = bind getter(cx, _);
-        auto convert = bind ast_ty_to_ty(cx.tystore, get, _);
+        auto convert = bind ast_ty_to_ty(cx.tcx, get, _);
         auto f = bind ty_of_arg(cx, _);
         auto inputs = _vec.map[ast.arg,arg](f, m.node.meth.decl.inputs);
         auto output = convert(m.node.meth.decl.output);
@@ -442,8 +440,8 @@ mod Collect {
         auto f = bind ty_of_method(cx, _);
         auto methods = _vec.map[@ast.method,method](f, obj_info.methods);
 
-        auto t_obj = ty.mk_obj(cx.tystore, ty.sort_methods(methods));
-        t_obj = ty.rename(cx.tystore, t_obj, id);
+        auto t_obj = ty.mk_obj(cx.tcx, ty.sort_methods(methods));
+        t_obj = ty.rename(cx.tcx, t_obj, id);
         auto ty_param_count = _vec.len[ast.ty_param](ty_params);
         ret tup(ty_param_count, t_obj);
     }
@@ -458,20 +456,20 @@ mod Collect {
         let vec[arg] t_inputs = vec();
         for (ast.obj_field f in obj_info.fields) {
             auto g = bind getter(cx, _);
-            auto t_field = ast_ty_to_ty(cx.tystore, g, f.ty);
+            auto t_field = ast_ty_to_ty(cx.tcx, g, f.ty);
             _vec.push[arg](t_inputs, rec(mode=ast.alias, ty=t_field));
         }
 
         cx.type_cache.insert(obj_ty_id, t_obj);
 
-        auto t_fn = ty.mk_fn(cx.tystore, ast.proto_fn, t_inputs, t_obj._1);
+        auto t_fn = ty.mk_fn(cx.tcx, ast.proto_fn, t_inputs, t_obj._1);
         ret tup(t_obj._0, t_fn);
     }
 
     fn ty_of_item(@ctxt cx, @ast.item it) -> ty.ty_param_count_and_ty {
 
         auto get = bind getter(cx, _);
-        auto convert = bind ast_ty_to_ty(cx.tystore, get, _);
+        auto convert = bind ast_ty_to_ty(cx.tcx, get, _);
 
         alt (it.node) {
 
@@ -516,11 +514,11 @@ mod Collect {
 
                 auto i = 0u;
                 for (ast.ty_param tp in tps) {
-                    subtys += vec(ty.mk_param(cx.tystore, i));
+                    subtys += vec(ty.mk_param(cx.tcx, i));
                     i += 1u;
                 }
 
-                auto t = ty.mk_tag(cx.tystore, def_id, subtys);
+                auto t = ty.mk_tag(cx.tcx, def_id, subtys);
 
                 auto ty_param_count = _vec.len[ast.ty_param](tps);
                 auto tpt = tup(ty_param_count, t);
@@ -539,7 +537,7 @@ mod Collect {
             case (ast.native_item_fn(?ident, ?lname, ?fn_decl,
                                      ?params, ?def_id, _)) {
                 auto get = bind getter(cx, _);
-                auto convert = bind ast_ty_to_ty(cx.tystore, get, _);
+                auto convert = bind ast_ty_to_ty(cx.tcx, get, _);
                 auto f = bind ty_of_arg(cx, _);
                 ret ty_of_native_fn_decl(cx, convert, f, fn_decl, abi, params,
                                          def_id);
@@ -552,7 +550,7 @@ mod Collect {
                     case (none[ty.ty_param_count_and_ty]) {}
                 }
 
-                auto t = ty.mk_native(cx.tystore);
+                auto t = ty.mk_native(cx.tcx);
                 auto tpt = tup(0u, t);
                 cx.type_cache.insert(def_id, tpt);
                 ret tpt;
@@ -570,7 +568,7 @@ mod Collect {
         let vec[ty.t] ty_param_tys = vec();
         auto i = 0u;
         for (ast.ty_param tp in ty_params) {
-            ty_param_tys += vec(ty.mk_param(cx.tystore, i));
+            ty_param_tys += vec(ty.mk_param(cx.tcx, i));
             i += 1u;
         }
 
@@ -581,7 +579,7 @@ mod Collect {
             // constructors get turned into functions.
             auto result_ty;
             if (_vec.len[ast.variant_arg](variant.node.args) == 0u) {
-                result_ty = ty.mk_tag(cx.tystore, tag_id, ty_param_tys);
+                result_ty = ty.mk_tag(cx.tcx, tag_id, ty_param_tys);
             } else {
                 // As above, tell ast_ty_to_ty() that trans_ty_item_to_ty()
                 // should be called to resolve named types.
@@ -589,11 +587,11 @@ mod Collect {
 
                 let vec[arg] args = vec();
                 for (ast.variant_arg va in variant.node.args) {
-                    auto arg_ty = ast_ty_to_ty(cx.tystore, f, va.ty);
+                    auto arg_ty = ast_ty_to_ty(cx.tcx, f, va.ty);
                     args += vec(rec(mode=ast.alias, ty=arg_ty));
                 }
-                auto tag_t = ty.mk_tag(cx.tystore, tag_id, ty_param_tys);
-                result_ty = ty.mk_fn(cx.tystore, ast.proto_fn, args, tag_t);
+                auto tag_t = ty.mk_tag(cx.tcx, tag_id, ty_param_tys);
+                result_ty = ty.mk_fn(cx.tcx, ast.proto_fn, args, tag_t);
             }
 
             auto tpt = tup(ty_param_count, result_ty);
@@ -691,9 +689,9 @@ mod Collect {
     }
 
     fn get_ctor_obj_methods(&@env e, ty.t t) -> vec[method] {
-        alt (struct(e.cx.tystore, t)) {
+        alt (struct(e.cx.tcx, t)) {
             case (ty.ty_fn(_,_,?tobj)) {
-                alt (struct(e.cx.tystore, tobj)) {
+                alt (struct(e.cx.tcx, tobj)) {
                     case (ty.ty_obj(?tm)) {
                         ret tm;
                     }
@@ -727,7 +725,7 @@ mod Collect {
             let method meth_ty = meth_tys.(ix);
             let ast.method_ m_;
             let @ast.method m;
-            auto meth_tfn = ty.mk_fn(e.cx.tystore,
+            auto meth_tfn = ty.mk_fn(e.cx.tcx,
                                      meth_ty.proto,
                                      meth_ty.inputs,
                                      meth_ty.output);
@@ -739,7 +737,7 @@ mod Collect {
         }
         auto g = bind getter(e.cx, _);
         for (ast.obj_field fld in ob.fields) {
-            let ty.t fty = ast_ty_to_ty(e.cx.tystore, g, fld.ty);
+            let ty.t fty = ast_ty_to_ty(e.cx.tcx, g, fld.ty);
             let ast.obj_field f = rec(ann=triv_ann(fty)
                 with fld
             );
@@ -750,8 +748,8 @@ mod Collect {
         alt (ob.dtor) {
             case (some[@ast.method](?d)) {
                 let vec[arg] inputs = vec();
-                let ty.t output = ty.mk_nil(e.cx.tystore);
-                auto dtor_tfn = ty.mk_fn(e.cx.tystore, ast.proto_fn, inputs,
+                let ty.t output = ty.mk_nil(e.cx.tcx);
+                auto dtor_tfn = ty.mk_fn(e.cx.tcx, ast.proto_fn, inputs,
                                          output);
                 auto d_ = rec(ann=triv_ann(dtor_tfn) with d.node);
                 dtor = some[@ast.method](@rec(node=d_ with *d));
@@ -789,9 +787,7 @@ mod Collect {
         ret @fold.respan[ast.item_](sp, item);
     }
 
-    fn collect_item_types(session.session sess,
-                          @ty.type_store tystore,
-                          @ast.crate crate)
+    fn collect_item_types(session.session sess, ty.ctxt tcx, @ast.crate crate)
             -> tup(@ast.crate, ty.type_cache, @ty_item_table) {
         // First pass: collect all type item IDs.
         auto module = crate.node.module;
@@ -809,7 +805,7 @@ mod Collect {
         auto cx = @rec(sess=sess,
                        id_to_ty_item=id_to_ty_item,
                        type_cache=type_cache,
-                       tystore=tystore);
+                       tcx=tcx);
 
         let @env e = @rec(cx=cx, abi=ast.native_abi_cdecl);
 
@@ -837,7 +833,7 @@ mod Unify {
     fn simple(@fn_ctxt fcx, ty.t expected, ty.t actual) -> ty.Unify.result {
         // FIXME: horrid botch
         let vec[mutable ty.t] param_substs =
-            vec(mutable ty.mk_nil(fcx.ccx.tystore));
+            vec(mutable ty.mk_nil(fcx.ccx.tcx));
         _vec.pop[mutable ty.t](param_substs);
         ret with_params(fcx, expected, actual, param_substs);
     }
@@ -860,7 +856,7 @@ mod Unify {
                 alt (fcx.locals.find(id)) {
                     case (none[ty.t]) { ret none[ty.t]; }
                     case (some[ty.t](?existing_type)) {
-                        if (ty.type_contains_vars(fcx.ccx.tystore,
+                        if (ty.type_contains_vars(fcx.ccx.tcx,
                                                   existing_type)) {
                             // Not fully resolved yet. The writeback phase
                             // will mop up.
@@ -890,7 +886,7 @@ mod Unify {
                 }
 
                 unified_type =
-                    ty.substitute_type_params(fcx.ccx.tystore, param_substs_1,
+                    ty.substitute_type_params(fcx.ccx.tcx, param_substs_1,
                                               unified_type);
                 fcx.locals.insert(id, unified_type);
             }
@@ -904,8 +900,7 @@ mod Unify {
                 alt (result) {
                     case (ures_ok(?new_subst)) {
                         param_substs.(index) = new_subst;
-                        ret ures_ok(ty.mk_bound_param(fcx.ccx.tystore,
-                                                      index));
+                        ret ures_ok(ty.mk_bound_param(fcx.ccx.tcx, index));
                     }
                     case (_) { ret result; }
                 }
@@ -914,10 +909,7 @@ mod Unify {
 
 
         auto handler = unify_handler(fcx, param_substs);
-        auto result = ty.Unify.unify(expected,
-                                     actual,
-                                     handler,
-                                     fcx.ccx.tystore);
+        auto result = ty.Unify.unify(expected, actual, handler, fcx.ccx.tcx);
         fcx.ccx.unify_cache.insert(cache_key, result);
         ret result;
     }
@@ -929,10 +921,10 @@ tag autoderef_kind {
     NO_AUTODEREF;
 }
 
-fn strip_boxes(@ty.type_store tystore, ty.t t) -> ty.t {
+fn strip_boxes(ty.ctxt tcx, ty.t t) -> ty.t {
     auto t1 = t;
     while (true) {
-        alt (struct(tystore, t1)) {
+        alt (struct(tcx, t1)) {
             case (ty.ty_box(?inner)) { t1 = inner.ty; }
             case (_) { ret t1; }
         }
@@ -943,18 +935,18 @@ fn strip_boxes(@ty.type_store tystore, ty.t t) -> ty.t {
 fn add_boxes(@crate_ctxt ccx, uint n, ty.t t) -> ty.t {
     auto t1 = t;
     while (n != 0u) {
-        t1 = ty.mk_imm_box(ccx.tystore, t1);
+        t1 = ty.mk_imm_box(ccx.tcx, t1);
         n -= 1u;
     }
     ret t1;
 }
 
 
-fn count_boxes(@ty.type_store tystore, ty.t t) -> uint {
+fn count_boxes(ty.ctxt tcx, ty.t t) -> uint {
     auto n = 0u;
     auto t1 = t;
     while (true) {
-        alt (struct(tystore, t1)) {
+        alt (struct(tcx, t1)) {
             case (ty.ty_box(?inner)) { n += 1u; t1 = inner.ty; }
             case (_) { ret n; }
         }
@@ -992,13 +984,13 @@ mod Demand {
         auto implicit_boxes = 0u;
 
         if (adk == AUTODEREF_OK) {
-            expected_1 = strip_boxes(fcx.ccx.tystore, expected_1);
-            actual_1 = strip_boxes(fcx.ccx.tystore, actual_1);
-            implicit_boxes = count_boxes(fcx.ccx.tystore, actual);
+            expected_1 = strip_boxes(fcx.ccx.tcx, expected_1);
+            actual_1 = strip_boxes(fcx.ccx.tcx, actual_1);
+            implicit_boxes = count_boxes(fcx.ccx.tcx, actual);
         }
 
         let vec[mutable ty.t] ty_param_substs =
-            vec(mutable ty.mk_nil(fcx.ccx.tystore));
+            vec(mutable ty.mk_nil(fcx.ccx.tcx));
         _vec.pop[mutable ty.t](ty_param_substs);   // FIXME: horrid botch
         for (ty.t ty_param_subst in ty_param_substs_0) {
             ty_param_substs += vec(mutable ty_param_subst);
@@ -1018,8 +1010,8 @@ mod Demand {
 
             case (ures_err(?err, ?expected, ?actual)) {
                 fcx.ccx.sess.span_err(sp, "mismatched types: expected "
-                    + ty_to_str(fcx.ccx.tystore, expected) + " but found "
-                    + ty_to_str(fcx.ccx.tystore, actual) + " ("
+                    + ty_to_str(fcx.ccx.tcx, expected) + " but found "
+                    + ty_to_str(fcx.ccx.tcx, actual) + " ("
                     + ty.type_err_to_str(err) + ")");
 
                 // TODO: In the future, try returning "expected", reporting
@@ -1046,13 +1038,12 @@ fn variant_arg_types(@crate_ctxt ccx, &span sp, ast.def_id vid,
 
     let vec[ty.t] result = vec();
 
-    auto tpt = ty.lookup_item_type(ccx.sess, ccx.tystore, ccx.type_cache,
-                                   vid);
-    alt (struct(ccx.tystore, tpt._1)) {
+    auto tpt = ty.lookup_item_type(ccx.sess, ccx.tcx, ccx.type_cache, vid);
+    alt (struct(ccx.tcx, tpt._1)) {
         case (ty.ty_fn(_, ?ins, _)) {
             // N-ary variant.
             for (ty.arg arg in ins) {
-                auto arg_ty = bind_params_in_type(ccx.tystore, arg.ty);
+                auto arg_ty = bind_params_in_type(ccx.tcx, arg.ty);
                 arg_ty = substitute_ty_params(ccx, arg_ty, ty_param_count,
                                               tag_ty_params, sp);
                 result += vec(arg_ty);
@@ -1117,7 +1108,7 @@ mod Pushdown {
                 // Take the variant's type parameters out of the expected
                 // type.
                 auto tag_tps;
-                alt (struct(fcx.ccx.tystore, expected)) {
+                alt (struct(fcx.ccx.tcx, expected)) {
                     case (ty.ty_tag(_, ?tps)) { tag_tps = tps; }
                     case (_) {
                         log_err "tag pattern type not actually a tag?!";
@@ -1167,7 +1158,7 @@ mod Pushdown {
                 auto t = Demand.simple(fcx, e.span, expected,
                                        ann_to_type(ann));
                 let vec[@ast.expr] es_1 = vec();
-                alt (struct(fcx.ccx.tystore, t)) {
+                alt (struct(fcx.ccx.tcx, t)) {
                     case (ty.ty_vec(?mt)) {
                         for (@ast.expr e_0 in es_0) {
                             es_1 += vec(pushdown_expr(fcx, mt.ty, e_0));
@@ -1184,7 +1175,7 @@ mod Pushdown {
                 auto t = Demand.simple(fcx, e.span, expected,
                                        ann_to_type(ann));
                 let vec[ast.elt] elts_1 = vec();
-                alt (struct(fcx.ccx.tystore, t)) {
+                alt (struct(fcx.ccx.tcx, t)) {
                     case (ty.ty_tup(?mts)) {
                         auto i = 0u;
                         for (ast.elt elt_0 in es_0) {
@@ -1208,7 +1199,7 @@ mod Pushdown {
                 auto t = Demand.simple(fcx, e.span, expected,
                                        ann_to_type(ann));
                 let vec[ast.field] fields_1 = vec();
-                alt (struct(fcx.ccx.tystore, t)) {
+                alt (struct(fcx.ccx.tcx, t)) {
                     case (ty.ty_rec(?field_mts)) {
                         alt (base_0) {
                             case (none[@ast.expr]) {
@@ -1421,9 +1412,9 @@ mod Pushdown {
                 auto t = Demand.simple(fcx, e.span, expected,
                                        ann_to_type(ann));
                 let @ast.expr es_1;
-                alt (struct(fcx.ccx.tystore, t)) {
+                alt (struct(fcx.ccx.tcx, t)) {
                     case (ty.ty_chan(?subty)) {
-                        auto pt = ty.mk_port(fcx.ccx.tystore, subty);
+                        auto pt = ty.mk_port(fcx.ccx.tcx, subty);
                         es_1 = pushdown_expr(fcx, pt, es);
                     }
                     case (_) {
@@ -1440,7 +1431,7 @@ mod Pushdown {
                 for (ast.arm arm_0 in arms_0) {
                     auto block_1 = pushdown_block(fcx, expected, arm_0.block);
                     t = Demand.simple(fcx, e.span, t,
-                                      block_ty(fcx.ccx.tystore, block_1));
+                                      block_ty(fcx.ccx.tcx, block_1));
                     auto arm_1 = rec(pat=arm_0.pat, block=block_1,
                                      index=arm_0.index);
                     arms_1 += vec(arm_1);
@@ -1451,9 +1442,8 @@ mod Pushdown {
             case (ast.expr_recv(?lval_0, ?expr_0, ?ann)) {
                 auto lval_1 = pushdown_expr(fcx, next_ty_var(fcx.ccx),
                                             lval_0);
-                auto t = expr_ty(fcx.ccx.tystore, lval_1);
-                auto expr_1 = pushdown_expr(fcx,
-                                            ty.mk_port(fcx.ccx.tystore, t),
+                auto t = expr_ty(fcx.ccx.tcx, lval_1);
+                auto expr_1 = pushdown_expr(fcx, ty.mk_port(fcx.ccx.tcx, t),
                                             expr_0);
                 e_1 = ast.expr_recv(lval_1, expr_1, ann);
             }
@@ -1461,9 +1451,8 @@ mod Pushdown {
             case (ast.expr_send(?lval_0, ?expr_0, ?ann)) {
                 auto expr_1 = pushdown_expr(fcx, next_ty_var(fcx.ccx),
                                             expr_0);
-                auto t = expr_ty(fcx.ccx.tystore, expr_1);
-                auto lval_1 = pushdown_expr(fcx,
-                                            ty.mk_chan(fcx.ccx.tystore, t),
+                auto t = expr_ty(fcx.ccx.tcx, expr_1);
+                auto lval_1 = pushdown_expr(fcx, ty.mk_chan(fcx.ccx.tcx, t),
                                             lval_0);
                 e_1 = ast.expr_send(lval_1, expr_1, ann);
             }
@@ -1488,14 +1477,14 @@ mod Pushdown {
                 auto block_ = rec(stmts=bloc.node.stmts,
                                   expr=some[@ast.expr](e_1),
                                   index=bloc.node.index,
-                                  a=plain_ann(fcx.ccx.tystore));
+                                  a=plain_ann(fcx.ccx.tcx));
                 ret fold.respan[ast.block_](bloc.span, block_);
             }
             case (none[@ast.expr]) {
                 Demand.simple(fcx, bloc.span, expected,
-                              ty.mk_nil(fcx.ccx.tystore));
+                              ty.mk_nil(fcx.ccx.tcx));
                 ret fold.respan[ast.block_](bloc.span,
-                      rec(a = plain_ann(fcx.ccx.tystore) with bloc.node));
+                      rec(a = plain_ann(fcx.ccx.tcx) with bloc.node));
             }
         }
     }
@@ -1530,7 +1519,7 @@ fn writeback_local(&option.t[@fn_ctxt] env, &span sp, @ast.local local)
 fn resolve_local_types_in_annotation(&option.t[@fn_ctxt] env, ast.ann ann)
         -> ast.ann {
     fn resolver(@fn_ctxt fcx, ty.t typ) -> ty.t {
-        alt (struct(fcx.ccx.tystore, typ)) {
+        alt (struct(fcx.ccx.tcx, typ)) {
             case (ty.ty_local(?lid)) { ret fcx.locals.get(lid); }
             case (_)                 { ret typ; }
         }
@@ -1544,7 +1533,7 @@ fn resolve_local_types_in_annotation(&option.t[@fn_ctxt] env, ast.ann ann)
         }
         case (ast.ann_type(?typ, ?tps, ?ts_info)) {
             auto f = bind resolver(fcx, _);
-            auto new_type = ty.fold_ty(fcx.ccx.tystore, f, ann_to_type(ann));
+            auto new_type = ty.fold_ty(fcx.ccx.tcx, f, ann_to_type(ann));
             ret ast.ann_type(new_type, tps, ts_info);
         }
     }
@@ -1580,16 +1569,16 @@ fn resolve_local_types_in_block(&@fn_ctxt fcx, &ast.block block)
 
 fn check_lit(@crate_ctxt ccx, @ast.lit lit) -> ty.t {
     alt (lit.node) {
-        case (ast.lit_str(_))           { ret ty.mk_str(ccx.tystore); }
-        case (ast.lit_char(_))          { ret ty.mk_char(ccx.tystore); }
-        case (ast.lit_int(_))           { ret ty.mk_int(ccx.tystore);  }
-        case (ast.lit_float(_))         { ret ty.mk_float(ccx.tystore);  }
+        case (ast.lit_str(_))           { ret ty.mk_str(ccx.tcx); }
+        case (ast.lit_char(_))          { ret ty.mk_char(ccx.tcx); }
+        case (ast.lit_int(_))           { ret ty.mk_int(ccx.tcx);  }
+        case (ast.lit_float(_))         { ret ty.mk_float(ccx.tcx);  }
         case (ast.lit_mach_float(?tm, _))
-                                        { ret ty.mk_mach(ccx.tystore, tm); }
-        case (ast.lit_uint(_))          { ret ty.mk_uint(ccx.tystore); }
-        case (ast.lit_mach_int(?tm, _)) { ret ty.mk_mach(ccx.tystore, tm); }
-        case (ast.lit_nil)              { ret ty.mk_nil(ccx.tystore);  }
-        case (ast.lit_bool(_))          { ret ty.mk_bool(ccx.tystore); }
+                                        { ret ty.mk_mach(ccx.tcx, tm); }
+        case (ast.lit_uint(_))          { ret ty.mk_uint(ccx.tcx); }
+        case (ast.lit_mach_int(?tm, _)) { ret ty.mk_mach(ccx.tcx, tm); }
+        case (ast.lit_nil)              { ret ty.mk_nil(ccx.tcx);  }
+        case (ast.lit_bool(_))          { ret ty.mk_bool(ccx.tcx); }
     }
 
     fail; // not reached
@@ -1610,16 +1599,16 @@ fn check_pat(&@fn_ctxt fcx, @ast.pat pat) -> @ast.pat {
         }
         case (ast.pat_tag(?p, ?subpats, ?vdef_opt, _)) {
             auto vdef = option.get[ast.variant_def](vdef_opt);
-            auto t = ty.lookup_item_type(fcx.ccx.sess, fcx.ccx.tystore,
+            auto t = ty.lookup_item_type(fcx.ccx.sess, fcx.ccx.tcx,
                                          fcx.ccx.type_cache, vdef._1)._1;
             auto len = _vec.len[ast.ident](p.node.idents);
             auto last_id = p.node.idents.(len - 1u);
 
-            auto tpt = ty.lookup_item_type(fcx.ccx.sess, fcx.ccx.tystore,
+            auto tpt = ty.lookup_item_type(fcx.ccx.sess, fcx.ccx.tcx,
                                            fcx.ccx.type_cache, vdef._0);
             auto ann = instantiate_path(fcx, p, tpt, pat.span);
 
-            alt (struct(fcx.ccx.tystore, t)) {
+            alt (struct(fcx.ccx.tcx, t)) {
                 // N-ary variants have function types.
                 case (ty.ty_fn(_, ?args, ?tag_ty)) {
                     auto arg_len = _vec.len[arg](args);
@@ -1692,7 +1681,7 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
 
                     // FIXME: this breaks aliases. We need a ty_fn_arg.
                     auto arg_ty = rec(mode=ast.val,
-                                      ty=expr_ty(fcx.ccx.tystore, a_0));
+                                      ty=expr_ty(fcx.ccx.tcx, a_0));
                     _vec.push[arg](arg_tys_0, arg_ty);
                 }
                 case (none[@ast.expr]) {
@@ -1707,12 +1696,12 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
 
         auto rt_0 = next_ty_var(fcx.ccx);
         auto t_0;
-        alt (struct(fcx.ccx.tystore, expr_ty(fcx.ccx.tystore, f_0))) {
+        alt (struct(fcx.ccx.tcx, expr_ty(fcx.ccx.tcx, f_0))) {
             case (ty.ty_fn(?proto, _, _))   {
-                t_0 = ty.mk_fn(fcx.ccx.tystore, proto, arg_tys_0, rt_0);
+                t_0 = ty.mk_fn(fcx.ccx.tcx, proto, arg_tys_0, rt_0);
             }
             case (ty.ty_native_fn(?abi, _, _))   {
-                t_0 = ty.mk_native_fn(fcx.ccx.tystore, abi, arg_tys_0, rt_0);
+                t_0 = ty.mk_native_fn(fcx.ccx.tcx, abi, arg_tys_0, rt_0);
             }
             case (_) {
                 log_err "check_call_or_bind(): fn expr doesn't have fn type";
@@ -1721,7 +1710,7 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
         }
 
         // Unify the callee and arguments.
-        auto tpt_0 = ty.expr_ty_params_and_ty(fcx.ccx.tystore, f_0);
+        auto tpt_0 = ty.expr_ty_params_and_ty(fcx.ccx.tcx, f_0);
         auto tpt_1 = Demand.full(fcx, f.span, tpt_0._1, t_0, tpt_0._0,
                                  NO_AUTODEREF);
         auto f_1 = ty.replace_expr_type(f_0, tpt_1);
@@ -1734,15 +1723,14 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
         -> tup(@ast.expr, @ast.expr, ast.ann) {
         auto lhs_0 = check_expr(fcx, lhs);
         auto rhs_0 = check_expr(fcx, rhs);
-        auto lhs_t0 = expr_ty(fcx.ccx.tystore, lhs_0);
-        auto rhs_t0 = expr_ty(fcx.ccx.tystore, rhs_0);
+        auto lhs_t0 = expr_ty(fcx.ccx.tcx, lhs_0);
+        auto rhs_t0 = expr_ty(fcx.ccx.tcx, rhs_0);
 
         auto lhs_1 = Pushdown.pushdown_expr(fcx, rhs_t0, lhs_0);
-        auto rhs_1 = Pushdown.pushdown_expr(fcx,
-                                            expr_ty(fcx.ccx.tystore, lhs_1),
+        auto rhs_1 = Pushdown.pushdown_expr(fcx, expr_ty(fcx.ccx.tcx, lhs_1),
                                             rhs_0);
 
-        auto ann = triv_ann(expr_ty(fcx.ccx.tystore, rhs_1));
+        auto ann = triv_ann(expr_ty(fcx.ccx.tcx, rhs_1));
         ret tup(lhs_1, rhs_1, ann);
     }
 
@@ -1778,25 +1766,25 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
         case (ast.expr_binary(?binop, ?lhs, ?rhs, _)) {
             auto lhs_0 = check_expr(fcx, lhs);
             auto rhs_0 = check_expr(fcx, rhs);
-            auto lhs_t0 = expr_ty(fcx.ccx.tystore, lhs_0);
-            auto rhs_t0 = expr_ty(fcx.ccx.tystore, rhs_0);
+            auto lhs_t0 = expr_ty(fcx.ccx.tcx, lhs_0);
+            auto rhs_t0 = expr_ty(fcx.ccx.tcx, rhs_0);
 
             // FIXME: Binops have a bit more subtlety than this.
             auto lhs_1 = Pushdown.pushdown_expr_full(fcx, rhs_t0, lhs_0,
                                                      AUTODEREF_OK);
             auto rhs_1 =
                 Pushdown.pushdown_expr_full(fcx,
-                                            expr_ty(fcx.ccx.tystore, lhs_1),
+                                            expr_ty(fcx.ccx.tcx, lhs_1),
                                             rhs_0, AUTODEREF_OK);
 
-            auto t = strip_boxes(fcx.ccx.tystore, lhs_t0);
+            auto t = strip_boxes(fcx.ccx.tcx, lhs_t0);
             alt (binop) {
-                case (ast.eq) { t = ty.mk_bool(fcx.ccx.tystore); }
-                case (ast.lt) { t = ty.mk_bool(fcx.ccx.tystore); }
-                case (ast.le) { t = ty.mk_bool(fcx.ccx.tystore); }
-                case (ast.ne) { t = ty.mk_bool(fcx.ccx.tystore); }
-                case (ast.ge) { t = ty.mk_bool(fcx.ccx.tystore); }
-                case (ast.gt) { t = ty.mk_bool(fcx.ccx.tystore); }
+                case (ast.eq) { t = ty.mk_bool(fcx.ccx.tcx); }
+                case (ast.lt) { t = ty.mk_bool(fcx.ccx.tcx); }
+                case (ast.le) { t = ty.mk_bool(fcx.ccx.tcx); }
+                case (ast.ne) { t = ty.mk_bool(fcx.ccx.tcx); }
+                case (ast.ge) { t = ty.mk_bool(fcx.ccx.tcx); }
+                case (ast.gt) { t = ty.mk_bool(fcx.ccx.tcx); }
                 case (_) { /* fall through */ }
             }
 
@@ -1809,14 +1797,14 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
 
         case (ast.expr_unary(?unop, ?oper, _)) {
             auto oper_1 = check_expr(fcx, oper);
-            auto oper_t = expr_ty(fcx.ccx.tystore, oper_1);
+            auto oper_t = expr_ty(fcx.ccx.tcx, oper_1);
             alt (unop) {
                 case (ast.box(?mut)) {
-                    oper_t = ty.mk_box(fcx.ccx.tystore,
+                    oper_t = ty.mk_box(fcx.ccx.tcx,
                                        rec(ty=oper_t, mut=mut));
                 }
                 case (ast.deref) {
-                    alt (struct(fcx.ccx.tystore, oper_t)) {
+                    alt (struct(fcx.ccx.tcx, oper_t)) {
                         case (ty.ty_box(?inner)) {
                             oper_t = inner.ty;
                         }
@@ -1824,11 +1812,11 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
                             fcx.ccx.sess.span_err
                                 (expr.span,
                                  "dereferencing non-box type: "
-                                 + ty_to_str(fcx.ccx.tystore, oper_t));
+                                 + ty_to_str(fcx.ccx.tcx, oper_t));
                         }
                     }
                 }
-                case (_) { oper_t = strip_boxes(fcx.ccx.tystore, oper_t); }
+                case (_) { oper_t = strip_boxes(fcx.ccx.tcx, oper_t); }
             }
 
             auto ann = triv_ann(oper_t);
@@ -1837,7 +1825,7 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
         }
 
         case (ast.expr_path(?pth, ?defopt, _)) {
-            auto t = ty.mk_nil(fcx.ccx.tystore);
+            auto t = ty.mk_nil(fcx.ccx.tcx);
             check (defopt != none[ast.def]);
             auto defn = option.get[ast.def](defopt);
 
@@ -1863,7 +1851,7 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
 
         case (ast.expr_ext(?p, ?args, ?body, ?expanded, _)) {
             auto exp_ = check_expr(fcx, expanded);
-            auto t = expr_ty(fcx.ccx.tystore, exp_);
+            auto t = expr_ty(fcx.ccx.tcx, exp_);
             auto ann = triv_ann(t);
             ret @fold.respan[ast.expr_](expr.span,
                                         ast.expr_ext(p, args, body, exp_,
@@ -1872,23 +1860,23 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
 
         case (ast.expr_fail(_)) {
             ret @fold.respan[ast.expr_](expr.span,
-                ast.expr_fail(plain_ann(fcx.ccx.tystore)));
+                ast.expr_fail(plain_ann(fcx.ccx.tcx)));
         }
 
         case (ast.expr_break(_)) {
             ret @fold.respan[ast.expr_](expr.span,
-                ast.expr_break(plain_ann(fcx.ccx.tystore)));
+                ast.expr_break(plain_ann(fcx.ccx.tcx)));
         }
 
         case (ast.expr_cont(_)) {
             ret @fold.respan[ast.expr_](expr.span,
-                ast.expr_cont(plain_ann(fcx.ccx.tystore)));
+                ast.expr_cont(plain_ann(fcx.ccx.tcx)));
         }
 
         case (ast.expr_ret(?expr_opt, _)) {
             alt (expr_opt) {
                 case (none[@ast.expr]) {
-                    auto nil = ty.mk_nil(fcx.ccx.tystore);
+                    auto nil = ty.mk_nil(fcx.ccx.tcx);
                     if (!are_compatible(fcx, fcx.ret_ty, nil)) {
                         fcx.ccx.sess.err("ret; in function "
                                          + "returning non-nil");
@@ -1897,7 +1885,7 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
                     ret @fold.respan[ast.expr_]
                         (expr.span,
                          ast.expr_ret(none[@ast.expr],
-                                      plain_ann(fcx.ccx.tystore)));
+                                      plain_ann(fcx.ccx.tcx)));
                 }
 
                 case (some[@ast.expr](?e)) {
@@ -1906,7 +1894,7 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
                                                          expr_0);
                     ret @fold.respan[ast.expr_]
                         (expr.span, ast.expr_ret(some(expr_1),
-                                                 plain_ann(fcx.ccx.tystore)));
+                                                 plain_ann(fcx.ccx.tcx)));
                 }
             }
         }
@@ -1914,7 +1902,7 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
         case (ast.expr_put(?expr_opt, _)) {
             alt (expr_opt) {
                 case (none[@ast.expr]) {
-                    auto nil = ty.mk_nil(fcx.ccx.tystore);
+                    auto nil = ty.mk_nil(fcx.ccx.tcx);
                     if (!are_compatible(fcx, fcx.ret_ty, nil)) {
                         fcx.ccx.sess.err("put; in function "
                                          + "putting non-nil");
@@ -1922,7 +1910,7 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
 
                     ret @fold.respan[ast.expr_]
                         (expr.span, ast.expr_put(none[@ast.expr],
-                         plain_ann(fcx.ccx.tystore)));
+                         plain_ann(fcx.ccx.tcx)));
                 }
 
                 case (some[@ast.expr](?e)) {
@@ -1931,7 +1919,7 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
                                                          expr_0);
                     ret @fold.respan[ast.expr_]
                         (expr.span, ast.expr_put(some(expr_1),
-                                                 plain_ann(fcx.ccx.tystore)));
+                                                 plain_ann(fcx.ccx.tcx)));
                 }
             }
         }
@@ -1942,23 +1930,23 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
             auto expr_0 = check_expr(fcx, e);
             auto expr_1 = Pushdown.pushdown_expr(fcx, fcx.ret_ty, expr_0);
             ret @fold.respan[ast.expr_](expr.span,
-                ast.expr_be(expr_1, plain_ann(fcx.ccx.tystore)));
+                ast.expr_be(expr_1, plain_ann(fcx.ccx.tcx)));
         }
 
         case (ast.expr_log(?l,?e,_)) {
             auto expr_t = check_expr(fcx, e);
             ret @fold.respan[ast.expr_]
                 (expr.span, ast.expr_log(l, expr_t,
-                                         plain_ann(fcx.ccx.tystore)));
+                                         plain_ann(fcx.ccx.tcx)));
         }
 
         case (ast.expr_check_expr(?e, _)) {
             auto expr_t = check_expr(fcx, e);
-            Demand.simple(fcx, expr.span, ty.mk_bool(fcx.ccx.tystore),
-                          expr_ty(fcx.ccx.tystore, expr_t));
+            Demand.simple(fcx, expr.span, ty.mk_bool(fcx.ccx.tcx),
+                          expr_ty(fcx.ccx.tcx, expr_t));
             ret @fold.respan[ast.expr_]
                 (expr.span, ast.expr_check_expr(expr_t,
-                                                plain_ann(fcx.ccx.tystore)));
+                                                plain_ann(fcx.ccx.tcx)));
         }
 
         case (ast.expr_assign(?lhs, ?rhs, _)) {
@@ -1981,12 +1969,12 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
         case (ast.expr_send(?lhs, ?rhs, _)) {
             auto lhs_0 = check_expr(fcx, lhs);
             auto rhs_0 = check_expr(fcx, rhs);
-            auto rhs_t = expr_ty(fcx.ccx.tystore, rhs_0);
+            auto rhs_t = expr_ty(fcx.ccx.tcx, rhs_0);
 
-            auto chan_t = ty.mk_chan(fcx.ccx.tystore, rhs_t);
+            auto chan_t = ty.mk_chan(fcx.ccx.tcx, rhs_t);
             auto lhs_1 = Pushdown.pushdown_expr(fcx, chan_t, lhs_0);
             auto item_t;
-            alt (struct(fcx.ccx.tystore, expr_ty(fcx.ccx.tystore, lhs_1))) {
+            alt (struct(fcx.ccx.tcx, expr_ty(fcx.ccx.tcx, lhs_1))) {
                 case (ty.ty_chan(?it)) {
                     item_t = it;
                 }
@@ -2004,12 +1992,12 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
         case (ast.expr_recv(?lhs, ?rhs, _)) {
             auto lhs_0 = check_expr(fcx, lhs);
             auto rhs_0 = check_expr(fcx, rhs);
-            auto lhs_t1 = expr_ty(fcx.ccx.tystore, lhs_0);
+            auto lhs_t1 = expr_ty(fcx.ccx.tcx, lhs_0);
 
-            auto port_t = ty.mk_port(fcx.ccx.tystore, lhs_t1);
+            auto port_t = ty.mk_port(fcx.ccx.tcx, lhs_t1);
             auto rhs_1 = Pushdown.pushdown_expr(fcx, port_t, rhs_0);
             auto item_t;
-            alt (struct(fcx.ccx.tystore, expr_ty(fcx.ccx.tystore, rhs_0))) {
+            alt (struct(fcx.ccx.tcx, expr_ty(fcx.ccx.tcx, rhs_0))) {
                 case (ty.ty_port(?it)) {
                     item_t = it;
                 }
@@ -2026,12 +2014,11 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
 
         case (ast.expr_if(?cond, ?thn, ?elsopt, _)) {
             auto cond_0 = check_expr(fcx, cond);
-            auto cond_1 = Pushdown.pushdown_expr(fcx,
-                                                 ty.mk_bool(fcx.ccx.tystore),
+            auto cond_1 = Pushdown.pushdown_expr(fcx, ty.mk_bool(fcx.ccx.tcx),
                                                  cond_0);
 
             auto thn_0 = check_block(fcx, thn);
-            auto thn_t = block_ty(fcx.ccx.tystore, thn_0);
+            auto thn_t = block_ty(fcx.ccx.tcx, thn_0);
 
             auto elsopt_1;
             auto elsopt_t;
@@ -2040,11 +2027,11 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
                     auto els_0 = check_expr(fcx, els);
                     auto els_1 = Pushdown.pushdown_expr(fcx, thn_t, els_0);
                     elsopt_1 = some[@ast.expr](els_1);
-                    elsopt_t = expr_ty(fcx.ccx.tystore, els_1);
+                    elsopt_t = expr_ty(fcx.ccx.tcx, els_1);
                 }
                 case (none[@ast.expr]) {
                     elsopt_1 = none[@ast.expr];
-                    elsopt_t = ty.mk_nil(fcx.ccx.tystore);
+                    elsopt_t = ty.mk_nil(fcx.ccx.tcx);
                 }
             }
 
@@ -2064,7 +2051,7 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
             // FIXME: enforce that the type of the decl is the element type
             // of the seq.
 
-            auto ann = triv_ann(ty.mk_nil(fcx.ccx.tystore));
+            auto ann = triv_ann(ty.mk_nil(fcx.ccx.tcx));
             ret @fold.respan[ast.expr_](expr.span,
                                         ast.expr_for(decl_1, seq_1,
                                                      body_1, ann));
@@ -2075,7 +2062,7 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
             auto seq_1 = check_expr(fcx, seq);
             auto body_1 = check_block(fcx, body);
 
-            auto ann = triv_ann(ty.mk_nil(fcx.ccx.tystore));
+            auto ann = triv_ann(ty.mk_nil(fcx.ccx.tcx));
             ret @fold.respan[ast.expr_](expr.span,
                                         ast.expr_for_each(decl_1, seq_1,
                                                           body_1, ann));
@@ -2083,24 +2070,22 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
 
         case (ast.expr_while(?cond, ?body, _)) {
             auto cond_0 = check_expr(fcx, cond);
-            auto cond_1 = Pushdown.pushdown_expr(fcx,
-                                                 ty.mk_bool(fcx.ccx.tystore),
+            auto cond_1 = Pushdown.pushdown_expr(fcx, ty.mk_bool(fcx.ccx.tcx),
                                                  cond_0);
             auto body_1 = check_block(fcx, body);
 
-            auto ann = triv_ann(ty.mk_nil(fcx.ccx.tystore));
+            auto ann = triv_ann(ty.mk_nil(fcx.ccx.tcx));
             ret @fold.respan[ast.expr_](expr.span,
                                         ast.expr_while(cond_1, body_1, ann));
         }
 
         case (ast.expr_do_while(?body, ?cond, _)) {
             auto cond_0 = check_expr(fcx, cond);
-            auto cond_1 = Pushdown.pushdown_expr(fcx,
-                                                 ty.mk_bool(fcx.ccx.tystore),
+            auto cond_1 = Pushdown.pushdown_expr(fcx, ty.mk_bool(fcx.ccx.tcx),
                                                  cond_0);
             auto body_1 = check_block(fcx, body);
 
-            auto ann = triv_ann(block_ty(fcx.ccx.tystore, body_1));
+            auto ann = triv_ann(block_ty(fcx.ccx.tcx, body_1));
             ret @fold.respan[ast.expr_](expr.span,
                                         ast.expr_do_while(body_1, cond_1,
                                                           ann));
@@ -2111,13 +2096,13 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
 
             // Typecheck the patterns first, so that we get types for all the
             // bindings.
-            auto pattern_ty = expr_ty(fcx.ccx.tystore, expr_0);
+            auto pattern_ty = expr_ty(fcx.ccx.tcx, expr_0);
 
             let vec[@ast.pat] pats_0 = vec();
             for (ast.arm arm in arms) {
                 auto pat_0 = check_pat(fcx, arm.pat);
                 pattern_ty = Demand.simple(fcx, pat_0.span, pattern_ty,
-                                           pat_ty(fcx.ccx.tystore, pat_0));
+                                           pat_ty(fcx.ccx.tcx, pat_0));
                 pats_0 += vec(pat_0);
             }
 
@@ -2133,7 +2118,7 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
             for (ast.arm arm in arms) {
                 auto block_0 = check_block(fcx, arm.block);
                 result_ty = Demand.simple(fcx, block_0.span, result_ty,
-                                          block_ty(fcx.ccx.tystore, block_0));
+                                          block_ty(fcx.ccx.tcx, block_0));
                 blocks_0 += vec(block_0);
             }
 
@@ -2161,14 +2146,13 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
             auto ann;
             alt (b_0.node.expr) {
                 case (some[@ast.expr](?expr)) {
-                    ann = triv_ann(expr_ty(fcx.ccx.tystore, expr));
+                    ann = triv_ann(expr_ty(fcx.ccx.tcx, expr));
                 }
                 case (none[@ast.expr]) {
-                    ann = triv_ann(ty.mk_nil(fcx.ccx.tystore));
+                    ann = triv_ann(ty.mk_nil(fcx.ccx.tcx));
                 }
             }
-            ret @fold.respan[ast.expr_](expr.span,
-                                        ast.expr_block(b_0, ann));
+            ret @fold.respan[ast.expr_](expr.span, ast.expr_block(b_0, ann));
         }
 
         case (ast.expr_bind(?f, ?args, _)) {
@@ -2179,8 +2163,7 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
             auto proto_1;
             let vec[ty.arg] arg_tys_1 = vec();
             auto rt_1;
-            alt (struct(fcx.ccx.tystore,
-                        expr_ty(fcx.ccx.tystore, result._0))) {
+            alt (struct(fcx.ccx.tcx, expr_ty(fcx.ccx.tcx, result._0))) {
                 case (ty.ty_fn(?proto, ?arg_tys, ?rt)) {
                     proto_1 = proto;
                     rt_1 = rt;
@@ -2204,7 +2187,7 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
                 }
             }
 
-            auto t_1 = ty.mk_fn(fcx.ccx.tystore, proto_1, arg_tys_1, rt_1);
+            auto t_1 = ty.mk_fn(fcx.ccx.tcx, proto_1, arg_tys_1, rt_1);
             auto ann = triv_ann(t_1);
             ret @fold.respan[ast.expr_](expr.span,
                                         ast.expr_bind(result._0, result._1,
@@ -2217,8 +2200,8 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
             auto args_1 = result._1;
 
             // Pull the return type out of the type of the function.
-            auto rt_1 = ty.mk_nil(fcx.ccx.tystore);  // FIXME: typestate botch
-            alt (struct(fcx.ccx.tystore, expr_ty(fcx.ccx.tystore, f_1))) {
+            auto rt_1 = ty.mk_nil(fcx.ccx.tcx);  // FIXME: typestate botch
+            alt (struct(fcx.ccx.tcx, expr_ty(fcx.ccx.tcx, f_1))) {
                 case (ty.ty_fn(_,_,?rt))    { rt_1 = rt; }
                 case (ty.ty_native_fn(_, _, ?rt))    { rt_1 = rt; }
                 case (_) {
@@ -2233,7 +2216,7 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
         }
 
         case (ast.expr_self_method(?id, _)) {
-            auto t = ty.mk_nil(fcx.ccx.tystore);
+            auto t = ty.mk_nil(fcx.ccx.tcx);
             let ty.t this_obj_ty;
 
             // Grab the type of the current object
@@ -2241,7 +2224,7 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
             alt (this_obj_id) {
                 case (some[ast.def_id](?def_id)) {
                     this_obj_ty = ty.lookup_item_type(fcx.ccx.sess,
-                        fcx.ccx.tystore, fcx.ccx.type_cache, def_id)._1;
+                        fcx.ccx.tcx, fcx.ccx.type_cache, def_id)._1;
                 }
                 case (_) { fail; }
             }
@@ -2250,11 +2233,11 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
             // Grab this method's type out of the current object type
 
             // this_obj_ty is an ty.t
-            alt (struct(fcx.ccx.tystore, this_obj_ty)) {
+            alt (struct(fcx.ccx.tcx, this_obj_ty)) {
                 case (ty.ty_obj(?methods)) {
                     for (ty.method method in methods) {
                         if (method.ident == id) {
-                            t = ty.method_ty_to_fn_ty(fcx.ccx.tystore,
+                            t = ty.method_ty_to_fn_ty(fcx.ccx.tcx,
                                                       method);
                         }
                     }
@@ -2274,9 +2257,9 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
             auto args_1 = result._1;
 
             // Check the return type
-            alt (struct(fcx.ccx.tystore, expr_ty(fcx.ccx.tystore, f_1))) {
+            alt (struct(fcx.ccx.tcx, expr_ty(fcx.ccx.tcx, f_1))) {
                 case (ty.ty_fn(_,_,?rt)) {
-                    alt (struct(fcx.ccx.tystore, rt)) {
+                    alt (struct(fcx.ccx.tcx, rt)) {
                         case (ty.ty_nil) {
                             // This is acceptable
                         }
@@ -2292,7 +2275,7 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
 
             // FIXME: Other typechecks needed
 
-            auto ann = triv_ann(ty.mk_task(fcx.ccx.tystore));
+            auto ann = triv_ann(ty.mk_task(fcx.ccx.tcx));
             ret @fold.respan[ast.expr_](expr.span,
                                         ast.expr_spawn(dom, name,
                                                        f_1, args_1, ann));
@@ -2302,14 +2285,12 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
             auto e_1 = check_expr(fcx, e);
             auto t_1 = ast_ty_to_ty_crate(fcx.ccx, t);
             // FIXME: there are more forms of cast to support, eventually.
-            if (! (type_is_scalar(fcx.ccx.tystore,
-                                  expr_ty(fcx.ccx.tystore, e_1)) &&
-                   type_is_scalar(fcx.ccx.tystore, t_1))) {
+            if (! (type_is_scalar(fcx.ccx.tcx, expr_ty(fcx.ccx.tcx, e_1)) &&
+                   type_is_scalar(fcx.ccx.tcx, t_1))) {
                 fcx.ccx.sess.span_err(expr.span,
                     "non-scalar cast: " +
-                    ty_to_str(fcx.ccx.tystore,
-                              expr_ty(fcx.ccx.tystore, e_1)) + " as " +
-                    ty_to_str(fcx.ccx.tystore, t_1));
+                    ty_to_str(fcx.ccx.tcx, expr_ty(fcx.ccx.tcx, e_1)) +
+                    " as " + ty_to_str(fcx.ccx.tcx, t_1));
             }
 
             auto ann = triv_ann(t_1);
@@ -2325,17 +2306,17 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
                 t = next_ty_var(fcx.ccx);
             } else {
                 auto expr_1 = check_expr(fcx, args.(0));
-                t = expr_ty(fcx.ccx.tystore, expr_1);
+                t = expr_ty(fcx.ccx.tcx, expr_1);
             }
 
             for (@ast.expr e in args) {
                 auto expr_1 = check_expr(fcx, e);
-                auto expr_t = expr_ty(fcx.ccx.tystore, expr_1);
+                auto expr_t = expr_ty(fcx.ccx.tcx, expr_1);
                 Demand.simple(fcx, expr.span, t, expr_t);
                 _vec.push[@ast.expr](args_1,expr_1);
             }
 
-            auto ann = triv_ann(ty.mk_vec(fcx.ccx.tystore,
+            auto ann = triv_ann(ty.mk_vec(fcx.ccx.tcx,
                                           rec(ty=t, mut=mut)));
             ret @fold.respan[ast.expr_](expr.span,
                                         ast.expr_vec(args_1, mut, ann));
@@ -2347,12 +2328,12 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
 
             for (ast.elt e in elts) {
                 auto expr_1 = check_expr(fcx, e.expr);
-                auto expr_t = expr_ty(fcx.ccx.tystore, expr_1);
+                auto expr_t = expr_ty(fcx.ccx.tcx, expr_1);
                 _vec.push[ast.elt](elts_1, rec(expr=expr_1 with e));
                 elts_mt += vec(rec(ty=expr_t, mut=e.mut));
             }
 
-            auto ann = triv_ann(ty.mk_tup(fcx.ccx.tystore, elts_mt));
+            auto ann = triv_ann(ty.mk_tup(fcx.ccx.tcx, elts_mt));
             ret @fold.respan[ast.expr_](expr.span,
                                         ast.expr_tup(elts_1, ann));
         }
@@ -2372,7 +2353,7 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
 
             for (ast.field f in fields) {
                 auto expr_1 = check_expr(fcx, f.expr);
-                auto expr_t = expr_ty(fcx.ccx.tystore, expr_1);
+                auto expr_t = expr_ty(fcx.ccx.tcx, expr_1);
                 _vec.push[ast.field](fields_1, rec(expr=expr_1 with f));
 
                 auto expr_mt = rec(ty=expr_t, mut=f.mut);
@@ -2383,16 +2364,16 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
 
             alt (base) {
                 case (none[@ast.expr]) {
-                    ann = triv_ann(ty.mk_rec(fcx.ccx.tystore, fields_t));
+                    ann = triv_ann(ty.mk_rec(fcx.ccx.tcx, fields_t));
                 }
 
                 case (some[@ast.expr](?bexpr)) {
                     auto bexpr_1 = check_expr(fcx, bexpr);
-                    auto bexpr_t = expr_ty(fcx.ccx.tystore, bexpr_1);
+                    auto bexpr_t = expr_ty(fcx.ccx.tcx, bexpr_1);
 
                     let vec[field] base_fields = vec();
 
-                    alt (struct(fcx.ccx.tystore, bexpr_t)) {
+                    alt (struct(fcx.ccx.tcx, bexpr_t)) {
                         case (ty.ty_rec(?flds)) {
                             base_fields = flds;
                         }
@@ -2430,9 +2411,9 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
 
         case (ast.expr_field(?base, ?field, _)) {
             auto base_1 = check_expr(fcx, base);
-            auto base_t = strip_boxes(fcx.ccx.tystore,
-                                      expr_ty(fcx.ccx.tystore, base_1));
-            alt (struct(fcx.ccx.tystore, base_t)) {
+            auto base_t = strip_boxes(fcx.ccx.tcx,
+                                      expr_ty(fcx.ccx.tcx, base_1));
+            alt (struct(fcx.ccx.tcx, base_t)) {
                 case (ty.ty_tup(?args)) {
                     let uint ix = ty.field_num(fcx.ccx.sess,
                                                expr.span, field);
@@ -2469,7 +2450,7 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
                                               "bad index on obj");
                     }
                     auto meth = methods.(ix);
-                    auto t = ty.mk_fn(fcx.ccx.tystore, meth.proto,
+                    auto t = ty.mk_fn(fcx.ccx.tcx, meth.proto,
                                       meth.inputs, meth.output);
                     auto ann = triv_ann(t);
                     ret @fold.respan[ast.expr_](expr.span,
@@ -2481,26 +2462,25 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
                 case (_) {
                     fcx.ccx.sess.span_unimpl(expr.span,
                         "base type for expr_field in typeck.check_expr: " +
-                        ty_to_str(fcx.ccx.tystore, base_t));
+                        ty_to_str(fcx.ccx.tcx, base_t));
                 }
             }
         }
 
         case (ast.expr_index(?base, ?idx, _)) {
             auto base_1 = check_expr(fcx, base);
-            auto base_t = strip_boxes(fcx.ccx.tystore,
-                                      expr_ty(fcx.ccx.tystore, base_1));
+            auto base_t = strip_boxes(fcx.ccx.tcx,
+                                      expr_ty(fcx.ccx.tcx, base_1));
 
             auto idx_1 = check_expr(fcx, idx);
-            auto idx_t = expr_ty(fcx.ccx.tystore, idx_1);
-
-            alt (struct(fcx.ccx.tystore, base_t)) {
+            auto idx_t = expr_ty(fcx.ccx.tcx, idx_1); 
+            alt (struct(fcx.ccx.tcx, base_t)) {
                 case (ty.ty_vec(?mt)) {
-                    if (! type_is_integral(fcx.ccx.tystore, idx_t)) {
+                    if (! type_is_integral(fcx.ccx.tcx, idx_t)) {
                         fcx.ccx.sess.span_err
                             (idx.span,
                              "non-integral type of vec index: "
-                             + ty_to_str(fcx.ccx.tystore, idx_t));
+                             + ty_to_str(fcx.ccx.tcx, idx_t));
                     }
                     auto ann = triv_ann(mt.ty);
                     ret @fold.respan[ast.expr_](expr.span,
@@ -2509,13 +2489,13 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
                                                                ann));
                 }
                 case (ty.ty_str) {
-                    if (! type_is_integral(fcx.ccx.tystore, idx_t)) {
+                    if (! type_is_integral(fcx.ccx.tcx, idx_t)) {
                         fcx.ccx.sess.span_err
                             (idx.span,
                              "non-integral type of str index: "
-                             + ty_to_str(fcx.ccx.tystore, idx_t));
+                             + ty_to_str(fcx.ccx.tcx, idx_t));
                     }
-                    auto ann = triv_ann(ty.mk_mach(fcx.ccx.tystore,
+                    auto ann = triv_ann(ty.mk_mach(fcx.ccx.tcx,
                                                    common.ty_u8));
                     ret @fold.respan[ast.expr_](expr.span,
                                                 ast.expr_index(base_1,
@@ -2526,32 +2506,31 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
                     fcx.ccx.sess.span_err
                         (expr.span,
                          "vector-indexing bad type: "
-                         + ty_to_str(fcx.ccx.tystore, base_t));
+                         + ty_to_str(fcx.ccx.tcx, base_t));
                 }
             }
         }
 
         case (ast.expr_port(_)) {
             auto t = next_ty_var(fcx.ccx);
-            auto pt = ty.mk_port(fcx.ccx.tystore, t);
+            auto pt = ty.mk_port(fcx.ccx.tcx, t);
             auto ann = triv_ann(pt);
             ret @fold.respan[ast.expr_](expr.span, ast.expr_port(ann));
         }
 
         case (ast.expr_chan(?x, _)) {
             auto expr_1 = check_expr(fcx, x);
-            auto port_t = expr_ty(fcx.ccx.tystore, expr_1);
-            alt (struct(fcx.ccx.tystore, port_t)) {
+            auto port_t = expr_ty(fcx.ccx.tcx, expr_1);
+            alt (struct(fcx.ccx.tcx, port_t)) {
                 case (ty.ty_port(?subtype)) {
-                    auto ct = ty.mk_chan(fcx.ccx.tystore, subtype);
+                    auto ct = ty.mk_chan(fcx.ccx.tcx, subtype);
                     auto ann = triv_ann(ct);
                     ret @fold.respan[ast.expr_](expr.span,
                                                 ast.expr_chan(expr_1, ann));
                 }
                 case (_) {
                     fcx.ccx.sess.span_err(expr.span,
-                        "bad port type: " + ty_to_str(fcx.ccx.tystore,
-                                                      port_t));
+                        "bad port type: " + ty_to_str(fcx.ccx.tcx, port_t));
                 }
             }
         }
@@ -2565,7 +2544,7 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
 }
 
 fn next_ty_var(@crate_ctxt ccx) -> ty.t {
-    auto t = ty.mk_var(ccx.tystore, ccx.next_var_id);
+    auto t = ty.mk_var(ccx.tcx, ccx.next_var_id);
     ccx.next_var_id += 1;
     ret t;
 }
@@ -2576,7 +2555,7 @@ fn check_decl_local(&@fn_ctxt fcx, &@ast.decl decl) -> @ast.decl {
 
             auto t;
 
-            t = ty.mk_nil(fcx.ccx.tystore);
+            t = ty.mk_nil(fcx.ccx.tcx);
             
             alt (local.ty) {
                 case (none[@ast.ty]) {
@@ -2602,14 +2581,14 @@ fn check_decl_local(&@fn_ctxt fcx, &@ast.decl decl) -> @ast.decl {
             alt (local.init) {
                 case (some[ast.initializer](?init)) {
                     auto expr_0 = check_expr(fcx, init.expr);
-                    auto lty = ty.mk_local(fcx.ccx.tystore, local.id);
+                    auto lty = ty.mk_local(fcx.ccx.tcx, local.id);
                     auto expr_1;
                     alt (init.op) {
                         case (ast.init_assign) {
                             expr_1 = Pushdown.pushdown_expr(fcx, lty, expr_0);
                         }
                         case (ast.init_recv) {
-                            auto port_ty = ty.mk_port(fcx.ccx.tystore, lty);
+                            auto port_ty = ty.mk_port(fcx.ccx.tcx, lty);
                             expr_1 = Pushdown.pushdown_expr(fcx, port_ty,
                                                             expr_0);
                         }
@@ -2647,8 +2626,7 @@ fn check_stmt(&@fn_ctxt fcx, &@ast.stmt stmt) -> @ast.stmt {
 
         case (ast.stmt_expr(?expr,?a)) {
             auto expr_t = check_expr(fcx, expr);
-            expr_t = Pushdown.pushdown_expr(fcx,
-                                            expr_ty(fcx.ccx.tystore, expr_t),
+            expr_t = Pushdown.pushdown_expr(fcx, expr_ty(fcx.ccx.tcx, expr_t),
                                             expr_t);
             ret @fold.respan[ast.stmt_](stmt.span, ast.stmt_expr(expr_t, a));
         }
@@ -2669,7 +2647,7 @@ fn check_block(&@fn_ctxt fcx, &ast.block block) -> ast.block {
         case (some[@ast.expr](?e)) {
             auto expr_t = check_expr(fcx, e);
             expr_t = Pushdown.pushdown_expr(fcx,
-                                            expr_ty(fcx.ccx.tystore, expr_t),
+                                            expr_ty(fcx.ccx.tcx, expr_t),
                                             expr_t);
             expr = some[@ast.expr](expr_t);
         }
@@ -2678,7 +2656,7 @@ fn check_block(&@fn_ctxt fcx, &ast.block block) -> ast.block {
     ret fold.respan[ast.block_](block.span,
                                 rec(stmts=stmts, expr=expr,
                                     index=block.node.index,
-                                    a=plain_ann(fcx.ccx.tystore)));
+                                    a=plain_ann(fcx.ccx.tcx)));
 }
 
 fn check_const(&@crate_ctxt ccx, &span sp, ast.ident ident, @ast.ty t,
@@ -2745,7 +2723,7 @@ fn check_item_fn(&@crate_ctxt ccx, &span sp, ast.ident ident, &ast._fn f,
     }
 
     auto output_ty = ast_ty_to_ty_crate(ccx, f.decl.output);
-    auto fn_ann = triv_ann(ty.mk_fn(ccx.tystore, f.proto, inputs, output_ty));
+    auto fn_ann = triv_ann(ty.mk_fn(ccx.tcx, f.proto, inputs, output_ty));
 
     auto item = ast.item_fn(ident, f, ty_params, id, fn_ann);
     ret @fold.respan[ast.item_](sp, item);
@@ -2799,10 +2777,9 @@ fn eq_unify_cache_entry(&unify_cache_entry a, &unify_cache_entry b) -> bool {
 
 type typecheck_result = tup(@ast.crate, ty.type_cache);
 
-fn check_crate(session.session sess,
-               @ty.type_store tystore,
-               @ast.crate crate) -> typecheck_result {
-    auto result = Collect.collect_item_types(sess, tystore, crate);
+fn check_crate(session.session sess, ty.ctxt tcx, @ast.crate crate)
+        -> typecheck_result {
+    auto result = Collect.collect_item_types(sess, tcx, crate);
 
     let vec[ast.obj_field] fields = vec();
 
@@ -2820,7 +2797,7 @@ fn check_crate(session.session sess,
                     unify_cache=unify_cache,
                     mutable cache_hits=0u,
                     mutable cache_misses=0u,
-                    tystore=tystore);
+                    tcx=tcx);
 
     auto fld = fold.new_identity_fold[@crate_ctxt]();
 
diff --git a/src/comp/util/common.rs b/src/comp/util/common.rs
index 0d0ca05da4b..a9e02c20e03 100644
--- a/src/comp/util/common.rs
+++ b/src/comp/util/common.rs
@@ -110,8 +110,8 @@ fn field_exprs(vec[ast.field] fields) -> vec [@ast.expr] {
     ret _vec.map[ast.field, @ast.expr](f, fields);
 }
 
-fn plain_ann(@middle.ty.type_store tystore) -> ast.ann {
-  ret ast.ann_type(middle.ty.mk_nil(tystore),
+fn plain_ann(middle.ty.ctxt tcx) -> ast.ann {
+  ret ast.ann_type(middle.ty.mk_nil(tcx),
                    none[vec[middle.ty.t]], none[@ts_ann]);
 }