@@ -73,40 +73,38 @@ struct GatherLoanCtxt {
73
73
repeating_ids : ~[ ast:: NodeId ]
74
74
}
75
75
76
- struct GatherLoanVisitor ;
77
-
78
- impl visit:: Visitor < @mut GatherLoanCtxt > for GatherLoanVisitor {
79
- fn visit_expr ( & mut self , ex : @Expr , e : @mut GatherLoanCtxt ) {
80
- gather_loans_in_expr ( self , ex, e) ;
76
+ impl visit:: Visitor < ( ) > for GatherLoanCtxt {
77
+ fn visit_expr ( & mut self , ex : @Expr , _: ( ) ) {
78
+ gather_loans_in_expr ( self , ex) ;
81
79
}
82
- fn visit_block ( & mut self , b : & Block , e : @ mut GatherLoanCtxt ) {
83
- gather_loans_in_block ( self , b, e ) ;
80
+ fn visit_block ( & mut self , b : & Block , _ : ( ) ) {
81
+ gather_loans_in_block ( self , b) ;
84
82
}
85
83
fn visit_fn ( & mut self , fk : & fn_kind , fd : & fn_decl , b : & Block ,
86
- s : Span , n : NodeId , e : @ mut GatherLoanCtxt ) {
87
- gather_loans_in_fn ( self , fk, fd, b, s, n, e ) ;
84
+ s : Span , n : NodeId , _ : ( ) ) {
85
+ gather_loans_in_fn ( self , fk, fd, b, s, n) ;
88
86
}
89
- fn visit_stmt ( & mut self , s : @Stmt , e : @ mut GatherLoanCtxt ) {
90
- add_stmt_to_map ( self , s, e ) ;
87
+ fn visit_stmt ( & mut self , s : @Stmt , _ : ( ) ) {
88
+ add_stmt_to_map ( self , s) ;
91
89
}
92
- fn visit_pat ( & mut self , p : @Pat , e : @ mut GatherLoanCtxt ) {
93
- add_pat_to_id_range ( self , p, e ) ;
90
+ fn visit_pat ( & mut self , p : @Pat , _ : ( ) ) {
91
+ add_pat_to_id_range ( self , p) ;
94
92
}
95
- fn visit_local ( & mut self , l : @Local , e : @ mut GatherLoanCtxt ) {
96
- gather_loans_in_local ( self , l, e ) ;
93
+ fn visit_local ( & mut self , l : @Local , _ : ( ) ) {
94
+ gather_loans_in_local ( self , l) ;
97
95
}
98
96
99
97
// #7740: Do not visit items here, not even fn items nor methods
100
98
// of impl items; the outer loop in borrowck/mod will visit them
101
99
// for us in turn. Thus override visit_item's walk with a no-op.
102
- fn visit_item ( & mut self , _: @ast:: item , _: @ mut GatherLoanCtxt ) { }
100
+ fn visit_item ( & mut self , _: @ast:: item , _: ( ) ) { }
103
101
}
104
102
105
103
pub fn gather_loans ( bccx : @BorrowckCtxt ,
106
104
decl : & ast:: fn_decl ,
107
105
body : & ast:: Block )
108
106
-> ( id_range , @mut ~[ Loan ] , @mut move_data:: MoveData ) {
109
- let glcx = @ mut GatherLoanCtxt {
107
+ let mut glcx = GatherLoanCtxt {
110
108
bccx : bccx,
111
109
id_range : id_range:: max ( ) ,
112
110
all_loans : @mut ~[ ] ,
@@ -116,29 +114,26 @@ pub fn gather_loans(bccx: @BorrowckCtxt,
116
114
} ;
117
115
glcx. gather_fn_arg_patterns ( decl, body) ;
118
116
119
- let mut v = GatherLoanVisitor ;
120
- v. visit_block ( body, glcx) ;
117
+ glcx. visit_block ( body, ( ) ) ;
121
118
return ( glcx. id_range , glcx. all_loans , glcx. move_data ) ;
122
119
}
123
120
124
- fn add_pat_to_id_range ( v : & mut GatherLoanVisitor ,
125
- p : @ast:: Pat ,
126
- this : @mut GatherLoanCtxt ) {
121
+ fn add_pat_to_id_range ( this : & mut GatherLoanCtxt ,
122
+ p : @ast:: Pat ) {
127
123
// NB: This visitor function just adds the pat ids into the id
128
124
// range. We gather loans that occur in patterns using the
129
125
// `gather_pat()` method below. Eventually these two should be
130
126
// brought together.
131
127
this. id_range . add ( p. id ) ;
132
- visit:: walk_pat ( v , p, this ) ;
128
+ visit:: walk_pat ( this , p, ( ) ) ;
133
129
}
134
130
135
- fn gather_loans_in_fn ( v : & mut GatherLoanVisitor ,
131
+ fn gather_loans_in_fn ( this : & mut GatherLoanCtxt ,
136
132
fk : & fn_kind ,
137
133
decl : & ast:: fn_decl ,
138
134
body : & ast:: Block ,
139
135
sp : Span ,
140
- id : ast:: NodeId ,
141
- this : @mut GatherLoanCtxt ) {
136
+ id : ast:: NodeId ) {
142
137
match fk {
143
138
& visit:: fk_item_fn( * ) | & visit:: fk_method( * ) => {
144
139
fail ! ( "cannot occur, due to visit_item override" ) ;
@@ -147,23 +142,21 @@ fn gather_loans_in_fn(v: &mut GatherLoanVisitor,
147
142
// Visit closures as part of the containing item.
148
143
& visit:: fk_anon( * ) | & visit:: fk_fn_block( * ) => {
149
144
this. push_repeating_id ( body. id ) ;
150
- visit:: walk_fn ( v , fk, decl, body, sp, id, this ) ;
145
+ visit:: walk_fn ( this , fk, decl, body, sp, id, ( ) ) ;
151
146
this. pop_repeating_id ( body. id ) ;
152
147
this. gather_fn_arg_patterns ( decl, body) ;
153
148
}
154
149
}
155
150
}
156
151
157
- fn gather_loans_in_block ( v : & mut GatherLoanVisitor ,
158
- blk : & ast:: Block ,
159
- this : @mut GatherLoanCtxt ) {
152
+ fn gather_loans_in_block ( this : & mut GatherLoanCtxt ,
153
+ blk : & ast:: Block ) {
160
154
this. id_range . add ( blk. id ) ;
161
- visit:: walk_block ( v , blk, this ) ;
155
+ visit:: walk_block ( this , blk, ( ) ) ;
162
156
}
163
157
164
- fn gather_loans_in_local( v : & mut GatherLoanVisitor ,
165
- local : @ast:: Local ,
166
- this : @mut GatherLoanCtxt ) {
158
+ fn gather_loans_in_local( this : & mut GatherLoanCtxt ,
159
+ local : @ast:: Local ) {
167
160
match local. init {
168
161
None => {
169
162
// Variable declarations without initializers are considered "moves":
@@ -194,13 +187,12 @@ fn gather_loans_in_local(v: &mut GatherLoanVisitor,
194
187
}
195
188
}
196
189
197
- visit:: walk_local( v , local, this ) ;
190
+ visit:: walk_local( this , local, ( ) ) ;
198
191
}
199
192
200
193
201
- fn gather_loans_in_expr( v: & mut GatherLoanVisitor ,
202
- ex: @ast:: Expr ,
203
- this: @mut GatherLoanCtxt ) {
194
+ fn gather_loans_in_expr( this: & mut GatherLoanCtxt ,
195
+ ex: @ast:: Expr ) {
204
196
let bccx = this. bccx;
205
197
let tcx = bccx. tcx;
206
198
@@ -244,7 +236,7 @@ fn gather_loans_in_expr(v: &mut GatherLoanVisitor,
244
236
base_cmt,
245
237
LoanMutability :: from_ast_mutability ( mutbl) ,
246
238
scope_r) ;
247
- visit:: walk_expr ( v , ex, this ) ;
239
+ visit:: walk_expr ( this , ex, ( ) ) ;
248
240
}
249
241
250
242
ast:: ExprAssign ( l, _) | ast:: ExprAssignOp ( _, _, l, _) => {
@@ -261,7 +253,7 @@ fn gather_loans_in_expr(v: &mut GatherLoanVisitor,
261
253
// with moves etc, just ignore.
262
254
}
263
255
}
264
- visit:: walk_expr ( v , ex, this ) ;
256
+ visit:: walk_expr ( this , ex, ( ) ) ;
265
257
}
266
258
267
259
ast:: ExprMatch ( ex_v, ref arms) => {
@@ -271,7 +263,7 @@ fn gather_loans_in_expr(v: &mut GatherLoanVisitor,
271
263
this. gather_pat ( cmt, * pat, Some ( ( arm. body . id , ex. id ) ) ) ;
272
264
}
273
265
}
274
- visit:: walk_expr ( v , ex, this ) ;
266
+ visit:: walk_expr ( this , ex, ( ) ) ;
275
267
}
276
268
277
269
ast:: ExprIndex ( _, _, arg) |
@@ -289,36 +281,36 @@ fn gather_loans_in_expr(v: &mut GatherLoanVisitor,
289
281
arg_cmt,
290
282
ImmutableMutability ,
291
283
scope_r) ;
292
- visit:: walk_expr ( v , ex, this ) ;
284
+ visit:: walk_expr ( this , ex, ( ) ) ;
293
285
}
294
286
295
287
// see explanation attached to the `root_ub` field:
296
288
ast:: ExprWhile ( cond, ref body) => {
297
289
// during the condition, can only root for the condition
298
290
this. push_repeating_id ( cond. id ) ;
299
- v . visit_expr ( cond, this ) ;
291
+ this . visit_expr ( cond, ( ) ) ;
300
292
this. pop_repeating_id ( cond. id ) ;
301
293
302
294
// during body, can only root for the body
303
295
this. push_repeating_id ( body. id ) ;
304
- v . visit_block ( body, this ) ;
296
+ this . visit_block ( body, ( ) ) ;
305
297
this. pop_repeating_id ( body. id ) ;
306
298
}
307
299
308
300
// see explanation attached to the `root_ub` field:
309
301
ast:: ExprLoop ( ref body, _) => {
310
302
this. push_repeating_id ( body. id ) ;
311
- visit:: walk_expr ( v , ex, this ) ;
303
+ visit:: walk_expr ( this , ex, ( ) ) ;
312
304
this. pop_repeating_id ( body. id ) ;
313
305
}
314
306
315
307
ast:: ExprFnBlock ( * ) => {
316
308
gather_moves:: gather_captures ( this. bccx , this. move_data , ex) ;
317
- visit:: walk_expr ( v , ex, this ) ;
309
+ visit:: walk_expr ( this , ex, ( ) ) ;
318
310
}
319
311
320
312
_ => {
321
- visit:: walk_expr ( v , ex, this ) ;
313
+ visit:: walk_expr ( this , ex, ( ) ) ;
322
314
}
323
315
}
324
316
}
@@ -809,14 +801,13 @@ impl GatherLoanCtxt {
809
801
810
802
// Setting up info that preserve needs.
811
803
// This is just the most convenient place to do it.
812
- fn add_stmt_to_map ( v : & mut GatherLoanVisitor ,
813
- stmt : @ast:: Stmt ,
814
- this : @mut GatherLoanCtxt ) {
804
+ fn add_stmt_to_map ( this : & mut GatherLoanCtxt ,
805
+ stmt : @ast:: Stmt ) {
815
806
match stmt. node {
816
807
ast:: StmtExpr ( _, id) | ast:: StmtSemi ( _, id) => {
817
808
this. bccx . stmt_map . insert ( id) ;
818
809
}
819
810
_ => ( )
820
811
}
821
- visit:: walk_stmt ( v , stmt, this ) ;
812
+ visit:: walk_stmt ( this , stmt, ( ) ) ;
822
813
}
0 commit comments