Skip to content

Commit 1b01b83

Browse files
committed
---
yaml --- r: 147542 b: refs/heads/try2 c: 3e9bcea h: refs/heads/master v: v3
1 parent b4a212b commit 1b01b83

File tree

5 files changed

+30
-15
lines changed

5 files changed

+30
-15
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: d803a0f7334a5283e762b1b32dc12d50871ba7fd
8+
refs/heads/try2: 3e9bcea018d179bf361cbaee04e2db506ffac4a9
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/librustc/middle/astencode.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -963,8 +963,11 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
963963
}
964964

965965
{
966-
let r = tcx.ty_param_defs.find(&id);
967-
for &type_param_def in r.iter() {
966+
let r = {
967+
let ty_param_defs = tcx.ty_param_defs.borrow();
968+
ty_param_defs.get().find(&id).map(|def| *def)
969+
};
970+
for type_param_def in r.iter() {
968971
ebml_w.tag(c::tag_table_param_defs, |ebml_w| {
969972
ebml_w.id(id);
970973
ebml_w.tag(c::tag_table_val, |ebml_w| {
@@ -1247,7 +1250,10 @@ fn decode_side_tables(xcx: @ExtendedDecodeContext,
12471250
}
12481251
c::tag_table_param_defs => {
12491252
let bounds = val_dsr.read_type_param_def(xcx);
1250-
dcx.tcx.ty_param_defs.insert(id, bounds);
1253+
let mut ty_param_defs = dcx.tcx
1254+
.ty_param_defs
1255+
.borrow_mut();
1256+
ty_param_defs.get().insert(id, bounds);
12511257
}
12521258
c::tag_table_method_map => {
12531259
dcx.maps.method_map.insert(

branches/try2/src/librustc/middle/ty.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ struct ctxt_ {
311311
tc_cache: RefCell<HashMap<uint, TypeContents>>,
312312
ast_ty_to_ty_cache: RefCell<HashMap<NodeId, ast_ty_to_ty_cache_entry>>,
313313
enum_var_cache: RefCell<HashMap<DefId, @~[@VariantInfo]>>,
314-
ty_param_defs: @mut HashMap<ast::NodeId, TypeParameterDef>,
314+
ty_param_defs: RefCell<HashMap<ast::NodeId, TypeParameterDef>>,
315315
adjustments: @mut HashMap<ast::NodeId, @AutoAdjustment>,
316316
normalized_cache: @mut HashMap<t, t>,
317317
lang_items: middle::lang_items::LanguageItems,
@@ -1001,7 +1001,7 @@ pub fn mk_ctxt(s: session::Session,
10011001
trait_method_def_ids: RefCell::new(HashMap::new()),
10021002
trait_methods_cache: RefCell::new(HashMap::new()),
10031003
impl_trait_cache: RefCell::new(HashMap::new()),
1004-
ty_param_defs: @mut HashMap::new(),
1004+
ty_param_defs: RefCell::new(HashMap::new()),
10051005
adjustments: @mut HashMap::new(),
10061006
normalized_cache: new_ty_hash(),
10071007
lang_items: lang_items,
@@ -2123,7 +2123,8 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents {
21232123
// def-id.
21242124
assert_eq!(p.def_id.crate, ast::LOCAL_CRATE);
21252125

2126-
let tp_def = cx.ty_param_defs.get(&p.def_id.node);
2126+
let ty_param_defs = cx.ty_param_defs.borrow();
2127+
let tp_def = ty_param_defs.get().get(&p.def_id.node);
21272128
kind_bounds_to_contents(cx,
21282129
tp_def.bounds.builtin_bounds,
21292130
tp_def.bounds.trait_bounds)
@@ -2568,7 +2569,8 @@ pub fn type_is_sized(cx: ctxt, ty: ty::t) -> bool {
25682569
match get(ty).sty {
25692570
// FIXME(#6308) add trait, vec, str, etc here.
25702571
ty_param(p) => {
2571-
let param_def = cx.ty_param_defs.get(&p.def_id.node);
2572+
let ty_param_defs = cx.ty_param_defs.borrow();
2573+
let param_def = ty_param_defs.get().get(&p.def_id.node);
25722574
if param_def.bounds.builtin_bounds.contains_elem(BoundSized) {
25732575
return true;
25742576
}

branches/try2/src/librustc/middle/typeck/collect.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -892,8 +892,12 @@ pub fn ty_generics(ccx: &CrateCtxt,
892892
def_id: local_def(l.id) }
893893
}).collect(),
894894
type_param_defs: @generics.ty_params.mapi_to_vec(|offset, param| {
895-
match ccx.tcx.ty_param_defs.find(&param.id) {
896-
Some(&def) => def,
895+
let existing_def_opt = {
896+
let ty_param_defs = ccx.tcx.ty_param_defs.borrow();
897+
ty_param_defs.get().find(&param.id).map(|def| *def)
898+
};
899+
match existing_def_opt {
900+
Some(def) => def,
897901
None => {
898902
let param_ty = ty::param_ty {idx: base_index + offset,
899903
def_id: local_def(param.id)};
@@ -904,7 +908,11 @@ pub fn ty_generics(ccx: &CrateCtxt,
904908
bounds: bounds
905909
};
906910
debug!("def for param: {}", def.repr(ccx.tcx));
907-
ccx.tcx.ty_param_defs.insert(param.id, def);
911+
912+
let mut ty_param_defs = ccx.tcx
913+
.ty_param_defs
914+
.borrow_mut();
915+
ty_param_defs.get().insert(param.id, def);
908916
def
909917
}
910918
}

branches/try2/src/librustc/util/ppaux.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -472,11 +472,10 @@ pub fn ty_to_str(cx: ctxt, typ: t) -> ~str {
472472
ty_infer(infer_ty) => infer_ty.to_str(),
473473
ty_err => ~"[type error]",
474474
ty_param(param_ty {idx: id, def_id: did}) => {
475-
let param_def = cx.ty_param_defs.find(&did.node);
475+
let ty_param_defs = cx.ty_param_defs.borrow();
476+
let param_def = ty_param_defs.get().find(&did.node);
476477
let ident = match param_def {
477-
Some(def) => {
478-
cx.sess.str_of(def.ident).to_owned()
479-
}
478+
Some(def) => cx.sess.str_of(def.ident).to_owned(),
480479
None => {
481480
// This should not happen...
482481
format!("BUG[{:?}]", id)

0 commit comments

Comments
 (0)