Skip to content

Commit 584b50b

Browse files
fw-immunantkkysen
authored andcommitted
transpile: disable caching zero initializers
computing these is impure because it can call `import_type`. ideally we would not disable this caching but instead cache both the initializer and its set of required imports.
1 parent 8629391 commit 584b50b

File tree

1 file changed

+3
-2
lines changed
  • c2rust-transpile/src/translator

1 file changed

+3
-2
lines changed

c2rust-transpile/src/translator/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4996,10 +4996,11 @@ impl<'c> Translation<'c> {
49964996
self.import_type(type_id, file_id);
49974997
}
49984998

4999+
// Caching skips critical side effect of `import_type` call.
49995000
// Look up the decl in the cache and return what we find (if we find anything)
5000-
if let Some(init) = self.zero_inits.borrow().get(&decl_id) {
5001+
/*if let Some(init) = self.zero_inits.borrow().get(&decl_id) {
50015002
return Ok(init.clone());
5002-
}
5003+
}*/
50035004

50045005
let name_decl_id = match self.ast_context.index(type_id).kind {
50055006
CTypeKind::Typedef(decl_id) => decl_id,

0 commit comments

Comments
 (0)