Skip to content

Commit 6f0ddb3

Browse files
committed
transpile: prune_unwanted_decls only after setting prenamed_decls
1 parent d9242d2 commit 6f0ddb3

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

c2rust-transpile/src/c_ast/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,6 +1159,8 @@ impl TypedAstContext {
11591159

11601160
// Remove references to removed decls that are held elsewhere.
11611161
self.c_decls_top.retain(|x| self.c_decls.contains_key(x));
1162+
self.prenamed_decls
1163+
.retain(|x, _| self.c_decls.contains_key(x));
11621164

11631165
if let Some(main_id) = self.c_main {
11641166
if !self.c_decls.contains_key(&main_id) {

c2rust-transpile/src/translator/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,10 @@ pub fn translate(
708708
None
709709
};
710710

711+
// Identify typedefs that name unnamed types and collapse the two declarations
712+
// into a single name and declaration, eliminating the typedef altogether.
713+
t.ast_context.set_prenamed_decls();
714+
711715
// Headers often pull in declarations that are unused;
712716
// we simplify the translator output by omitting those.
713717
t.ast_context
@@ -737,10 +741,6 @@ pub fn translate(
737741
prefix_names(&mut t, prefix);
738742
}
739743

740-
// Identify typedefs that name unnamed types and collapse the two declarations
741-
// into a single name and declaration, eliminating the typedef altogether.
742-
t.ast_context.set_prenamed_decls();
743-
744744
for (&decl_id, &subdecl_id) in &t.ast_context.prenamed_decls {
745745
if let CDeclKind::Typedef { ref name, .. } = t.ast_context[decl_id].kind {
746746
t.type_converter

0 commit comments

Comments
 (0)