Skip to content

Commit 98e803b

Browse files
committed
transpile: rename fn sort_top_decls to sort_top_decls_for_emitting and add docs
1 parent 36bf7d4 commit 98e803b

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
@@ -735,9 +735,7 @@ pub fn translate(
735735
})
736736
.collect::<HashMap<_, _>>();
737737

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

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

0 commit comments

Comments
 (0)