Skip to content

Commit e6468bc

Browse files
committed
---
yaml --- r: 147698 b: refs/heads/try2 c: fc0b466 h: refs/heads/master v: v3
1 parent 7bff1cb commit e6468bc

File tree

3 files changed

+21
-15
lines changed

3 files changed

+21
-15
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: 0afae85bc2889226fa4bb2f2a7e58947a58327dd
8+
refs/heads/try2: fc0b466fd47ebe7f40a08276cbb26ef1f5657fce
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/borrowck/gather_loans/mod.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ use middle::ty;
2626
use util::common::indenter;
2727
use util::ppaux::{Repr};
2828

29+
use std::cell::RefCell;
2930
use syntax::ast;
3031
use syntax::ast_util::id_range;
3132
use syntax::codemap::Span;
@@ -68,7 +69,7 @@ struct GatherLoanCtxt<'a> {
6869
bccx: &'a BorrowckCtxt,
6970
id_range: id_range,
7071
move_data: @move_data::MoveData,
71-
all_loans: @mut ~[Loan],
72+
all_loans: @RefCell<~[Loan]>,
7273
item_ub: ast::NodeId,
7374
repeating_ids: ~[ast::NodeId]
7475
}
@@ -103,11 +104,11 @@ impl<'a> visit::Visitor<()> for GatherLoanCtxt<'a> {
103104
pub fn gather_loans(bccx: &BorrowckCtxt,
104105
decl: &ast::fn_decl,
105106
body: ast::P<ast::Block>)
106-
-> (id_range, @mut ~[Loan], @move_data::MoveData) {
107+
-> (id_range, @RefCell<~[Loan]>, @move_data::MoveData) {
107108
let mut glcx = GatherLoanCtxt {
108109
bccx: bccx,
109110
id_range: id_range::max(),
110-
all_loans: @mut ~[],
111+
all_loans: @RefCell::new(~[]),
111112
item_ub: body.id,
112113
repeating_ids: ~[body.id],
113114
move_data: @MoveData::new()
@@ -511,9 +512,9 @@ impl<'a> GatherLoanCtxt<'a> {
511512
self.mark_loan_path_as_mutated(loan_path);
512513
}
513514

514-
let all_loans = &mut *self.all_loans; // FIXME(#5074)
515+
let all_loans = self.all_loans.borrow();
515516
Loan {
516-
index: all_loans.len(),
517+
index: all_loans.get().len(),
517518
loan_path: loan_path,
518519
cmt: cmt,
519520
mutbl: req_mutbl,
@@ -531,7 +532,10 @@ impl<'a> GatherLoanCtxt<'a> {
531532
// let loan_path = loan.loan_path;
532533
// let loan_gen_scope = loan.gen_scope;
533534
// let loan_kill_scope = loan.kill_scope;
534-
self.all_loans.push(loan);
535+
{
536+
let mut all_loans = self.all_loans.borrow_mut();
537+
all_loans.get().push(loan);
538+
}
535539

536540
// if loan_gen_scope != borrow_id {
537541
// FIXME(#6268) Nested method calls

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,16 +133,18 @@ fn borrowck_fn(this: &mut BorrowckCtxt,
133133
// Check the body of fn items.
134134
let (id_range, all_loans, move_data) =
135135
gather_loans::gather_loans(this, decl, body);
136-
let mut loan_dfcx =
137-
DataFlowContext::new(this.tcx,
138-
this.method_map,
139-
LoanDataFlowOperator,
140-
id_range,
141-
all_loans.len());
142-
for (loan_idx, loan) in all_loans.iter().enumerate() {
136+
137+
let all_loans = all_loans.borrow();
138+
let mut loan_dfcx = DataFlowContext::new(this.tcx,
139+
this.method_map,
140+
LoanDataFlowOperator,
141+
id_range,
142+
all_loans.get().len());
143+
for (loan_idx, loan) in all_loans.get().iter().enumerate() {
143144
loan_dfcx.add_gen(loan.gen_scope, loan_idx);
144145
loan_dfcx.add_kill(loan.kill_scope, loan_idx);
145146
}
147+
146148
loan_dfcx.propagate(body);
147149

148150
let flowed_moves = move_data::FlowedMoveData::new(move_data,
@@ -152,7 +154,7 @@ fn borrowck_fn(this: &mut BorrowckCtxt,
152154
body);
153155

154156
check_loans::check_loans(this, &loan_dfcx, flowed_moves,
155-
*all_loans, body);
157+
*all_loans.get(), body);
156158
}
157159
}
158160

0 commit comments

Comments
 (0)