Skip to content

Commit 3620fdd

Browse files
committed
transpile: rename fn sort_top_decls to sort_top_decls_for_emitting and add docs
1 parent ce765dd commit 3620fdd

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

c2rust-transpile/src/c_ast/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -986,8 +986,10 @@ impl TypedAstContext {
986986
}
987987
}
988988

989-
pub fn sort_top_decls(&mut self) {
990-
// Group and sort declarations by file and by position
989+
/// Sort the top-level declarations by file and source location
990+
/// so that we preserve the ordering of all declarations in each file.
991+
/// This preserves the order when we emit the converted declarations.
992+
pub fn sort_top_decls_for_emitting(&mut self) {
991993
let mut decls_top = mem::take(&mut self.c_decls_top);
992994
decls_top.sort_unstable_by(|a, b| {
993995
let a = self.index(*a);

c2rust-transpile/src/translator/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -738,9 +738,7 @@ pub fn translate(
738738
})
739739
.collect::<HashMap<_, _>>();
740740

741-
// Sort the top-level declarations by file and source location so that we
742-
// preserve the ordering of all declarations in each file.
743-
t.ast_context.sort_top_decls();
741+
t.ast_context.sort_top_decls_for_emitting();
744742

745743
for top_id in &t.ast_context.c_decls_top {
746744
let decl = t.ast_context.get_decl(top_id).unwrap();

0 commit comments

Comments
 (0)