Skip to content

Commit acc5c97

Browse files
committed
rustc: de-@ ty::AutoAdjustment.
1 parent c9bf843 commit acc5c97

File tree

18 files changed

+58
-53
lines changed

18 files changed

+58
-53
lines changed

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 => {

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
};

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:

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 {

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);

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, .. }) => {

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)

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
..

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,

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
}

0 commit comments

Comments
 (0)