Skip to content

Commit 36bf7d4

Browse files
committed
transpile: move sorting top-level decls after their converted but before they're inserted
This should ensure that those two steps are properly separated.
1 parent 3b5ec86 commit 36bf7d4

File tree

1 file changed

+4
-4
lines changed
  • c2rust-transpile/src/translator

1 file changed

+4
-4
lines changed

c2rust-transpile/src/translator/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -492,10 +492,6 @@ pub fn translate(
492492
};
493493

494494
{
495-
// Sort the top-level declarations by file and source location so that we
496-
// preserve the ordering of all declarations in each file.
497-
t.ast_context.sort_top_decls();
498-
499495
t.locate_comments();
500496

501497
// Headers often pull in declarations that are unused;
@@ -739,6 +735,10 @@ pub fn translate(
739735
})
740736
.collect::<HashMap<_, _>>();
741737

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();
741+
742742
for top_id in &t.ast_context.c_decls_top {
743743
let decl = t.ast_context.get_decl(top_id).unwrap();
744744
let decl_file_id = t.ast_context.file_id(decl);

0 commit comments

Comments
 (0)