From 3f64d4126b982b88368dc39c45e28aae5301e6a2 Mon Sep 17 00:00:00 2001 From: Eduard Burtescu Date: Fri, 14 Mar 2014 10:55:30 +0200 Subject: [PATCH] De-@ gather_loans. --- .../middle/borrowck/gather_loans/mod.rs | 18 +++++++----------- src/librustc/middle/borrowck/mod.rs | 7 +++---- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/librustc/middle/borrowck/gather_loans/mod.rs b/src/librustc/middle/borrowck/gather_loans/mod.rs index 914634d88b2..ffc00bad320 100644 --- a/src/librustc/middle/borrowck/gather_loans/mod.rs +++ b/src/librustc/middle/borrowck/gather_loans/mod.rs @@ -27,7 +27,6 @@ use middle::typeck::MethodCall; use util::common::indenter; use util::ppaux::{Repr}; -use std::cell::RefCell; use std::vec_ng::Vec; use syntax::ast; use syntax::ast_util; @@ -72,7 +71,7 @@ struct GatherLoanCtxt<'a> { bccx: &'a BorrowckCtxt<'a>, id_range: IdRange, move_data: move_data::MoveData, - all_loans: @RefCell >, + all_loans: Vec, item_ub: ast::NodeId, repeating_ids: Vec } @@ -104,11 +103,11 @@ impl<'a> visit::Visitor<()> for GatherLoanCtxt<'a> { } pub fn gather_loans(bccx: &BorrowckCtxt, decl: &ast::FnDecl, body: &ast::Block) - -> (IdRange, @RefCell >, move_data::MoveData) { + -> (IdRange, Vec, move_data::MoveData) { let mut glcx = GatherLoanCtxt { bccx: bccx, id_range: IdRange::max(), - all_loans: @RefCell::new(Vec::new()), + all_loans: Vec::new(), item_ub: body.id, repeating_ids: vec!(body.id), move_data: MoveData::new() @@ -116,7 +115,8 @@ pub fn gather_loans(bccx: &BorrowckCtxt, decl: &ast::FnDecl, body: &ast::Block) glcx.gather_fn_arg_patterns(decl, body); glcx.visit_block(body, ()); - return (glcx.id_range, glcx.all_loans, glcx.move_data); + let GatherLoanCtxt { id_range, all_loans, move_data, .. } = glcx; + (id_range, all_loans, move_data) } fn add_pat_to_id_range(this: &mut GatherLoanCtxt, @@ -584,9 +584,8 @@ impl<'a> GatherLoanCtxt<'a> { self.mark_loan_path_as_mutated(loan_path); } - let all_loans = self.all_loans.borrow(); Loan { - index: all_loans.get().len(), + index: self.all_loans.len(), loan_path: loan_path, cmt: cmt, kind: req_kind, @@ -605,10 +604,7 @@ impl<'a> GatherLoanCtxt<'a> { // let loan_path = loan.loan_path; // let loan_gen_scope = loan.gen_scope; // let loan_kill_scope = loan.kill_scope; - { - let mut all_loans = self.all_loans.borrow_mut(); - all_loans.get().push(loan); - } + self.all_loans.push(loan); // if loan_gen_scope != borrow_id { // FIXME(#6268) Nested method calls diff --git a/src/librustc/middle/borrowck/mod.rs b/src/librustc/middle/borrowck/mod.rs index e34a7ff94db..4c926bb81ef 100644 --- a/src/librustc/middle/borrowck/mod.rs +++ b/src/librustc/middle/borrowck/mod.rs @@ -127,14 +127,13 @@ fn borrowck_fn(this: &mut BorrowckCtxt, // Check the body of fn items. let (id_range, all_loans, move_data) = gather_loans::gather_loans(this, decl, body); - let all_loans = all_loans.borrow(); let mut loan_dfcx = DataFlowContext::new(this.tcx, this.method_map, LoanDataFlowOperator, id_range, - all_loans.get().len()); - for (loan_idx, loan) in all_loans.get().iter().enumerate() { + all_loans.len()); + for (loan_idx, loan) in all_loans.iter().enumerate() { loan_dfcx.add_gen(loan.gen_scope, loan_idx); loan_dfcx.add_kill(loan.kill_scope, loan_idx); } @@ -147,7 +146,7 @@ fn borrowck_fn(this: &mut BorrowckCtxt, body); check_loans::check_loans(this, &loan_dfcx, flowed_moves, - all_loans.get().as_slice(), body); + all_loans.as_slice(), body); visit::walk_fn(this, fk, decl, body, sp, id, ()); }