Skip to content

Commit ecdc322

Browse files
fw-immunantkkysen
authored andcommitted
transpile: simplify import_type
1 parent 4b969f3 commit ecdc322

File tree

1 file changed

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

1 file changed

+4
-10
lines changed

c2rust-transpile/src/translator/mod.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5366,19 +5366,13 @@ impl<'c> Translation<'c> {
53665366
}
53675367

53685368
fn import_type(&self, ctype: CTypeId) {
5369-
for Import {
5370-
decl_id,
5371-
ident_name,
5372-
} in self.imports_for_type(ctype)
5373-
{
5374-
self.add_import(decl_id, &ident_name)
5375-
}
5369+
self.add_imports(&self.imports_for_type(ctype))
53765370
}
53775371

5378-
fn imports_for_type(&self, ctype: CTypeId) -> Vec<Import> {
5372+
fn imports_for_type(&self, ctype: CTypeId) -> IndexSet<Import> {
53795373
use self::CTypeKind::*;
53805374

5381-
let mut imports = vec![];
5375+
let mut imports = Default::default();
53825376

53835377
let type_kind = &self.ast_context[ctype].kind;
53845378
match type_kind {
@@ -5417,7 +5411,7 @@ impl<'c> Translation<'c> {
54175411
.borrow()
54185412
.resolve_decl_name(decl_id)
54195413
.expect("Expected decl name");
5420-
imports.push(Import {
5414+
imports.insert(Import {
54215415
decl_id,
54225416
ident_name,
54235417
});

0 commit comments

Comments
 (0)