]> git.lizzy.rs Git - rust.git/commitdiff
Implement pcwalton's code review suggestions.
authorPaul Stansifer <paul.stansifer@gmail.com>
Thu, 2 Jun 2011 22:12:17 +0000 (15:12 -0700)
committerPaul Stansifer <paul.stansifer@gmail.com>
Thu, 2 Jun 2011 22:12:17 +0000 (15:12 -0700)
src/comp/front/ast.rs
src/comp/middle/ty.rs
src/comp/middle/typeck.rs
src/test/compile-fail/type-recursive.rs

index 1575631451c89e18087f574a8abbc4e95c51de66..32d9ee1678f00695a91896acf8ccbefae74eb5aa 100644 (file)
@@ -504,7 +504,7 @@ fn is_constraint_arg(@expr e) -> bool {
 }
 
 fn eq_ty(&@ty a, &@ty b) -> bool {
-    ret a == b;
+    ret std::box::ptr_eq(a,b);
 }
 
 fn hash_ty(&@ty t) -> uint {
index 70557a97ed473acc31be419657e3fecc33d280d6..4e33b0b844b4124bfaf66072da5744005ffb1d4f 100644 (file)
 
 type mt = rec(t ty, ast::mutability mut);
 
-tag cached_ty {
-    in_progress;
-    done(t);
-}
-
 // Contains information needed to resolve types and (in the future) look up
 // the types of AST nodes.
 type creader_cache = hashmap[tup(int,uint,uint),ty::t];
@@ -77,7 +72,7 @@
                 type_cache tcache,
                 creader_cache rcache,
                 hashmap[t,str] short_names_cache,
-                hashmap[@ast::ty,cached_ty] ast_ty_to_ty_cache);
+                hashmap[@ast::ty,option::t[t]] ast_ty_to_ty_cache);
 type ty_ctxt = ctxt;    // Needed for disambiguation from unify::ctxt.
 
 // Convert from method type to function type.  Pretty easy; we just drop
@@ -253,7 +248,7 @@ fn mk_ctxt(session::session s, resolve::def_map dm) -> ctxt {
             short_names_cache =
             map::mk_hashmap[ty::t,str](ty::hash_ty, ty::eq_ty),
             ast_ty_to_ty_cache = 
-            map::mk_hashmap[@ast::ty,cached_ty](ast::hash_ty, ast::eq_ty));
+            map::mk_hashmap[@ast::ty,option::t[t]](ast::hash_ty, ast::eq_ty));
 
     populate_type_store(cx);
     ret cx;
index 690ecd4aba861cb742d61d3d14dcb5b422b86ced..0c21090d6e48acfe8cb7b4d168db3ca01a885f40 100644 (file)
@@ -228,14 +228,14 @@ fn ast_mode_to_mode(ast::mode mode) -> ty::mode {
 // corresponding to a definition ID:
 fn ast_ty_to_ty(&ty::ctxt tcx, &ty_getter getter, &@ast::ty ast_ty) -> ty::t {
     alt (tcx.ast_ty_to_ty_cache.find(ast_ty)) {
-        case (some[ty::cached_ty](ty::done(?ty))) { ret ty; } 
-        case (some[ty::cached_ty](ty::in_progress)) {
+        case (some[option::t[ty::t]](some[ty::t](?ty))) { ret ty; } 
+        case (some[option::t[ty::t]](none)) {
             tcx.sess.span_err(ast_ty.span, "illegal recursive type "
                 + "(insert a tag in the cycle, if this is desired)");
         }
-        case (none[ty::cached_ty]) { } /* go on */
+        case (none[option::t[ty::t]]) { } /* go on */
     }
-    tcx.ast_ty_to_ty_cache.insert(ast_ty, ty::in_progress);
+    tcx.ast_ty_to_ty_cache.insert(ast_ty, none[ty::t]);
     
     fn ast_arg_to_arg(&ty::ctxt tcx,
                       &ty_getter getter,
@@ -371,7 +371,7 @@ fn instantiate(&ty::ctxt tcx,
         }
     }
 
-    tcx.ast_ty_to_ty_cache.insert(ast_ty, ty::done(typ));
+    tcx.ast_ty_to_ty_cache.insert(ast_ty, some(typ));
     ret typ;
 }
 
index 763f1f9b3e42f0da32f97bf1167a12db11a9b285..5de96b82a791c7857787d9d3a2d0c44ad2931547 100644 (file)
@@ -1,4 +1,4 @@
 // error-pattern:illegal recursive type
 type t1 = rec(int foo, t1 foolish);
 
-fn main() {}
\ No newline at end of file
+fn main() {}