Skip to content

Commit 52a7af6

Browse files
committed
transpile: move sorting top-level decls after they're converted but before they're inserted
This should ensure that those two steps are properly separated.
1 parent 39511dc commit 52a7af6

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
@@ -495,10 +495,6 @@ pub fn translate(
495495
};
496496

497497
{
498-
// Sort the top-level declarations by file and source location so that we
499-
// preserve the ordering of all declarations in each file.
500-
t.ast_context.sort_top_decls();
501-
502498
t.locate_comments();
503499

504500
// Headers often pull in declarations that are unused;
@@ -742,6 +738,10 @@ pub fn translate(
742738
})
743739
.collect::<HashMap<_, _>>();
744740

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();
744+
745745
for top_id in &t.ast_context.c_decls_top {
746746
let decl = t.ast_context.get_decl(top_id).unwrap();
747747
let decl_file_id = t.ast_context.file_id(decl);

0 commit comments

Comments
 (0)