Implement pcwalton's code review suggestions.

This commit is contained in:
Paul Stansifer 2011-06-02 15:12:17 -07:00
parent 5cd10d2fef
commit 1377e9b341
4 changed files with 9 additions and 14 deletions

View 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 {

View File

@ -61,11 +61,6 @@
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;

View 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;
}