librustc: Remove ty_param_defs from the type context
This commit is contained in:
parent
d803a0f733
commit
3e9bcea018
4 changed files with 29 additions and 14 deletions
|
|
@ -963,8 +963,11 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
|
|||
}
|
||||
|
||||
{
|
||||
let r = tcx.ty_param_defs.find(&id);
|
||||
for &type_param_def in r.iter() {
|
||||
let r = {
|
||||
let ty_param_defs = tcx.ty_param_defs.borrow();
|
||||
ty_param_defs.get().find(&id).map(|def| *def)
|
||||
};
|
||||
for type_param_def in r.iter() {
|
||||
ebml_w.tag(c::tag_table_param_defs, |ebml_w| {
|
||||
ebml_w.id(id);
|
||||
ebml_w.tag(c::tag_table_val, |ebml_w| {
|
||||
|
|
@ -1247,7 +1250,10 @@ fn decode_side_tables(xcx: @ExtendedDecodeContext,
|
|||
}
|
||||
c::tag_table_param_defs => {
|
||||
let bounds = val_dsr.read_type_param_def(xcx);
|
||||
dcx.tcx.ty_param_defs.insert(id, bounds);
|
||||
let mut ty_param_defs = dcx.tcx
|
||||
.ty_param_defs
|
||||
.borrow_mut();
|
||||
ty_param_defs.get().insert(id, bounds);
|
||||
}
|
||||
c::tag_table_method_map => {
|
||||
dcx.maps.method_map.insert(
|
||||
|
|
|
|||
|
|
@ -311,7 +311,7 @@ struct ctxt_ {
|
|||
tc_cache: RefCell<HashMap<uint, TypeContents>>,
|
||||
ast_ty_to_ty_cache: RefCell<HashMap<NodeId, ast_ty_to_ty_cache_entry>>,
|
||||
enum_var_cache: RefCell<HashMap<DefId, @~[@VariantInfo]>>,
|
||||
ty_param_defs: @mut HashMap<ast::NodeId, TypeParameterDef>,
|
||||
ty_param_defs: RefCell<HashMap<ast::NodeId, TypeParameterDef>>,
|
||||
adjustments: @mut HashMap<ast::NodeId, @AutoAdjustment>,
|
||||
normalized_cache: @mut HashMap<t, t>,
|
||||
lang_items: middle::lang_items::LanguageItems,
|
||||
|
|
@ -1001,7 +1001,7 @@ pub fn mk_ctxt(s: session::Session,
|
|||
trait_method_def_ids: RefCell::new(HashMap::new()),
|
||||
trait_methods_cache: RefCell::new(HashMap::new()),
|
||||
impl_trait_cache: RefCell::new(HashMap::new()),
|
||||
ty_param_defs: @mut HashMap::new(),
|
||||
ty_param_defs: RefCell::new(HashMap::new()),
|
||||
adjustments: @mut HashMap::new(),
|
||||
normalized_cache: new_ty_hash(),
|
||||
lang_items: lang_items,
|
||||
|
|
@ -2123,7 +2123,8 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents {
|
|||
// def-id.
|
||||
assert_eq!(p.def_id.crate, ast::LOCAL_CRATE);
|
||||
|
||||
let tp_def = cx.ty_param_defs.get(&p.def_id.node);
|
||||
let ty_param_defs = cx.ty_param_defs.borrow();
|
||||
let tp_def = ty_param_defs.get().get(&p.def_id.node);
|
||||
kind_bounds_to_contents(cx,
|
||||
tp_def.bounds.builtin_bounds,
|
||||
tp_def.bounds.trait_bounds)
|
||||
|
|
@ -2568,7 +2569,8 @@ pub fn type_is_sized(cx: ctxt, ty: ty::t) -> bool {
|
|||
match get(ty).sty {
|
||||
// FIXME(#6308) add trait, vec, str, etc here.
|
||||
ty_param(p) => {
|
||||
let param_def = cx.ty_param_defs.get(&p.def_id.node);
|
||||
let ty_param_defs = cx.ty_param_defs.borrow();
|
||||
let param_def = ty_param_defs.get().get(&p.def_id.node);
|
||||
if param_def.bounds.builtin_bounds.contains_elem(BoundSized) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -892,8 +892,12 @@ pub fn ty_generics(ccx: &CrateCtxt,
|
|||
def_id: local_def(l.id) }
|
||||
}).collect(),
|
||||
type_param_defs: @generics.ty_params.mapi_to_vec(|offset, param| {
|
||||
match ccx.tcx.ty_param_defs.find(¶m.id) {
|
||||
Some(&def) => def,
|
||||
let existing_def_opt = {
|
||||
let ty_param_defs = ccx.tcx.ty_param_defs.borrow();
|
||||
ty_param_defs.get().find(¶m.id).map(|def| *def)
|
||||
};
|
||||
match existing_def_opt {
|
||||
Some(def) => def,
|
||||
None => {
|
||||
let param_ty = ty::param_ty {idx: base_index + offset,
|
||||
def_id: local_def(param.id)};
|
||||
|
|
@ -904,7 +908,11 @@ pub fn ty_generics(ccx: &CrateCtxt,
|
|||
bounds: bounds
|
||||
};
|
||||
debug!("def for param: {}", def.repr(ccx.tcx));
|
||||
ccx.tcx.ty_param_defs.insert(param.id, def);
|
||||
|
||||
let mut ty_param_defs = ccx.tcx
|
||||
.ty_param_defs
|
||||
.borrow_mut();
|
||||
ty_param_defs.get().insert(param.id, def);
|
||||
def
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -472,11 +472,10 @@ pub fn ty_to_str(cx: ctxt, typ: t) -> ~str {
|
|||
ty_infer(infer_ty) => infer_ty.to_str(),
|
||||
ty_err => ~"[type error]",
|
||||
ty_param(param_ty {idx: id, def_id: did}) => {
|
||||
let param_def = cx.ty_param_defs.find(&did.node);
|
||||
let ty_param_defs = cx.ty_param_defs.borrow();
|
||||
let param_def = ty_param_defs.get().find(&did.node);
|
||||
let ident = match param_def {
|
||||
Some(def) => {
|
||||
cx.sess.str_of(def.ident).to_owned()
|
||||
}
|
||||
Some(def) => cx.sess.str_of(def.ident).to_owned(),
|
||||
None => {
|
||||
// This should not happen...
|
||||
format!("BUG[{:?}]", id)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue