From d1e23aeb0e3056a4da5c8aac86c10ae0353a8c2d Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Sat, 21 Dec 2013 19:04:10 -0800 Subject: [PATCH] librustc: De-`@mut` `MoveData` --- .../borrowck/gather_loans/gather_moves.rs | 12 ++++----- .../middle/borrowck/gather_loans/mod.rs | 6 ++--- src/librustc/middle/borrowck/move_data.rs | 26 +++++++++---------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/librustc/middle/borrowck/gather_loans/gather_moves.rs b/src/librustc/middle/borrowck/gather_loans/gather_moves.rs index 2dafcbef61f0..907a8e8fdd97 100644 --- a/src/librustc/middle/borrowck/gather_loans/gather_moves.rs +++ b/src/librustc/middle/borrowck/gather_loans/gather_moves.rs @@ -23,7 +23,7 @@ use syntax::codemap::Span; use util::ppaux::{UserString}; pub fn gather_decl(bccx: &BorrowckCtxt, - move_data: &mut MoveData, + move_data: &MoveData, decl_id: ast::NodeId, _decl_span: Span, var_id: ast::NodeId) { @@ -32,7 +32,7 @@ pub fn gather_decl(bccx: &BorrowckCtxt, } pub fn gather_move_from_expr(bccx: &BorrowckCtxt, - move_data: &mut MoveData, + move_data: &MoveData, move_expr: @ast::Expr, cmt: mc::cmt) { gather_move_from_expr_or_pat(bccx, move_data, move_expr.id, @@ -40,7 +40,7 @@ pub fn gather_move_from_expr(bccx: &BorrowckCtxt, } pub fn gather_move_from_pat(bccx: &BorrowckCtxt, - move_data: &mut MoveData, + move_data: &MoveData, move_pat: @ast::Pat, cmt: mc::cmt) { gather_move_from_expr_or_pat(bccx, move_data, move_pat.id, @@ -48,7 +48,7 @@ pub fn gather_move_from_pat(bccx: &BorrowckCtxt, } fn gather_move_from_expr_or_pat(bccx: &BorrowckCtxt, - move_data: &mut MoveData, + move_data: &MoveData, move_id: ast::NodeId, move_kind: MoveKind, cmt: mc::cmt) { @@ -67,7 +67,7 @@ fn gather_move_from_expr_or_pat(bccx: &BorrowckCtxt, } pub fn gather_captures(bccx: &BorrowckCtxt, - move_data: &mut MoveData, + move_data: &MoveData, closure_expr: @ast::Expr) { let capture_map = bccx.capture_map.borrow(); let captured_vars = capture_map.get().get(&closure_expr.id); @@ -85,7 +85,7 @@ pub fn gather_captures(bccx: &BorrowckCtxt, } pub fn gather_assignment(bccx: &BorrowckCtxt, - move_data: &mut MoveData, + move_data: &MoveData, assignment_id: ast::NodeId, assignment_span: Span, assignee_loan_path: @LoanPath, diff --git a/src/librustc/middle/borrowck/gather_loans/mod.rs b/src/librustc/middle/borrowck/gather_loans/mod.rs index fa0af8526cf7..7cf07b38d30b 100644 --- a/src/librustc/middle/borrowck/gather_loans/mod.rs +++ b/src/librustc/middle/borrowck/gather_loans/mod.rs @@ -67,7 +67,7 @@ mod gather_moves; struct GatherLoanCtxt<'a> { bccx: &'a BorrowckCtxt, id_range: id_range, - move_data: @mut move_data::MoveData, + move_data: @move_data::MoveData, all_loans: @mut ~[Loan], item_ub: ast::NodeId, repeating_ids: ~[ast::NodeId] @@ -103,14 +103,14 @@ impl<'a> visit::Visitor<()> for GatherLoanCtxt<'a> { pub fn gather_loans(bccx: &BorrowckCtxt, decl: &ast::fn_decl, body: ast::P) - -> (id_range, @mut ~[Loan], @mut move_data::MoveData) { + -> (id_range, @mut ~[Loan], @move_data::MoveData) { let mut glcx = GatherLoanCtxt { bccx: bccx, id_range: id_range::max(), all_loans: @mut ~[], item_ub: body.id, repeating_ids: ~[body.id], - move_data: @mut MoveData::new() + move_data: @MoveData::new() }; glcx.gather_fn_arg_patterns(decl, body); diff --git a/src/librustc/middle/borrowck/move_data.rs b/src/librustc/middle/borrowck/move_data.rs index 2690038d8e27..a23b74a2fade 100644 --- a/src/librustc/middle/borrowck/move_data.rs +++ b/src/librustc/middle/borrowck/move_data.rs @@ -53,11 +53,12 @@ pub struct MoveData { } pub struct FlowedMoveData { - move_data: @mut MoveData, - // ^~~~~~~~~~~~~ - // It makes me sad to use @mut here, except that due to - // the visitor design, this is what gather_loans - // must produce. + move_data: @MoveData, + // ^~~~~~~~~ + // It makes me sad to use @ here, except that due to + // the old visitor design, this is what gather_loans + // used to have to produce, and this code hasn't been + // updated. dfcx_moves: MoveDataFlow, @@ -199,14 +200,14 @@ impl MoveData { paths.get()[*index].next_sibling } - fn set_path_first_move(&mut self, + fn set_path_first_move(&self, index: MovePathIndex, first_move: MoveIndex) { let mut paths = self.paths.borrow_mut(); paths.get()[*index].first_move = first_move } - fn set_path_first_child(&mut self, + fn set_path_first_child(&self, index: MovePathIndex, first_child: MovePathIndex) { let mut paths = self.paths.borrow_mut(); @@ -225,7 +226,7 @@ impl MoveData { self.path_parent(index) == InvalidMovePathIndex } - pub fn move_path(&mut self, + pub fn move_path(&self, tcx: ty::ctxt, lp: @LoanPath) -> MovePathIndex { /*! @@ -344,7 +345,7 @@ impl MoveData { } - pub fn add_move(&mut self, + pub fn add_move(&self, tcx: ty::ctxt, lp: @LoanPath, id: ast::NodeId, @@ -379,7 +380,7 @@ impl MoveData { } } - pub fn add_assignment(&mut self, + pub fn add_assignment(&self, tcx: ty::ctxt, lp: @LoanPath, assign_id: ast::NodeId, @@ -556,13 +557,12 @@ impl MoveData { } impl FlowedMoveData { - pub fn new(move_data: @mut MoveData, + pub fn new(move_data: @MoveData, tcx: ty::ctxt, method_map: typeck::method_map, id_range: ast_util::id_range, body: &ast::Block) - -> FlowedMoveData - { + -> FlowedMoveData { let mut dfcx_moves = { let moves = move_data.moves.borrow(); DataFlowContext::new(tcx,