@@ -40,24 +40,23 @@ struct CheckLoanCtxt<'self> {
40
40
reported : @mut HashSet < ast:: NodeId > ,
41
41
}
42
42
43
- struct CheckLoanVisitor ;
43
+ impl < ' self > Visitor < ( ) > for CheckLoanCtxt < ' self > {
44
44
45
- impl < ' self > Visitor < CheckLoanCtxt < ' self > > for CheckLoanVisitor {
46
- fn visit_expr < ' a > ( & mut self , ex : @ast:: Expr , e : CheckLoanCtxt < ' a > ) {
47
- check_loans_in_expr ( self , ex, e) ;
45
+ fn visit_expr ( & mut self , ex : @ast:: Expr , _: ( ) ) {
46
+ check_loans_in_expr ( self , ex) ;
48
47
}
49
- fn visit_local ( & mut self , l : @ast:: Local , e : CheckLoanCtxt ) {
50
- check_loans_in_local ( self , l, e ) ;
48
+ fn visit_local ( & mut self , l : @ast:: Local , _ : ( ) ) {
49
+ check_loans_in_local ( self , l) ;
51
50
}
52
- fn visit_block ( & mut self , b : & ast:: Block , e : CheckLoanCtxt ) {
53
- check_loans_in_block ( self , b, e ) ;
51
+ fn visit_block ( & mut self , b : & ast:: Block , _ : ( ) ) {
52
+ check_loans_in_block ( self , b) ;
54
53
}
55
- fn visit_pat ( & mut self , p : @ast:: Pat , e : CheckLoanCtxt ) {
56
- check_loans_in_pat ( self , p, e ) ;
54
+ fn visit_pat ( & mut self , p : @ast:: Pat , _ : ( ) ) {
55
+ check_loans_in_pat ( self , p) ;
57
56
}
58
57
fn visit_fn ( & mut self , fk : & visit:: fn_kind , fd : & ast:: fn_decl ,
59
- b : & ast:: Block , s : Span , n : ast:: NodeId , e : CheckLoanCtxt ) {
60
- check_loans_in_fn ( self , fk, fd, b, s, n, e ) ;
58
+ b : & ast:: Block , s : Span , n : ast:: NodeId , _ : ( ) ) {
59
+ check_loans_in_fn ( self , fk, fd, b, s, n) ;
61
60
}
62
61
}
63
62
@@ -68,16 +67,15 @@ pub fn check_loans(bccx: @BorrowckCtxt,
68
67
body : & ast:: Block ) {
69
68
debug ! ( "check_loans(body id=%?)" , body. id) ;
70
69
71
- let clcx = CheckLoanCtxt {
70
+ let mut clcx = CheckLoanCtxt {
72
71
bccx : bccx,
73
72
dfcx_loans : dfcx_loans,
74
73
move_data : @move_data,
75
74
all_loans : all_loans,
76
75
reported : @mut HashSet :: new ( ) ,
77
76
} ;
78
77
79
- let mut vt = CheckLoanVisitor ;
80
- vt. visit_block ( body, clcx) ;
78
+ clcx. visit_block ( body, ( ) ) ;
81
79
}
82
80
83
81
enum MoveError {
@@ -725,13 +723,12 @@ impl<'self> CheckLoanCtxt<'self> {
725
723
}
726
724
}
727
725
728
- fn check_loans_in_fn < ' a > ( visitor : & mut CheckLoanVisitor ,
726
+ fn check_loans_in_fn < ' a > ( this : & mut CheckLoanCtxt < ' a > ,
729
727
fk : & visit:: fn_kind ,
730
728
decl : & ast:: fn_decl ,
731
729
body : & ast:: Block ,
732
730
sp : Span ,
733
- id : ast:: NodeId ,
734
- this : CheckLoanCtxt < ' a > ) {
731
+ id : ast:: NodeId ) {
735
732
match * fk {
736
733
visit:: fk_item_fn( * ) |
737
734
visit:: fk_method( * ) => {
@@ -745,9 +742,9 @@ fn check_loans_in_fn<'a>(visitor: &mut CheckLoanVisitor,
745
742
}
746
743
}
747
744
748
- visit:: walk_fn ( visitor , fk, decl, body, sp, id, this ) ;
745
+ visit:: walk_fn ( this , fk, decl, body, sp, id, ( ) ) ;
749
746
750
- fn check_captured_variables ( this : CheckLoanCtxt ,
747
+ fn check_captured_variables ( this : & CheckLoanCtxt ,
751
748
closure_id : ast:: NodeId ,
752
749
span : Span ) {
753
750
let cap_vars = this. bccx . capture_map . get ( & closure_id) ;
@@ -765,7 +762,7 @@ fn check_loans_in_fn<'a>(visitor: &mut CheckLoanVisitor,
765
762
}
766
763
return ;
767
764
768
- fn check_by_move_capture ( this : CheckLoanCtxt ,
765
+ fn check_by_move_capture ( this : & CheckLoanCtxt ,
769
766
closure_id : ast:: NodeId ,
770
767
cap_var : & moves:: CaptureVar ,
771
768
move_path : @LoanPath ) {
@@ -788,16 +785,14 @@ fn check_loans_in_fn<'a>(visitor: &mut CheckLoanVisitor,
788
785
}
789
786
}
790
787
791
- fn check_loans_in_local < ' a > ( vt : & mut CheckLoanVisitor ,
792
- local : @ast:: Local ,
793
- this : CheckLoanCtxt < ' a > ) {
794
- visit:: walk_local ( vt, local, this) ;
788
+ fn check_loans_in_local < ' a > ( this : & mut CheckLoanCtxt < ' a > ,
789
+ local : @ast:: Local ) {
790
+ visit:: walk_local ( this, local, ( ) ) ;
795
791
}
796
792
797
- fn check_loans_in_expr < ' a > ( vt : & mut CheckLoanVisitor ,
798
- expr : @ast:: Expr ,
799
- this : CheckLoanCtxt < ' a > ) {
800
- visit:: walk_expr ( vt, expr, this) ;
793
+ fn check_loans_in_expr < ' a > ( this : & mut CheckLoanCtxt < ' a > ,
794
+ expr : @ast:: Expr ) {
795
+ visit:: walk_expr ( this, expr, ( ) ) ;
801
796
802
797
debug ! ( "check_loans_in_expr(expr=%s)" ,
803
798
expr. repr( this. tcx( ) ) ) ;
@@ -848,20 +843,18 @@ fn check_loans_in_expr<'a>(vt: &mut CheckLoanVisitor,
848
843
}
849
844
}
850
845
851
- fn check_loans_in_pat < ' a > ( vt : & mut CheckLoanVisitor ,
852
- pat : @ast:: Pat ,
853
- this : CheckLoanCtxt < ' a > )
846
+ fn check_loans_in_pat < ' a > ( this : & mut CheckLoanCtxt < ' a > ,
847
+ pat : @ast:: Pat )
854
848
{
855
849
this. check_for_conflicting_loans ( pat. id ) ;
856
850
this. check_move_out_from_id ( pat. id , pat. span ) ;
857
- visit:: walk_pat ( vt , pat, this ) ;
851
+ visit:: walk_pat ( this , pat, ( ) ) ;
858
852
}
859
853
860
- fn check_loans_in_block < ' a > ( vt : & mut CheckLoanVisitor ,
861
- blk : & ast:: Block ,
862
- this : CheckLoanCtxt < ' a > )
854
+ fn check_loans_in_block < ' a > ( this : & mut CheckLoanCtxt < ' a > ,
855
+ blk : & ast:: Block )
863
856
{
864
- visit:: walk_block ( vt , blk, this ) ;
857
+ visit:: walk_block ( this , blk, ( ) ) ;
865
858
this. check_for_conflicting_loans ( blk. id ) ;
866
859
}
867
860
0 commit comments