Skip to content

Commit 55587a5

Browse files
committed
rustc: Sort object methods when parsing textual types in the AST
1 parent bc51842 commit 55587a5

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

src/comp/middle/ty.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,14 @@ fn method_idx(session.session sess, &span sp,
793793
fail;
794794
}
795795

796+
fn sort_methods(vec[method] meths) -> vec[method] {
797+
fn method_lteq(&method a, &method b) -> bool {
798+
ret _str.lteq(a.ident, b.ident);
799+
}
800+
801+
ret std.sort.merge_sort[method](bind method_lteq(_,_), meths);
802+
}
803+
796804
fn is_lval(@ast.expr expr) -> bool {
797805
alt (expr.node) {
798806
case (ast.expr_field(_,_,_)) { ret true; }

src/comp/middle/typeck.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,8 @@ fn ast_ty_to_ty(ty_getter getter, &@ast.ty ast_ty) -> @ty.t {
376376
inputs=ins,
377377
output=out));
378378
}
379-
sty = ty.ty_obj(tmeths);
379+
380+
sty = ty.ty_obj(ty.sort_methods(tmeths));
380381
}
381382
}
382383

@@ -545,14 +546,7 @@ fn collect_item_types(session.session sess, @ast.crate crate)
545546
auto methods =
546547
_vec.map[@ast.method,method](f, obj_info.methods);
547548

548-
fn method_lteq(&method a, &method b) -> bool {
549-
ret _str.lteq(a.ident, b.ident);
550-
}
551-
552-
methods = std.sort.merge_sort[method](bind method_lteq(_,_),
553-
methods);
554-
555-
auto t_obj = plain_ty(ty.ty_obj(methods));
549+
auto t_obj = plain_ty(ty.ty_obj(ty.sort_methods(methods)));
556550
ret t_obj;
557551
}
558552

0 commit comments

Comments
 (0)