diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs index 1575631451c8..32d9ee1678f0 100644 --- a/src/comp/front/ast.rs +++ b/src/comp/front/ast.rs @@ -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 { diff --git a/src/comp/middle/ty.rs b/src/comp/middle/ty.rs index 70557a97ed47..4e33b0b844b4 100644 --- a/src/comp/middle/ty.rs +++ b/src/comp/middle/ty.rs @@ -61,11 +61,6 @@ type item_table = hashmap[ast::def_id,any_item]; 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 ctxt = rec(@type_store ts, 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; diff --git a/src/comp/middle/typeck.rs b/src/comp/middle/typeck.rs index 690ecd4aba86..0c21090d6e48 100644 --- a/src/comp/middle/typeck.rs +++ b/src/comp/middle/typeck.rs @@ -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 ast_ty_to_ty(&ty::ctxt tcx, &ty_getter getter, &@ast::ty ast_ty) -> ty::t { } } - 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; } diff --git a/src/test/compile-fail/type-recursive.rs b/src/test/compile-fail/type-recursive.rs index 763f1f9b3e42..5de96b82a791 100644 --- a/src/test/compile-fail/type-recursive.rs +++ b/src/test/compile-fail/type-recursive.rs @@ -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() {}