7
7
// 3. assignments do not affect things loaned out as immutable
8
8
// 4. moves to dnot affect things loaned out in any way
9
9
10
+ import dvec:: { dvec, extensions} ;
10
11
import categorization:: public_methods;
11
12
12
13
export check_loans;
@@ -22,7 +23,7 @@ enum check_loan_ctxt = @{
22
23
// we are in a ctor, we track the self id
23
24
mut in_ctor: bool,
24
25
mut declared_purity: ast:: purity,
25
- mut fn_args: [ ast:: node_id]
26
+ mut fn_args: @ [ ast:: node_id]
26
27
} ;
27
28
28
29
// if we are enforcing purity, why are we doing so?
@@ -44,7 +45,7 @@ fn check_loans(bccx: borrowck_ctxt,
44
45
reported: int_hash ( ) ,
45
46
mut in_ctor: false ,
46
47
mut declared_purity: ast:: impure_fn,
47
- mut fn_args: [ ] } ) ;
48
+ mut fn_args: @ [ ] } ) ;
48
49
let vt = visit:: mk_vt ( @{ visit_expr: check_loans_in_expr,
49
50
visit_block: check_loans_in_block,
50
51
visit_fn: check_loans_in_fn
@@ -179,7 +180,7 @@ impl methods for check_loan_ctxt {
179
180
let did = ast_util:: def_id_of_def ( def) ;
180
181
let is_fn_arg =
181
182
did. crate == ast:: local_crate &&
182
- self . fn_args . contains ( did. node ) ;
183
+ ( * self . fn_args ) . contains ( did. node ) ;
183
184
if is_fn_arg { ret; } // case (a) above
184
185
}
185
186
ast:: expr_fn_block ( * ) | ast:: expr_fn ( * ) |
@@ -225,7 +226,8 @@ impl methods for check_loan_ctxt {
225
226
ast:: expr_path ( _) {
226
227
let def = self . tcx ( ) . def_map . get ( expr. id ) ;
227
228
let did = ast_util:: def_id_of_def ( def) ;
228
- did. crate == ast:: local_crate && self . fn_args . contains ( did. node )
229
+ did. crate == ast:: local_crate &&
230
+ ( * self . fn_args ) . contains ( did. node )
229
231
}
230
232
ast:: expr_fn_block ( * ) | ast:: expr_fn ( * ) {
231
233
self . is_stack_closure ( expr. id )
@@ -484,7 +486,7 @@ fn check_loans_in_fn(fk: visit::fn_kind, decl: ast::fn_decl, body: ast::blk,
484
486
sp : span , id : ast:: node_id , & & self : check_loan_ctxt ,
485
487
visitor : visit:: vt < check_loan_ctxt > ) {
486
488
487
- #debug[ "purity on entry=%?" , self . declared_purity ] ;
489
+ #debug[ "purity on entry=%?" , copy self . declared_purity ] ;
488
490
save_and_restore ( self . in_ctor ) { ||
489
491
save_and_restore ( self . declared_purity ) { ||
490
492
save_and_restore ( self . fn_args ) { ||
@@ -500,7 +502,7 @@ fn check_loans_in_fn(fk: visit::fn_kind, decl: ast::fn_decl, body: ast::blk,
500
502
visit: : fk_ctor( * ) {
501
503
self . in_ctor = true ;
502
504
self . declared_purity = decl. purity ;
503
- self . fn_args = decl. inputs . map ( { |i| i. id } ) ;
505
+ self . fn_args = @ decl. inputs . map ( { |i| i. id } ) ;
504
506
}
505
507
visit:: fk_anon ( * ) |
506
508
visit:: fk_fn_block ( * ) if is_stack_closure {
@@ -512,15 +514,15 @@ fn check_loans_in_fn(fk: visit::fn_kind, decl: ast::fn_decl, body: ast::blk,
512
514
visit:: fk_res ( * ) | visit:: fk_dtor ( * ) {
513
515
self . in_ctor = false ;
514
516
self . declared_purity = decl. purity ;
515
- self . fn_args = decl. inputs . map ( { |i| i. id } ) ;
517
+ self . fn_args = @ decl. inputs . map ( { |i| i. id } ) ;
516
518
}
517
519
}
518
520
519
521
visit:: visit_fn ( fk, decl, body, sp, id, self , visitor) ;
520
522
}
521
523
}
522
524
}
523
- #debug[ "purity on exit=%?" , self . declared_purity ] ;
525
+ #debug[ "purity on exit=%?" , copy self . declared_purity ] ;
524
526
}
525
527
526
528
fn check_loans_in_expr( expr: @ast:: expr,
0 commit comments