@@ -40,6 +40,8 @@ type ast_fold_precursor =
40
40
fold_expr : fn @( expr_ , span , ast_fold ) -> ( expr_ , span ) ,
41
41
fold_ty : fn @( ty_ , span , ast_fold ) -> ( ty_ , span ) ,
42
42
fold_constr : fn @( ast:: constr_ , span , ast_fold ) -> ( constr_ , span ) ,
43
+ fold_ty_constr : fn @( ast:: ty_constr_ , span , ast_fold )
44
+ -> ( ty_constr_ , span ) ,
43
45
fold_mod : fn @( _mod , ast_fold ) -> _mod ,
44
46
fold_native_mod : fn @( native_mod , ast_fold ) -> native_mod ,
45
47
fold_variant : fn @( variant_ , span , ast_fold ) -> ( variant_ , span ) ,
@@ -67,6 +69,7 @@ type a_f =
67
69
fold_expr : fn @( & & @expr) -> @expr,
68
70
fold_ty : fn @( & & @ty) -> @ty,
69
71
fold_constr : fn @( & & @constr ) -> @constr ,
72
+ fold_ty_constr : fn @( & & @ty_constr ) -> @ty_constr ,
70
73
fold_mod : fn @( _mod ) -> _mod ,
71
74
fold_native_mod : fn @( native_mod ) -> native_mod ,
72
75
fold_variant : fn @( variant ) -> variant ,
@@ -97,6 +100,7 @@ fn nf_decl_dummy(&&_d: @decl) -> @decl { fail; }
97
100
fn nf_expr_dummy ( & & _e: @expr) -> @expr { fail ; }
98
101
fn nf_ty_dummy( & & _t: @ty) -> @ty { fail; }
99
102
fn nf_constr_dummy ( & & _c: @constr ) -> @constr { fail; }
103
+ fn nf_ty_constr_dummy ( & & _c: @ty_constr ) -> @ty_constr { fail; }
100
104
fn nf_mod_dummy ( _m : _mod ) -> _mod { fail; }
101
105
fn nf_native_mod_dummy ( _n : native_mod ) -> native_mod { fail; }
102
106
fn nf_variant_dummy ( _v : variant ) -> variant { fail; }
@@ -141,9 +145,7 @@ fn fold_mac_(m: mac, fld: ast_fold) -> mac {
141
145
alt m. node {
142
146
mac_invoc ( pth, arg, body) {
143
147
mac_invoc ( fld. fold_path ( pth) ,
144
- // FIXME: bind should work, but causes a crash
145
- option:: map ( arg) { |arg| fld. fold_expr ( arg) } ,
146
- body)
148
+ option:: map ( arg, fld. fold_expr ) , body)
147
149
}
148
150
mac_embed_type ( ty) { mac_embed_type ( fld. fold_ty ( ty) ) }
149
151
mac_embed_block ( blk) { mac_embed_block ( fld. fold_block ( blk) ) }
@@ -500,8 +502,8 @@ fn noop_fold_ty(t: ty_, fld: ast_fold) -> ty_ {
500
502
ty_fn ( proto , decl ) { ty_fn ( proto , fold_fn_decl ( decl , fld ) ) }
501
503
ty_tup ( tys ) { ty_tup ( vec:: map ( tys ) { |ty| fld. fold_ty( ty) } ) }
502
504
ty_path ( path , id ) { ty_path ( fld. fold_path ( path ) , fld. new_id ( id ) ) }
503
- // FIXME: constrs likely needs to be folded...
504
- ty_constr ( ty , constrs ) { ty_constr ( fld. fold_ty ( ty ) , constrs ) }
505
+ ty_constr ( ty , constrs ) { ty_constr ( fld . fold_ty ( ty ) ,
506
+ vec :: map ( constrs , fld. fold_ty_constr ) ) }
505
507
ty_vstore ( t , vs ) { ty_vstore ( fld. fold_ty ( t ) , vs ) }
506
508
ty_mac ( mac ) { ty_mac ( fold_mac ( mac ) ) }
507
509
ty_infer { t }
@@ -512,6 +514,11 @@ fn noop_fold_constr(c: constr_, fld: ast_fold) -> constr_ {
512
514
{ path: fld. fold_path ( c . path) , args : c. args, id : fld. new_id ( c. id ) }
513
515
}
514
516
517
+ fn noop_fold_ty_constr ( c : ty_constr_ , fld : ast_fold ) -> ty_constr_ {
518
+ let rslt : ty_constr_ =
519
+ { path: fld. fold_path ( c . path) , args : c. args, id : fld. new_id ( c. id ) } ;
520
+ rslt
521
+ }
515
522
// ...nor do modules
516
523
fn noop_fold_mod ( m : _mod , fld : ast_fold ) -> _mod {
517
524
ret { view_items : vec:: map ( m. view_items , fld. fold_view_item ) ,
@@ -594,6 +601,7 @@ fn default_ast_fold() -> @ast_fold_precursor {
594
601
fold_expr : wrap ( noop_fold_expr ) ,
595
602
fold_ty : wrap ( noop_fold_ty ) ,
596
603
fold_constr : wrap ( noop_fold_constr ) ,
604
+ fold_ty_constr : wrap ( noop_fold_ty_constr ) ,
597
605
fold_mod : noop_fold_mod ,
598
606
fold_native_mod : noop_fold_native_mod ,
599
607
fold_variant : wrap ( noop_fold_variant ) ,
@@ -608,6 +616,7 @@ fn default_ast_fold() -> @ast_fold_precursor {
608
616
fn make_fold ( afp : ast_fold_precursor ) -> ast_fold {
609
617
// FIXME: Have to bind all the bare functions into shared functions
610
618
// because @mut is invariant with respect to its contents
619
+ // I assume this has something to do with Issue #1973 - tjc
611
620
let result : ast_fold =
612
621
@mut { fold_crate : bind nf_crate_dummy ( _) ,
613
622
fold_crate_directive : bind nf_crate_directive_dummy ( _) ,
@@ -625,6 +634,7 @@ fn make_fold(afp: ast_fold_precursor) -> ast_fold {
625
634
fold_expr : bind nf_expr_dummy ( _) ,
626
635
fold_ty : bind nf_ty_dummy ( _) ,
627
636
fold_constr : bind nf_constr_dummy ( _) ,
637
+ fold_ty_constr : bind nf_ty_constr_dummy ( _) ,
628
638
fold_mod : bind nf_mod_dummy ( _) ,
629
639
fold_native_mod : bind nf_native_mod_dummy ( _) ,
630
640
fold_variant : bind nf_variant_dummy ( _) ,
@@ -714,6 +724,13 @@ fn make_fold(afp: ast_fold_precursor) -> ast_fold {
714
724
let ( n , s ) = afp. fold_constr ( x. node , x. span , f ) ;
715
725
ret @{ node : n , span : afp. new_span ( s ) } ;
716
726
}
727
+ fn f_ty_constr ( afp : ast_fold_precursor , f : ast_fold ,
728
+ & & x: @ast:: ty_constr ) ->
729
+ @ast:: ty_constr {
730
+ let ( n , s ) : ( ty_constr_ , span ) =
731
+ afp. fold_ty_constr ( x. node , x. span , f ) ;
732
+ ret @{ node : n , span : afp. new_span ( s ) } ;
733
+ }
717
734
fn f_mod ( afp : ast_fold_precursor , f : ast_fold , x : _mod ) -> _mod {
718
735
ret afp. fold_mod ( x , f ) ;
719
736
}
@@ -755,6 +772,7 @@ fn make_fold(afp: ast_fold_precursor) -> ast_fold {
755
772
fold_expr : bind f_expr ( afp , result , _) ,
756
773
fold_ty : bind f_ty ( afp , result , _) ,
757
774
fold_constr : bind f_constr ( afp , result , _) ,
775
+ fold_ty_constr : bind f_ty_constr ( afp , result , _) ,
758
776
fold_mod : bind f_mod ( afp , result , _) ,
759
777
fold_native_mod : bind f_native_mod ( afp , result , _) ,
760
778
fold_variant : bind f_variant ( afp , result , _) ,
0 commit comments