@@ -42,15 +42,16 @@ use syntax::ast::*;
42
42
use syntax:: ast_map;
43
43
use syntax:: ast_util;
44
44
use syntax:: parse:: token;
45
- use syntax:: oldvisit;
45
+ use syntax:: visit;
46
+ use syntax:: visit:: Visitor ;
46
47
47
48
pub type type_uses = uint ; // Bitmask
48
49
pub static use_repr: uint = 1 ; /* Dependency on size/alignment/mode and
49
50
take/drop glue */
50
51
pub static use_tydesc: uint = 2 ; /* Takes the tydesc, or compares */
51
52
pub static use_all: uint = use_repr|use_tydesc;
52
53
53
-
54
+ # [ deriving ( Clone ) ]
54
55
pub struct Context {
55
56
ccx : @mut CrateContext ,
56
57
uses : @mut ~[ type_uses ]
@@ -416,28 +417,39 @@ pub fn mark_for_expr(cx: &Context, e: &expr) {
416
417
}
417
418
}
418
419
419
- pub fn handle_body ( cx : & Context , body : & Block ) {
420
- let v = oldvisit:: mk_vt ( @oldvisit:: Visitor {
421
- visit_expr : |e, ( cx, v) | {
422
- oldvisit:: visit_expr ( e, ( cx, v) ) ;
420
+ struct TypeUseVisitor ;
421
+
422
+ impl < ' self > Visitor < & ' self Context > for TypeUseVisitor {
423
+
424
+ fn visit_expr < ' a > ( & mut self , e: @expr, cx : & ' a Context ) {
425
+ visit:: walk_expr ( self , e, cx) ;
423
426
mark_for_expr ( cx, e) ;
424
- } ,
425
- visit_local : |l, ( cx, v) | {
426
- oldvisit:: visit_local ( l, ( cx, v) ) ;
427
+ }
428
+
429
+ fn visit_local < ' a > ( & mut self , l : @Local , cx : & ' a Context ) {
430
+ visit:: walk_local ( self , l, cx) ;
427
431
node_type_needs ( cx, use_repr, l. id ) ;
428
- } ,
429
- visit_pat : |p, ( cx, v) | {
430
- oldvisit:: visit_pat ( p, ( cx, v) ) ;
432
+ }
433
+
434
+ fn visit_pat < ' a > ( & mut self , p: @pat, cx : & ' a Context ) {
435
+ visit:: walk_pat ( self , p, cx) ;
431
436
node_type_needs ( cx, use_repr, p. id ) ;
432
- } ,
433
- visit_block : |b, ( cx, v) | {
434
- oldvisit:: visit_block ( b, ( cx, v) ) ;
437
+ }
438
+
439
+ fn visit_block < ' a > ( & mut self , b : & Block , cx : & ' a Context ) {
440
+ visit:: walk_block ( self , b, cx) ;
435
441
for e in b. expr . iter ( ) {
436
442
node_type_needs ( cx, use_repr, e. id ) ;
437
443
}
438
- } ,
439
- visit_item : |_i, ( _cx, _v) | { } ,
440
- ..* oldvisit:: default_visitor ( )
441
- } ) ;
442
- ( v. visit_block ) ( body, ( cx, v) ) ;
444
+ }
445
+
446
+ fn visit_item < ' a > ( & mut self , _: @item, _: & ' a Context ) {
447
+ // do nothing
448
+ }
449
+
450
+ }
451
+
452
+ pub fn handle_body ( cx : & Context , body : & Block ) {
453
+ let mut v = TypeUseVisitor ;
454
+ v. visit_block ( body, cx) ;
443
455
}
0 commit comments