Skip to content

Commit 614ddfe

Browse files
committed
---
yaml --- r: 147543 b: refs/heads/try2 c: 7cf6abc h: refs/heads/master i: 147541: b4a212b 147539: 3ff6de7 147535: 7de5156 v: v3
1 parent 1b01b83 commit 614ddfe

File tree

13 files changed

+88
-39
lines changed

13 files changed

+88
-39
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: 3e9bcea018d179bf361cbaee04e2db506ffac4a9
8+
refs/heads/try2: 7cf6abc84a92a2556225edbe3f6a07a39ff06a3f
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: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,7 +1002,8 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
10021002
}
10031003

10041004
{
1005-
let r = tcx.adjustments.find(&id);
1005+
let adjustments = tcx.adjustments.borrow();
1006+
let r = adjustments.get().find(&id);
10061007
for adj in r.iter() {
10071008
ebml_w.tag(c::tag_table_adjustments, |ebml_w| {
10081009
ebml_w.id(id);
@@ -1268,7 +1269,10 @@ fn decode_side_tables(xcx: @ExtendedDecodeContext,
12681269
c::tag_table_adjustments => {
12691270
let adj: @ty::AutoAdjustment = @Decodable::decode(val_dsr);
12701271
adj.tr(xcx);
1271-
dcx.tcx.adjustments.insert(id, adj);
1272+
let mut adjustments = dcx.tcx
1273+
.adjustments
1274+
.borrow_mut();
1275+
adjustments.get().insert(id, adj);
12721276
}
12731277
c::tag_table_capture_map => {
12741278
let cvars =

branches/try2/src/librustc/middle/borrowck/check_loans.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,9 +296,13 @@ impl<'a> CheckLoanCtxt<'a> {
296296
pub fn check_assignment(&self, expr: @ast::Expr) {
297297
// We don't use cat_expr() here because we don't want to treat
298298
// auto-ref'd parameters in overloaded operators as rvalues.
299-
let cmt = match self.bccx.tcx.adjustments.find(&expr.id) {
299+
let adj = {
300+
let adjustments = self.bccx.tcx.adjustments.borrow();
301+
adjustments.get().find_copy(&expr.id)
302+
};
303+
let cmt = match adj {
300304
None => self.bccx.cat_expr_unadjusted(expr),
301-
Some(&adj) => self.bccx.cat_expr_autoderefd(expr, adj)
305+
Some(adj) => self.bccx.cat_expr_autoderefd(expr, adj)
302306
};
303307

304308
debug!("check_assignment(cmt={})", cmt.repr(self.tcx()));

branches/try2/src/librustc/middle/borrowck/gather_loans/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,8 @@ fn gather_loans_in_expr(this: &mut GatherLoanCtxt,
208208

209209
// If this expression is borrowed, have to ensure it remains valid:
210210
{
211-
let r = tcx.adjustments.find(&ex.id);
211+
let adjustments = tcx.adjustments.borrow();
212+
let r = adjustments.get().find(&ex.id);
212213
for &adjustments in r.iter() {
213214
this.guarantee_adjustments(ex, *adjustments);
214215
}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1073,7 +1073,11 @@ fn check_unnecessary_allocation(cx: &Context, e: &ast::Expr) {
10731073
cx.span_lint(unnecessary_allocation, e.span, msg);
10741074
};
10751075

1076-
match cx.tcx.adjustments.find_copy(&e.id) {
1076+
let adjustment = {
1077+
let adjustments = cx.tcx.adjustments.borrow();
1078+
adjustments.get().find_copy(&e.id)
1079+
};
1080+
match adjustment {
10771081
Some(@ty::AutoDerefRef(ty::AutoDerefRef { autoref, .. })) => {
10781082
match (allocation, autoref) {
10791083
(VectorAllocation, Some(ty::AutoBorrowVec(..))) => {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,8 @@ impl mem_categorization_ctxt {
340340
}
341341

342342
pub fn cat_expr(&self, expr: @ast::Expr) -> cmt {
343-
match self.tcx.adjustments.find(&expr.id) {
343+
let adjustments = self.tcx.adjustments.borrow();
344+
match adjustments.get().find(&expr.id) {
344345
None => {
345346
// No adjustments.
346347
self.cat_expr_unadjusted(expr)

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -321,11 +321,14 @@ impl VisitContext {
321321
// `expr_mode` refers to the post-adjustment value. If one of
322322
// those adjustments is to take a reference, then it's only
323323
// reading the underlying expression, not moving it.
324-
let comp_mode = match self.tcx.adjustments.find(&expr.id) {
325-
Some(&@ty::AutoDerefRef(
326-
ty::AutoDerefRef {
327-
autoref: Some(_), ..})) => Read,
328-
_ => expr_mode
324+
let comp_mode = {
325+
let adjustments = self.tcx.adjustments.borrow();
326+
match adjustments.get().find(&expr.id) {
327+
Some(&@ty::AutoDerefRef(
328+
ty::AutoDerefRef {
329+
autoref: Some(_), ..})) => Read,
330+
_ => expr_mode
331+
}
329332
};
330333

331334
debug!("comp_mode = {:?}", comp_mode);

branches/try2/src/librustc/middle/trans/consts.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,10 @@ pub fn const_expr(cx: @CrateContext, e: &ast::Expr) -> (ValueRef, bool) {
186186
let mut llconst = llconst;
187187
let mut inlineable = inlineable;
188188
let ety = ty::expr_ty(cx.tcx, e);
189-
let adjustment = cx.tcx.adjustments.find_copy(&e.id);
189+
let adjustment = {
190+
let adjustments = cx.tcx.adjustments.borrow();
191+
adjustments.get().find_copy(&e.id)
192+
};
190193
match adjustment {
191194
None => { }
192195
Some(@ty::AutoAddEnv(ty::ReStatic, ast::BorrowedSigil)) => {

branches/try2/src/librustc/middle/trans/expr.rs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,12 @@ pub fn trans_to_datum(bcx: @Block, expr: &ast::Expr) -> DatumBlock {
180180

181181
let mut bcx = bcx;
182182
let mut datum = unpack_datum!(bcx, trans_to_datum_unadjusted(bcx, expr));
183-
let adjustment = match bcx.tcx().adjustments.find_copy(&expr.id) {
184-
None => { return DatumBlock {bcx: bcx, datum: datum}; }
185-
Some(adj) => { adj }
183+
let adjustment = {
184+
let adjustments = bcx.tcx().adjustments.borrow();
185+
match adjustments.get().find_copy(&expr.id) {
186+
None => { return DatumBlock {bcx: bcx, datum: datum}; }
187+
Some(adj) => { adj }
188+
}
186189
};
187190
debug!("unadjusted datum: {}", datum.to_str(bcx.ccx()));
188191
match *adjustment {
@@ -415,7 +418,11 @@ pub fn trans_to_datum(bcx: @Block, expr: &ast::Expr) -> DatumBlock {
415418
}
416419

417420
pub fn trans_into(bcx: @Block, expr: &ast::Expr, dest: Dest) -> @Block {
418-
if bcx.tcx().adjustments.contains_key(&expr.id) {
421+
let adjustment_found = {
422+
let adjustments = bcx.tcx().adjustments.borrow();
423+
adjustments.get().contains_key(&expr.id)
424+
};
425+
if adjustment_found {
419426
// use trans_to_datum, which is mildly less efficient but
420427
// which will perform the adjustments:
421428
let datumblock = trans_to_datum(bcx, expr);
@@ -480,15 +487,19 @@ fn trans_lvalue(bcx: @Block, expr: &ast::Expr) -> DatumBlock {
480487
* instead, but sometimes we call trans_lvalue() directly as a
481488
* means of asserting that a particular expression is an lvalue. */
482489

483-
return match bcx.tcx().adjustments.find(&expr.id) {
490+
let adjustment_opt = {
491+
let adjustments = bcx.tcx().adjustments.borrow();
492+
adjustments.get().find_copy(&expr.id)
493+
};
494+
match adjustment_opt {
484495
None => trans_lvalue_unadjusted(bcx, expr),
485496
Some(_) => {
486497
bcx.sess().span_bug(
487498
expr.span,
488499
format!("trans_lvalue() called on an expression \
489500
with adjustments"));
490501
}
491-
};
502+
}
492503
}
493504

494505
fn trans_to_datum_unadjusted(bcx: @Block, expr: &ast::Expr) -> DatumBlock {

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ struct ctxt_ {
312312
ast_ty_to_ty_cache: RefCell<HashMap<NodeId, ast_ty_to_ty_cache_entry>>,
313313
enum_var_cache: RefCell<HashMap<DefId, @~[@VariantInfo]>>,
314314
ty_param_defs: RefCell<HashMap<ast::NodeId, TypeParameterDef>>,
315-
adjustments: @mut HashMap<ast::NodeId, @AutoAdjustment>,
315+
adjustments: RefCell<HashMap<ast::NodeId, @AutoAdjustment>>,
316316
normalized_cache: @mut HashMap<t, t>,
317317
lang_items: middle::lang_items::LanguageItems,
318318
// A mapping of fake provided method def_ids to the default implementation
@@ -1002,7 +1002,7 @@ pub fn mk_ctxt(s: session::Session,
10021002
trait_methods_cache: RefCell::new(HashMap::new()),
10031003
impl_trait_cache: RefCell::new(HashMap::new()),
10041004
ty_param_defs: RefCell::new(HashMap::new()),
1005-
adjustments: @mut HashMap::new(),
1005+
adjustments: RefCell::new(HashMap::new()),
10061006
normalized_cache: new_ty_hash(),
10071007
lang_items: lang_items,
10081008
provided_method_sources: @mut HashMap::new(),
@@ -2876,14 +2876,18 @@ pub fn expr_ty_adjusted(cx: ctxt, expr: &ast::Expr) -> t {
28762876
*/
28772877

28782878
let unadjusted_ty = expr_ty(cx, expr);
2879-
adjust_ty(cx, expr.span, unadjusted_ty, cx.adjustments.find_copy(&expr.id))
2879+
let adjustment = {
2880+
let adjustments = cx.adjustments.borrow();
2881+
adjustments.get().find_copy(&expr.id)
2882+
};
2883+
adjust_ty(cx, expr.span, unadjusted_ty, adjustment)
28802884
}
28812885

28822886
pub fn adjust_ty(cx: ctxt,
28832887
span: Span,
28842888
unadjusted_ty: ty::t,
2885-
adjustment: Option<@AutoAdjustment>) -> ty::t
2886-
{
2889+
adjustment: Option<@AutoAdjustment>)
2890+
-> ty::t {
28872891
/*! See `expr_ty_adjusted` */
28882892

28892893
return match adjustment {

branches/try2/src/librustc/middle/typeck/check/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ pub struct Inherited {
164164
// Temporary tables:
165165
node_types: @mut HashMap<ast::NodeId, ty::t>,
166166
node_type_substs: RefCell<HashMap<ast::NodeId, ty::substs>>,
167-
adjustments: @mut HashMap<ast::NodeId, @ty::AutoAdjustment>,
167+
adjustments: RefCell<HashMap<ast::NodeId, @ty::AutoAdjustment>>,
168168
method_map: method_map,
169169
vtable_map: vtable_map,
170170
}
@@ -264,7 +264,7 @@ impl Inherited {
264264
param_env: param_env,
265265
node_types: @mut HashMap::new(),
266266
node_type_substs: RefCell::new(HashMap::new()),
267-
adjustments: @mut HashMap::new(),
267+
adjustments: RefCell::new(HashMap::new()),
268268
method_map: @mut HashMap::new(),
269269
vtable_map: @mut HashMap::new(),
270270
}
@@ -1137,7 +1137,8 @@ impl FnCtxt {
11371137
node_id: ast::NodeId,
11381138
adj: @ty::AutoAdjustment) {
11391139
debug!("write_adjustment(node_id={:?}, adj={:?})", node_id, adj);
1140-
self.inh.adjustments.insert(node_id, adj);
1140+
let mut adjustments = self.inh.adjustments.borrow_mut();
1141+
adjustments.get().insert(node_id, adj);
11411142
}
11421143

11431144
pub fn write_nil(&self, node_id: ast::NodeId) {

branches/try2/src/librustc/middle/typeck/check/regionck.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,11 @@ impl Rcx {
134134
ty_unadjusted
135135
} else {
136136
let tcx = self.fcx.tcx();
137-
let adjustments = self.fcx.inh.adjustments;
138-
ty::adjust_ty(tcx, expr.span, ty_unadjusted,
139-
adjustments.find_copy(&expr.id))
137+
let adjustment = {
138+
let adjustments = self.fcx.inh.adjustments.borrow();
139+
adjustments.get().find_copy(&expr.id)
140+
};
141+
ty::adjust_ty(tcx, expr.span, ty_unadjusted, adjustment)
140142
}
141143
}
142144
}
@@ -300,7 +302,8 @@ fn visit_expr(rcx: &mut Rcx, expr: @ast::Expr) {
300302

301303
// Check any autoderefs or autorefs that appear.
302304
{
303-
let r = rcx.fcx.inh.adjustments.find(&expr.id);
305+
let adjustments = rcx.fcx.inh.adjustments.borrow();
306+
let r = adjustments.get().find(&expr.id);
304307
for &adjustment in r.iter() {
305308
debug!("adjustment={:?}", adjustment);
306309
match *adjustment {
@@ -699,7 +702,10 @@ fn constrain_regions_in_type_of_node(
699702
// is going to fail anyway, so just stop here and let typeck
700703
// report errors later on in the writeback phase.
701704
let ty0 = rcx.resolve_node_type(id);
702-
let adjustment = rcx.fcx.inh.adjustments.find_copy(&id);
705+
let adjustment = {
706+
let adjustments = rcx.fcx.inh.adjustments.borrow();
707+
adjustments.get().find_copy(&id)
708+
};
703709
let ty = ty::adjust_ty(tcx, origin.span(), ty0, adjustment);
704710
debug!("constrain_regions_in_type_of_node(\
705711
ty={}, ty0={}, id={}, minimum_lifetime={:?}, adjustment={:?})",
@@ -1055,7 +1061,8 @@ pub mod guarantor {
10551061
let mut expr_ct = categorize_unadjusted(rcx, expr);
10561062
debug!("before adjustments, cat={:?}", expr_ct.cat);
10571063

1058-
match rcx.fcx.inh.adjustments.find(&expr.id) {
1064+
let adjustments = rcx.fcx.inh.adjustments.borrow();
1065+
match adjustments.get().find(&expr.id) {
10591066
Some(&@ty::AutoAddEnv(..)) => {
10601067
// This is basically an rvalue, not a pointer, no regions
10611068
// involved.

branches/try2/src/librustc/middle/typeck/check/writeback.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,14 @@ fn resolve_type_vars_for_node(wbcx: &mut WbCtxt, sp: Span, id: ast::NodeId)
120120
let tcx = fcx.ccx.tcx;
121121

122122
// Resolve any borrowings for the node with id `id`
123-
match fcx.inh.adjustments.find(&id) {
123+
let adjustment = {
124+
let adjustments = fcx.inh.adjustments.borrow();
125+
adjustments.get().find_copy(&id)
126+
};
127+
match adjustment {
124128
None => (),
125129

126-
Some(&@ty::AutoAddEnv(r, s)) => {
130+
Some(@ty::AutoAddEnv(r, s)) => {
127131
match resolve_region(fcx.infcx(), r, resolve_all | force_all) {
128132
Err(e) => {
129133
// This should not, I think, happen:
@@ -134,12 +138,13 @@ fn resolve_type_vars_for_node(wbcx: &mut WbCtxt, sp: Span, id: ast::NodeId)
134138
Ok(r1) => {
135139
let resolved_adj = @ty::AutoAddEnv(r1, s);
136140
debug!("Adjustments for node {}: {:?}", id, resolved_adj);
137-
fcx.tcx().adjustments.insert(id, resolved_adj);
141+
let mut adjustments = fcx.tcx().adjustments.borrow_mut();
142+
adjustments.get().insert(id, resolved_adj);
138143
}
139144
}
140145
}
141146

142-
Some(&@ty::AutoDerefRef(adj)) => {
147+
Some(@ty::AutoDerefRef(adj)) => {
143148
let fixup_region = |r| {
144149
match resolve_region(fcx.infcx(), r, resolve_all | force_all) {
145150
Ok(r1) => r1,
@@ -163,7 +168,8 @@ fn resolve_type_vars_for_node(wbcx: &mut WbCtxt, sp: Span, id: ast::NodeId)
163168
autoref: resolved_autoref,
164169
});
165170
debug!("Adjustments for node {}: {:?}", id, resolved_adj);
166-
fcx.tcx().adjustments.insert(id, resolved_adj);
171+
let mut adjustments = fcx.tcx().adjustments.borrow_mut();
172+
adjustments.get().insert(id, resolved_adj);
167173
}
168174
}
169175

0 commit comments

Comments
 (0)