@@ -869,35 +869,19 @@ mod test {
869869 use parse:: token;
870870 use print:: pprust;
871871 use super :: * ;
872-
873- struct IdentFolder {
874- f : @fn ( ast:: ident ) ->ast:: ident ,
875- }
876-
877- impl ast_fold for IdentFolder {
878- fn fold_ident ( @self , i : ident ) -> ident {
879- ( self . f ) ( i)
880- }
881- }
882-
883- // taken from expand
884- // given a function from idents to idents, produce
885- // an ast_fold that applies that function:
886- pub fn fun_to_ident_folder ( f : @fn ( ast:: ident ) ->ast:: ident ) -> @ast_fold {
887- @IdentFolder {
888- f : f,
889- } as @ast_fold
890- }
891-
872+
892873 // this version doesn't care about getting comments or docstrings in.
893874 fn fake_print_crate ( s : @pprust:: ps , crate : & ast:: Crate ) {
894875 pprust:: print_mod ( s, & crate . module, crate . attrs) ;
895876 }
896877
897878 // change every identifier to "zz"
898- pub fn to_zz ( ) -> @fn ( ast:: Ident ) ->ast:: Ident {
899- let zz_id = token:: str_to_ident ( "zz" ) ;
900- |_id| { zz_id}
879+ struct ToZzIdentFolder ;
880+
881+ impl ast_fold for ToZzIdentFolder {
882+ fn fold_ident ( & self , _: ident ) -> ident {
883+ token:: str_to_ident ( "zz" )
884+ }
901885 }
902886
903887 // maybe add to expand.rs...
@@ -917,7 +901,7 @@ mod test {
917901
918902 // make sure idents get transformed everywhere
919903 #[ test] fn ident_transformation ( ) {
920- let zz_fold = fun_to_ident_folder ( to_zz ( ) ) ;
904+ let zz_fold = ToZzIdentFolder ;
921905 let ast = string_to_crate ( @"#[ a] mod b { fn c ( d : e, f : g) { h ! ( i, j, k) ; l; m} } ") ;
922906 assert_pred ! ( matches_codepattern,
923907 "matches_codepattern" ,
@@ -928,7 +912,7 @@ mod test {
928912
929913 // even inside macro defs....
930914 #[test] fn ident_transformation_in_defs () {
931- let zz_fold = fun_to_ident_folder(to_zz()) ;
915+ let zz_fold = ToZzIdentFolder ;
932916 let ast = string_to_crate(@" macro_rules! a { ( b $c: expr $( d $e: token) f+
933917=> ( g $( d $d $e) +) ) } ");
934918 assert_pred!(matches_codepattern,
@@ -940,7 +924,7 @@ mod test {
940924
941925 // and in cast expressions... this appears to be an existing bug.
942926 #[test] fn ident_transformation_in_types () {
943- let zz_fold = fun_to_ident_folder(to_zz()) ;
927+ let zz_fold = ToZzIdentFolder ;
944928 let ast = string_to_crate(@" fn a( ) { let z = 13 as int; } ");
945929 assert_pred!(matches_codepattern,
946930 " matches_codepattern",
0 commit comments