Skip to content

Commit 793e6c7

Browse files
committed
transpile: rename fn sort_top_decls to sort_top_decls_for_emitting and add docs
1 parent 37113e1 commit 793e6c7

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
@@ -973,8 +973,10 @@ impl TypedAstContext {
973973
}
974974
}
975975

976-
pub fn sort_top_decls(&mut self) {
977-
// Group and sort declarations by file and by position
976+
/// Sort the top-level declarations by file and source location
977+
/// so that we preserve the ordering of all declarations in each file.
978+
/// This preserves the order when we emit the converted declarations.
979+
pub fn sort_top_decls_for_emitting(&mut self) {
978980
let mut decls_top = mem::take(&mut self.c_decls_top);
979981
decls_top.sort_unstable_by(|a, b| {
980982
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
@@ -737,9 +737,7 @@ pub fn translate(
737737
})
738738
.collect::<HashMap<_, _>>();
739739

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

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

0 commit comments

Comments
 (0)