Skip to content

Commit 3f64d41

Browse files
committed
De-@ gather_loans.
1 parent a1e24c7 commit 3f64d41

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

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

+7-11
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ use middle::typeck::MethodCall;
2727
use util::common::indenter;
2828
use util::ppaux::{Repr};
2929

30-
use std::cell::RefCell;
3130
use std::vec_ng::Vec;
3231
use syntax::ast;
3332
use syntax::ast_util;
@@ -72,7 +71,7 @@ struct GatherLoanCtxt<'a> {
7271
bccx: &'a BorrowckCtxt<'a>,
7372
id_range: IdRange,
7473
move_data: move_data::MoveData,
75-
all_loans: @RefCell<Vec<Loan> >,
74+
all_loans: Vec<Loan>,
7675
item_ub: ast::NodeId,
7776
repeating_ids: Vec<ast::NodeId> }
7877

@@ -104,19 +103,20 @@ impl<'a> visit::Visitor<()> for GatherLoanCtxt<'a> {
104103
}
105104

106105
pub fn gather_loans(bccx: &BorrowckCtxt, decl: &ast::FnDecl, body: &ast::Block)
107-
-> (IdRange, @RefCell<Vec<Loan> >, move_data::MoveData) {
106+
-> (IdRange, Vec<Loan>, move_data::MoveData) {
108107
let mut glcx = GatherLoanCtxt {
109108
bccx: bccx,
110109
id_range: IdRange::max(),
111-
all_loans: @RefCell::new(Vec::new()),
110+
all_loans: Vec::new(),
112111
item_ub: body.id,
113112
repeating_ids: vec!(body.id),
114113
move_data: MoveData::new()
115114
};
116115
glcx.gather_fn_arg_patterns(decl, body);
117116

118117
glcx.visit_block(body, ());
119-
return (glcx.id_range, glcx.all_loans, glcx.move_data);
118+
let GatherLoanCtxt { id_range, all_loans, move_data, .. } = glcx;
119+
(id_range, all_loans, move_data)
120120
}
121121

122122
fn add_pat_to_id_range(this: &mut GatherLoanCtxt,
@@ -584,9 +584,8 @@ impl<'a> GatherLoanCtxt<'a> {
584584
self.mark_loan_path_as_mutated(loan_path);
585585
}
586586

587-
let all_loans = self.all_loans.borrow();
588587
Loan {
589-
index: all_loans.get().len(),
588+
index: self.all_loans.len(),
590589
loan_path: loan_path,
591590
cmt: cmt,
592591
kind: req_kind,
@@ -605,10 +604,7 @@ impl<'a> GatherLoanCtxt<'a> {
605604
// let loan_path = loan.loan_path;
606605
// let loan_gen_scope = loan.gen_scope;
607606
// let loan_kill_scope = loan.kill_scope;
608-
{
609-
let mut all_loans = self.all_loans.borrow_mut();
610-
all_loans.get().push(loan);
611-
}
607+
self.all_loans.push(loan);
612608

613609
// if loan_gen_scope != borrow_id {
614610
// FIXME(#6268) Nested method calls

src/librustc/middle/borrowck/mod.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,13 @@ fn borrowck_fn(this: &mut BorrowckCtxt,
127127
// Check the body of fn items.
128128
let (id_range, all_loans, move_data) =
129129
gather_loans::gather_loans(this, decl, body);
130-
let all_loans = all_loans.borrow();
131130
let mut loan_dfcx =
132131
DataFlowContext::new(this.tcx,
133132
this.method_map,
134133
LoanDataFlowOperator,
135134
id_range,
136-
all_loans.get().len());
137-
for (loan_idx, loan) in all_loans.get().iter().enumerate() {
135+
all_loans.len());
136+
for (loan_idx, loan) in all_loans.iter().enumerate() {
138137
loan_dfcx.add_gen(loan.gen_scope, loan_idx);
139138
loan_dfcx.add_kill(loan.kill_scope, loan_idx);
140139
}
@@ -147,7 +146,7 @@ fn borrowck_fn(this: &mut BorrowckCtxt,
147146
body);
148147

149148
check_loans::check_loans(this, &loan_dfcx, flowed_moves,
150-
all_loans.get().as_slice(), body);
149+
all_loans.as_slice(), body);
151150

152151
visit::walk_fn(this, fk, decl, body, sp, id, ());
153152
}

0 commit comments

Comments
 (0)