@@ -1135,7 +1135,7 @@ fn print_fn_args_and_ret(s: &ps, decl: &ast::fn_decl,
1135
1135
}
1136
1136
commasep ( s, inconsistent, decl. inputs , print_arg) ;
1137
1137
pclose ( s) ;
1138
- word ( s. s , ast_constrs_str ( constrs) ) ;
1138
+ word ( s. s , ast_fn_constrs_str ( decl , constrs) ) ;
1139
1139
maybe_print_comment ( s, decl. output . span . lo ) ;
1140
1140
if decl. output . node != ast:: ty_nil {
1141
1141
space_if_not_bol ( s) ;
@@ -1290,7 +1290,7 @@ fn print_ty_fn(s: &ps, proto: &ast::proto, id: &option::t[str],
1290
1290
}
1291
1291
end ( s) ;
1292
1292
}
1293
- word ( s. s , ast_constrs_str ( constrs) ) ;
1293
+ word ( s. s , ast_ty_fn_constrs_str ( constrs) ) ;
1294
1294
end ( s) ;
1295
1295
}
1296
1296
@@ -1498,18 +1498,40 @@ fn constr_arg_to_str[T](f: &fn(&T) -> str , c: &ast::constr_arg_general_[T])
1498
1498
// (argh)
1499
1499
fn uint_to_str(i: &uint) -> str { ret uint::str(i); }
1500
1500
1501
- fn ast_constr_to_str (c: &@ast::constr) -> str {
1501
+ fn ast_ty_fn_constr_to_str (c: &@ast::constr) -> str {
1502
1502
ret path_to_str(c.node.path) +
1503
1503
constr_args_to_str(uint_to_str, c.node.args);
1504
1504
}
1505
1505
1506
1506
// FIXME: fix repeated code
1507
- fn ast_constrs_str (constrs: &(@ast::constr)[]) -> str {
1507
+ fn ast_ty_fn_constrs_str (constrs: &(@ast::constr)[]) -> str {
1508
1508
let s = " ";
1509
1509
let colon = true ;
1510
1510
for c: @ast:: constr in constrs {
1511
1511
if colon { s += " : " ; colon = false ; } else { s += ", " ; }
1512
- s += ast_constr_to_str ( c) ;
1512
+ s += ast_ty_fn_constr_to_str ( c) ;
1513
+ }
1514
+ ret s;
1515
+ }
1516
+
1517
+ fn fn_arg_idx_to_str ( decl : & ast:: fn_decl , idx : & uint ) -> str {
1518
+ decl. inputs . ( idx) . ident
1519
+ }
1520
+
1521
+ fn ast_fn_constr_to_str ( decl : & ast:: fn_decl , c : & @ast:: constr ) -> str {
1522
+ let arg_to_str = bind fn_arg_idx_to_str ( decl, _) ;
1523
+ ret path_to_str ( c. node . path ) +
1524
+ constr_args_to_str ( arg_to_str, c. node . args ) ;
1525
+ }
1526
+
1527
+ // FIXME: fix repeated code
1528
+ fn ast_fn_constrs_str ( decl : & ast:: fn_decl ,
1529
+ constrs : & ( @ast:: constr ) [ ] ) -> str {
1530
+ let s = "" ;
1531
+ let colon = true ;
1532
+ for c: @ast:: constr in constrs {
1533
+ if colon { s += " : " ; colon = false ; } else { s += ", " ; }
1534
+ s += ast_fn_constr_to_str ( decl, c) ;
1513
1535
}
1514
1536
ret s;
1515
1537
}
0 commit comments