Skip to content

Commit 37113e1

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 49338c5 commit 37113e1

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
@@ -494,10 +494,6 @@ pub fn translate(
494494
{
495495
t.use_crate(ExternCrate::Libc);
496496

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

503499
// Headers often pull in declarations that are unused;
@@ -741,6 +737,10 @@ pub fn translate(
741737
})
742738
.collect::<HashMap<_, _>>();
743739

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

0 commit comments

Comments
 (0)