@@ -26,6 +26,7 @@ use middle::ty;
26
26
use util:: common:: indenter;
27
27
use util:: ppaux:: { Repr } ;
28
28
29
+ use std:: cell:: RefCell ;
29
30
use syntax:: ast;
30
31
use syntax:: ast_util:: id_range;
31
32
use syntax:: codemap:: Span ;
@@ -68,7 +69,7 @@ struct GatherLoanCtxt<'a> {
68
69
bccx : & ' a BorrowckCtxt ,
69
70
id_range : id_range ,
70
71
move_data : @move_data:: MoveData ,
71
- all_loans : @mut ~[ Loan ] ,
72
+ all_loans : @RefCell < ~[ Loan ] > ,
72
73
item_ub : ast:: NodeId ,
73
74
repeating_ids : ~[ ast:: NodeId ]
74
75
}
@@ -103,11 +104,11 @@ impl<'a> visit::Visitor<()> for GatherLoanCtxt<'a> {
103
104
pub fn gather_loans ( bccx : & BorrowckCtxt ,
104
105
decl : & ast:: fn_decl ,
105
106
body : ast:: P < ast:: Block > )
106
- -> ( id_range , @mut ~[ Loan ] , @move_data:: MoveData ) {
107
+ -> ( id_range , @RefCell < ~[ Loan ] > , @move_data:: MoveData ) {
107
108
let mut glcx = GatherLoanCtxt {
108
109
bccx : bccx,
109
110
id_range : id_range:: max ( ) ,
110
- all_loans : @mut ~[ ] ,
111
+ all_loans : @RefCell :: new ( ~[ ] ) ,
111
112
item_ub : body. id ,
112
113
repeating_ids : ~[ body. id ] ,
113
114
move_data : @MoveData :: new ( )
@@ -511,9 +512,9 @@ impl<'a> GatherLoanCtxt<'a> {
511
512
self . mark_loan_path_as_mutated ( loan_path) ;
512
513
}
513
514
514
- let all_loans = & mut * self . all_loans ; // FIXME(#5074)
515
+ let all_loans = self . all_loans . borrow ( ) ;
515
516
Loan {
516
- index : all_loans. len ( ) ,
517
+ index : all_loans. get ( ) . len ( ) ,
517
518
loan_path : loan_path,
518
519
cmt : cmt,
519
520
mutbl : req_mutbl,
@@ -531,7 +532,10 @@ impl<'a> GatherLoanCtxt<'a> {
531
532
// let loan_path = loan.loan_path;
532
533
// let loan_gen_scope = loan.gen_scope;
533
534
// 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
+ }
535
539
536
540
// if loan_gen_scope != borrow_id {
537
541
// FIXME(#6268) Nested method calls
0 commit comments