about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMarijn Haverbeke <marijnh@gmail.com>2012-03-01 17:50:08 +0100
committerMarijn Haverbeke <marijnh@gmail.com>2012-03-01 17:50:08 +0100
commit03984561d43130cb8d51025604ac882470d47e3c (patch)
treed2a79f6c4e0bdd8b115935c2c32f29647cdf7aaa
parent072b0155151329b323540d521bffe3eb49873799 (diff)
downloadrust-03984561d43130cb8d51025604ac882470d47e3c.tar.gz
rust-03984561d43130cb8d51025604ac882470d47e3c.zip
Make sure resource item types get written by typechecker
Closes #1916
-rw-r--r--src/comp/middle/typeck.rs12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/comp/middle/typeck.rs b/src/comp/middle/typeck.rs
index 265f5717461..40cd1d37a8d 100644
--- a/src/comp/middle/typeck.rs
+++ b/src/comp/middle/typeck.rs
@@ -420,11 +420,11 @@ fn ast_ty_to_ty(tcx: ty::ctxt, mode: mode, &&ast_ty: @ast::ty) -> ty::t {
 
 fn ty_of_item(tcx: ty::ctxt, mode: mode, it: @ast::item)
     -> ty::ty_param_bounds_and_ty {
-    alt tcx.tcache.find(local_def(it.id)) {
+    let def_id = local_def(it.id);
+    alt tcx.tcache.find(def_id) {
       some(tpt) { ret tpt; }
       _ {}
     }
-    let def_id = {crate: ast::local_crate, node: it.id};
     alt it.node {
       ast::item_const(t, _) {
         let typ = ast_ty_to_ty(tcx, mode, t);
@@ -917,9 +917,10 @@ mod collect {
           }
           ast::item_res(decl, tps, _, dtor_id, ctor_id) {
             let {bounds, params} = mk_ty_params(tcx, tps);
+            let def_id = local_def(it.id);
             let t_arg = ty_of_arg(tcx, m_collect, decl.inputs[0]);
-            let t_res = ty::mk_res(tcx, local_def(it.id), t_arg.ty,
-                                   params);
+            let t_res = ty::mk_res(tcx, def_id, t_arg.ty, params);
+            let t_res = ty::mk_with_id(tcx, t_res, def_id);
             let t_ctor = ty::mk_fn(tcx, {
                 proto: ast::proto_box,
                 inputs: [{mode: ast::expl(ast::by_copy) with t_arg}],
@@ -934,7 +935,8 @@ mod collect {
             write_ty(tcx, it.id, t_res);
             write_ty(tcx, ctor_id, t_ctor);
             tcx.tcache.insert(local_def(ctor_id),
-                                 {bounds: bounds, ty: t_ctor});
+                              {bounds: bounds, ty: t_ctor});
+            tcx.tcache.insert(def_id, {bounds: bounds, ty: t_res});
             write_ty(tcx, dtor_id, t_dtor);
           }
           ast::item_iface(_, ms) {