Skip to content

Commit e5f95b1

Browse files
committed
---
yaml --- r: 150994 b: refs/heads/try2 c: acc5c97 h: refs/heads/master v: v3
1 parent 4cfcdb1 commit e5f95b1

File tree

19 files changed

+59
-54
lines changed

19 files changed

+59
-54
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: c9bf84333d4f76417f935e24b7a70340b8f1b1be
8+
refs/heads/try2: acc5c971babe3c59a32834ecac3ec7e064bf1dfa
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: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,8 +1062,8 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
10621062
})
10631063
}
10641064

1065-
for adj in tcx.adjustments.borrow().find(&id).iter() {
1066-
match ***adj {
1065+
for &adj in tcx.adjustments.borrow().find(&id).iter() {
1066+
match *adj {
10671067
ty::AutoDerefRef(adj) => {
10681068
for autoderef in range(0, adj.autoderefs) {
10691069
let method_call = MethodCall::autoderef(id, autoderef as u32);
@@ -1093,7 +1093,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
10931093
ebml_w.tag(c::tag_table_adjustments, |ebml_w| {
10941094
ebml_w.id(id);
10951095
ebml_w.tag(c::tag_table_val, |ebml_w| {
1096-
ebml_w.emit_auto_adjustment(ecx, **adj);
1096+
ebml_w.emit_auto_adjustment(ecx, adj);
10971097
})
10981098
})
10991099
}
@@ -1403,7 +1403,7 @@ fn decode_side_tables(xcx: &ExtendedDecodeContext,
14031403
dcx.tcx.vtable_map.borrow_mut().insert(vtable_key, vtable_res);
14041404
}
14051405
c::tag_table_adjustments => {
1406-
let adj: @ty::AutoAdjustment = @val_dsr.read_auto_adjustment(xcx);
1406+
let adj: ty::AutoAdjustment = val_dsr.read_auto_adjustment(xcx);
14071407
dcx.tcx.adjustments.borrow_mut().insert(id, adj);
14081408
}
14091409
c::tag_table_capture_map => {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ impl<'a> CheckLoanCtxt<'a> {
378378
pub fn check_assignment(&self, expr: &ast::Expr) {
379379
// We don't use cat_expr() here because we don't want to treat
380380
// auto-ref'd parameters in overloaded operators as rvalues.
381-
let cmt = match self.bccx.tcx.adjustments.borrow().find_copy(&expr.id) {
381+
let cmt = match self.bccx.tcx.adjustments.borrow().find(&expr.id) {
382382
None => self.bccx.cat_expr_unadjusted(expr),
383383
Some(adj) => self.bccx.cat_expr_autoderefd(expr, adj)
384384
};

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ fn gather_loans_in_expr(this: &mut GatherLoanCtxt,
177177

178178
// If this expression is borrowed, have to ensure it remains valid:
179179
for &adjustments in tcx.adjustments.borrow().find(&ex.id).iter() {
180-
this.guarantee_adjustments(ex, *adjustments);
180+
this.guarantee_adjustments(ex, adjustments);
181181
}
182182

183183
// If this expression is a move, gather it:

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use middle::typeck;
1818
use middle::moves;
1919
use middle::dataflow::DataFlowContext;
2020
use middle::dataflow::DataFlowOperator;
21-
use util::nodemap::NodeSet;
21+
use util::nodemap::{NodeMap, NodeSet};
2222
use util::ppaux::{note_and_explain_region, Repr, UserString};
2323

2424
use std::cell::{Cell, RefCell};
@@ -918,8 +918,8 @@ impl<'a> mc::Typer for &'a ty::ctxt {
918918
self.method_map.borrow().find(&method_call).map(|method| method.ty)
919919
}
920920

921-
fn adjustment(&mut self, id: ast::NodeId) -> Option<@ty::AutoAdjustment> {
922-
self.adjustments.borrow().find_copy(&id)
921+
fn adjustments<'a>(&'a self) -> &'a RefCell<NodeMap<ty::AutoAdjustment>> {
922+
&self.adjustments
923923
}
924924

925925
fn is_method_call(&mut self, id: ast::NodeId) -> bool {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ pub fn check_expr(cx: &mut Context, e: &Expr) {
306306
// Search for auto-adjustments to find trait coercions.
307307
match cx.tcx.adjustments.borrow().find(&e.id) {
308308
Some(adjustment) => {
309-
match **adjustment {
309+
match *adjustment {
310310
ty::AutoObject(..) => {
311311
let source_ty = ty::expr_ty(cx.tcx, e);
312312
let target_ty = ty::expr_ty_adjusted(cx.tcx, e);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1387,7 +1387,7 @@ fn check_unnecessary_allocation(cx: &Context, e: &ast::Expr) {
13871387
cx.span_lint(UnnecessaryAllocation, e.span, msg);
13881388
};
13891389

1390-
match cx.tcx.adjustments.borrow().find_copy(&e.id) {
1390+
match cx.tcx.adjustments.borrow().find(&e.id) {
13911391
Some(adjustment) => {
13921392
match *adjustment {
13931393
ty::AutoDerefRef(ty::AutoDerefRef { autoref, .. }) => {

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464

6565
use middle::ty;
6666
use middle::typeck;
67+
use util::nodemap::NodeMap;
6768
use util::ppaux::{ty_to_str, Repr};
6869

6970
use syntax::ast::{MutImmutable, MutMutable};
@@ -72,6 +73,8 @@ use syntax::codemap::Span;
7273
use syntax::print::pprust;
7374
use syntax::parse::token;
7475

76+
use std::cell::RefCell;
77+
7578
#[deriving(Eq)]
7679
pub enum categorization {
7780
cat_rvalue(ty::Region), // temporary val, argument is its scope
@@ -265,10 +268,10 @@ pub trait Typer {
265268
fn tcx<'a>(&'a self) -> &'a ty::ctxt;
266269
fn node_ty(&mut self, id: ast::NodeId) -> McResult<ty::t>;
267270
fn node_method_ty(&self, method_call: typeck::MethodCall) -> Option<ty::t>;
268-
fn adjustment(&mut self, node_id: ast::NodeId) -> Option<@ty::AutoAdjustment>;
269271
fn is_method_call(&mut self, id: ast::NodeId) -> bool;
270272
fn temporary_scope(&mut self, rvalue_id: ast::NodeId) -> Option<ast::NodeId>;
271273
fn upvar_borrow(&mut self, upvar_id: ty::UpvarId) -> ty::UpvarBorrow;
274+
fn adjustments<'a>(&'a self) -> &'a RefCell<NodeMap<ty::AutoAdjustment>>;
272275
}
273276

274277
impl MutabilityCategory {
@@ -360,8 +363,8 @@ impl<TYPER:Typer> MemCategorizationContext<TYPER> {
360363

361364
fn expr_ty_adjusted(&mut self, expr: &ast::Expr) -> McResult<ty::t> {
362365
let unadjusted_ty = if_ok!(self.expr_ty(expr));
363-
let adjustment = self.adjustment(expr.id);
364-
Ok(ty::adjust_ty(self.tcx(), expr.span, expr.id, unadjusted_ty, adjustment,
366+
Ok(ty::adjust_ty(self.tcx(), expr.span, expr.id, unadjusted_ty,
367+
self.typer.adjustments().borrow().find(&expr.id),
365368
|method_call| self.typer.node_method_ty(method_call)))
366369
}
367370

@@ -374,7 +377,7 @@ impl<TYPER:Typer> MemCategorizationContext<TYPER> {
374377
}
375378

376379
pub fn cat_expr(&mut self, expr: &ast::Expr) -> McResult<cmt> {
377-
match self.adjustment(expr.id) {
380+
match self.typer.adjustments().borrow().find(&expr.id) {
378381
None => {
379382
// No adjustments.
380383
self.cat_expr_unadjusted(expr)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ impl<'a> VisitContext<'a> {
312312
// reading the underlying expression, not moving it.
313313
let comp_mode = match self.tcx.adjustments.borrow().find(&expr.id) {
314314
Some(adjustment) => {
315-
match **adjustment {
315+
match *adjustment {
316316
ty::AutoDerefRef(ty::AutoDerefRef {
317317
autoref: Some(_),
318318
..

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ pub fn const_expr(cx: &CrateContext, e: &ast::Expr, is_local: bool) -> (ValueRef
192192
match opt_adj {
193193
None => { }
194194
Some(adj) => {
195-
match *adj {
195+
match adj {
196196
ty::AutoAddEnv(ty::RegionTraitStore(ty::ReStatic, _)) => {
197197
let def = ty::resolve_expr(cx.tcx(), e);
198198
let wrapper = closure::get_wrapper_for_bare_fn(cx,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ fn apply_adjustments<'a>(bcx: &'a Block<'a>,
175175
};
176176
debug!("unadjusted datum for expr {}: {}",
177177
expr.id, datum.to_str(bcx.ccx()));
178-
match *adjustment {
178+
match adjustment {
179179
AutoAddEnv(..) => {
180180
datum = unpack_datum!(bcx, add_env(bcx, expr, datum));
181181
}

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

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ pub enum Variance {
212212
Bivariant, // T<A> <: T<B> -- e.g., unused type parameter
213213
}
214214

215+
#[deriving(Clone)]
215216
pub enum AutoAdjustment {
216217
AutoAddEnv(ty::TraitStore),
217218
AutoDerefRef(AutoDerefRef),
@@ -221,13 +222,13 @@ pub enum AutoAdjustment {
221222
ty::substs /* Trait substitutions */)
222223
}
223224

224-
#[deriving(Decodable, Encodable)]
225+
#[deriving(Clone, Decodable, Encodable)]
225226
pub struct AutoDerefRef {
226227
pub autoderefs: uint,
227228
pub autoref: Option<AutoRef>
228229
}
229230

230-
#[deriving(Decodable, Encodable, Eq, Show)]
231+
#[deriving(Clone, Decodable, Encodable, Eq, Show)]
231232
pub enum AutoRef {
232233
/// Convert from T to &T
233234
AutoPtr(Region, ast::Mutability),
@@ -296,7 +297,7 @@ pub struct ctxt {
296297
pub ast_ty_to_ty_cache: RefCell<NodeMap<ast_ty_to_ty_cache_entry>>,
297298
pub enum_var_cache: RefCell<DefIdMap<@Vec<@VariantInfo> >>,
298299
pub ty_param_defs: RefCell<NodeMap<TypeParameterDef>>,
299-
pub adjustments: RefCell<NodeMap<@AutoAdjustment>>,
300+
pub adjustments: RefCell<NodeMap<AutoAdjustment>>,
300301
pub normalized_cache: RefCell<HashMap<t, t>>,
301302
pub lang_items: @middle::lang_items::LanguageItems,
302303
// A mapping of fake provided method def_ids to the default implementation
@@ -2808,11 +2809,9 @@ pub fn expr_ty_adjusted(cx: &ctxt, expr: &ast::Expr) -> t {
28082809
* task at hand! -nmatsakis
28092810
*/
28102811

2811-
let unadjusted_ty = expr_ty(cx, expr);
2812-
let adjustment = cx.adjustments.borrow().find_copy(&expr.id);
2813-
adjust_ty(cx, expr.span, expr.id, unadjusted_ty, adjustment, |method_call| {
2814-
cx.method_map.borrow().find(&method_call).map(|method| method.ty)
2815-
})
2812+
adjust_ty(cx, expr.span, expr.id, expr_ty(cx, expr),
2813+
cx.adjustments.borrow().find(&expr.id),
2814+
|method_call| cx.method_map.borrow().find(&method_call).map(|method| method.ty))
28162815
}
28172816

28182817
pub fn expr_span(cx: &ctxt, id: NodeId) -> Span {
@@ -2857,7 +2856,7 @@ pub fn adjust_ty(cx: &ctxt,
28572856
span: Span,
28582857
expr_id: ast::NodeId,
28592858
unadjusted_ty: ty::t,
2860-
adjustment: Option<@AutoAdjustment>,
2859+
adjustment: Option<&AutoAdjustment>,
28612860
method_type: |typeck::MethodCall| -> Option<ty::t>)
28622861
-> ty::t {
28632862
/*! See `expr_ty_adjusted` */

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ impl<'a> LookupContext<'a> {
715715
// an explicit adjustment, but rather we hardwire the single deref
716716
// that occurs in trans and mem_categorization.
717717
let adjustment = match self.self_expr {
718-
Some(expr) => Some((expr.id, @ty::AutoDerefRef(auto_deref_ref))),
718+
Some(expr) => Some((expr.id, ty::AutoDerefRef(auto_deref_ref))),
719719
None => return None
720720
};
721721

@@ -962,7 +962,7 @@ impl<'a> LookupContext<'a> {
962962
Some(self_expr_id) => {
963963
self.fcx.write_adjustment(
964964
self_expr_id,
965-
@ty::AutoDerefRef(ty::AutoDerefRef {
965+
ty::AutoDerefRef(ty::AutoDerefRef {
966966
autoderefs: autoderefs,
967967
autoref: Some(kind(region, *mutbl))
968968
}));

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ pub struct Inherited<'a> {
161161
// Temporary tables:
162162
node_types: RefCell<NodeMap<ty::t>>,
163163
node_type_substs: RefCell<NodeMap<ty::substs>>,
164-
adjustments: RefCell<NodeMap<@ty::AutoAdjustment>>,
164+
adjustments: RefCell<NodeMap<ty::AutoAdjustment>>,
165165
method_map: MethodMap,
166166
vtable_map: vtable_map,
167167
upvar_borrow_map: RefCell<ty::UpvarBorrowMap>,
@@ -1076,15 +1076,15 @@ impl<'a> FnCtxt<'a> {
10761076
if derefs == 0 { return; }
10771077
self.write_adjustment(
10781078
node_id,
1079-
@ty::AutoDerefRef(ty::AutoDerefRef {
1079+
ty::AutoDerefRef(ty::AutoDerefRef {
10801080
autoderefs: derefs,
10811081
autoref: None })
10821082
);
10831083
}
10841084

10851085
pub fn write_adjustment(&self,
10861086
node_id: ast::NodeId,
1087-
adj: @ty::AutoAdjustment) {
1087+
adj: ty::AutoAdjustment) {
10881088
debug!("write_adjustment(node_id={:?}, adj={:?})", node_id, adj);
10891089
self.inh.adjustments.borrow_mut().insert(node_id, adj);
10901090
}

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

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ use middle::typeck::infer::resolve_type;
131131
use middle::typeck::infer;
132132
use middle::typeck::MethodCall;
133133
use middle::pat_util;
134+
use util::nodemap::NodeMap;
134135
use util::ppaux::{ty_to_str, region_to_str, Repr};
135136

136137
use syntax::ast::{DefArg, DefBinding, DefLocal, DefUpvar};
@@ -140,6 +141,8 @@ use syntax::codemap::Span;
140141
use syntax::visit;
141142
use syntax::visit::Visitor;
142143

144+
use std::cell::RefCell;
145+
143146
// If mem categorization results in an error, it's because the type
144147
// check failed (or will fail, when the error is uncovered and
145148
// reported during writeback). In this case, we just ignore this part
@@ -252,8 +255,8 @@ impl<'a> Rcx<'a> {
252255
ty_unadjusted
253256
} else {
254257
let tcx = self.fcx.tcx();
255-
let adjustment = self.fcx.inh.adjustments.borrow().find_copy(&expr.id);
256-
ty::adjust_ty(tcx, expr.span, expr.id, ty_unadjusted, adjustment,
258+
ty::adjust_ty(tcx, expr.span, expr.id, ty_unadjusted,
259+
self.fcx.inh.adjustments.borrow().find(&expr.id),
257260
|method_call| self.resolve_method_type(method_call))
258261
}
259262
}
@@ -273,8 +276,8 @@ impl<'a, 'b> mc::Typer for &'a mut Rcx<'b> {
273276
self.resolve_method_type(method_call)
274277
}
275278

276-
fn adjustment(&mut self, id: ast::NodeId) -> Option<@ty::AutoAdjustment> {
277-
self.fcx.inh.adjustments.borrow().find_copy(&id)
279+
fn adjustments<'a>(&'a self) -> &'a RefCell<NodeMap<ty::AutoAdjustment>> {
280+
&self.fcx.inh.adjustments
278281
}
279282

280283
fn is_method_call(&mut self, id: ast::NodeId) -> bool {
@@ -402,7 +405,7 @@ fn visit_expr(rcx: &mut Rcx, expr: &ast::Expr) {
402405
// Check any autoderefs or autorefs that appear.
403406
for &adjustment in rcx.fcx.inh.adjustments.borrow().find(&expr.id).iter() {
404407
debug!("adjustment={:?}", adjustment);
405-
match **adjustment {
408+
match *adjustment {
406409
ty::AutoDerefRef(ty::AutoDerefRef {autoderefs, autoref: opt_autoref}) => {
407410
let expr_ty = rcx.resolve_node_type(expr.id);
408411
constrain_autoderefs(rcx, expr, autoderefs, expr_ty);
@@ -960,13 +963,13 @@ fn constrain_regions_in_type_of_node(
960963
// is going to fail anyway, so just stop here and let typeck
961964
// report errors later on in the writeback phase.
962965
let ty0 = rcx.resolve_node_type(id);
963-
let adjustment = rcx.fcx.inh.adjustments.borrow().find_copy(&id);
964-
let ty = ty::adjust_ty(tcx, origin.span(), id, ty0, adjustment,
966+
let ty = ty::adjust_ty(tcx, origin.span(), id, ty0,
967+
rcx.fcx.inh.adjustments.borrow().find(&id),
965968
|method_call| rcx.resolve_method_type(method_call));
966969
debug!("constrain_regions_in_type_of_node(\
967-
ty={}, ty0={}, id={}, minimum_lifetime={:?}, adjustment={:?})",
970+
ty={}, ty0={}, id={}, minimum_lifetime={:?})",
968971
ty_to_str(tcx, ty), ty_to_str(tcx, ty0),
969-
id, minimum_lifetime, adjustment);
972+
id, minimum_lifetime);
970973
constrain_regions_in_type(rcx, minimum_lifetime, origin, ty)
971974
}
972975

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ pub fn early_resolve_expr(ex: &ast::Expr, fcx: &FnCtxt, is_early: bool) {
682682
// Search for auto-adjustments to find trait coercions
683683
match fcx.inh.adjustments.borrow().find(&ex.id) {
684684
Some(adjustment) => {
685-
match **adjustment {
685+
match *adjustment {
686686
AutoDerefRef(adj) => {
687687
for autoderef in range(0, adj.autoderefs) {
688688
let method_call = MethodCall::autoderef(ex.id, autoderef as u32);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ fn resolve_type_vars_for_node(wbcx: &mut WbCtxt, sp: Span, id: ast::NodeId) {
127127
None => None,
128128

129129
Some(adjustment) => {
130-
Some(match *adjustment {
130+
Some(match adjustment {
131131
ty::AutoAddEnv(store) => {
132132
let r = match store {
133133
ty::RegionTraitStore(r, _) => r,
@@ -205,7 +205,7 @@ fn resolve_type_vars_for_node(wbcx: &mut WbCtxt, sp: Span, id: ast::NodeId) {
205205
id, resolved_adj);
206206
match resolved_adj {
207207
Some(adj) => {
208-
tcx.adjustments.borrow_mut().insert(id, @adj);
208+
tcx.adjustments.borrow_mut().insert(id, adj);
209209
}
210210
None => {}
211211
}

0 commit comments

Comments
 (0)