librustc: De-@mut the ast_ty_to_ty_cache.

This commit is contained in:
Patrick Walton 2013-12-19 16:54:48 -08:00
parent b941677ea3
commit ab0d7b2312
2 changed files with 18 additions and 11 deletions

View File

@ -310,7 +310,7 @@ struct ctxt_ {
short_names_cache: RefCell<HashMap<t, @str>>,
needs_unwind_cleanup_cache: RefCell<HashMap<t, bool>>,
tc_cache: RefCell<HashMap<uint, TypeContents>>,
ast_ty_to_ty_cache: @mut HashMap<NodeId, ast_ty_to_ty_cache_entry>,
ast_ty_to_ty_cache: RefCell<HashMap<NodeId, ast_ty_to_ty_cache_entry>>,
enum_var_cache: @mut HashMap<DefId, @~[@VariantInfo]>,
ty_param_defs: @mut HashMap<ast::NodeId, TypeParameterDef>,
adjustments: @mut HashMap<ast::NodeId, @AutoAdjustment>,
@ -996,7 +996,7 @@ pub fn mk_ctxt(s: session::Session,
short_names_cache: RefCell::new(HashMap::new()),
needs_unwind_cleanup_cache: RefCell::new(HashMap::new()),
tc_cache: RefCell::new(HashMap::new()),
ast_ty_to_ty_cache: @mut HashMap::new(),
ast_ty_to_ty_cache: RefCell::new(HashMap::new()),
enum_var_cache: @mut HashMap::new(),
methods: RefCell::new(HashMap::new()),
trait_method_def_ids: RefCell::new(HashMap::new()),

View File

@ -383,16 +383,22 @@ fn check_path_args(tcx: ty::ctxt,
let tcx = this.tcx();
match tcx.ast_ty_to_ty_cache.find(&ast_ty.id) {
Some(&ty::atttce_resolved(ty)) => return ty,
Some(&ty::atttce_unresolved) => {
tcx.sess.span_fatal(ast_ty.span, "illegal recursive type; \
insert an enum in the cycle, if this is desired");
}
None => { /* go on */ }
{
let mut ast_ty_to_ty_cache = tcx.ast_ty_to_ty_cache.borrow_mut();
match ast_ty_to_ty_cache.get().find(&ast_ty.id) {
Some(&ty::atttce_resolved(ty)) => return ty,
Some(&ty::atttce_unresolved) => {
tcx.sess.span_fatal(ast_ty.span,
"illegal recursive type; insert an enum \
or struct in the cycle, if this is \
desired");
}
None => { /* go on */ }
}
ast_ty_to_ty_cache.get().insert(ast_ty.id, ty::atttce_unresolved);
}
tcx.ast_ty_to_ty_cache.insert(ast_ty.id, ty::atttce_unresolved);
let typ = match ast_ty.node {
ast::ty_nil => ty::mk_nil(),
ast::ty_bot => ty::mk_bot(),
@ -576,7 +582,8 @@ fn check_path_args(tcx: ty::ctxt,
}
};
tcx.ast_ty_to_ty_cache.insert(ast_ty.id, ty::atttce_resolved(typ));
let mut ast_ty_to_ty_cache = tcx.ast_ty_to_ty_cache.borrow_mut();
ast_ty_to_ty_cache.get().insert(ast_ty.id, ty::atttce_resolved(typ));
return typ;
}