Skip to content

Commit 60d818b

Browse files
chrysnkaspar030
authored andcommitted
asm: Use raw pointers rather than mutable references
This is a quick-and-dirty fix for immunant#309 without the ambition to get merged into c2rust in this way; at least it would need * exploring of other options * checking of the string-based "*mut _" and "&mut *" parts that may be better expressed using the mk() interfaces
1 parent 030df66 commit 60d818b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

c2rust-transpile/src/translator/assembly.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,11 @@ impl<'c> Translation<'c> {
103103
let output_local = mk().local(
104104
mk().ident_pat(&output_name),
105105
None as Option<P<Ty>>,
106-
Some(mk().mutbl().addr_of_expr(result)),
106+
Some(
107+
mk().cast_expr(
108+
mk().mutbl().addr_of_expr(result),
109+
mk().ident_ty("*mut _")
110+
)),
107111
);
108112
stmts.push(mk().local_stmt(P(output_local)));
109113

@@ -117,6 +121,7 @@ impl<'c> Translation<'c> {
117121
stmts.push(mk().local_stmt(P(inner_local)));
118122

119123
result = mk().ident_expr(&inner_name);
124+
let output_name = format!("&mut *{}", output_name);
120125
operand_renames.insert(operand_idx, (output_name, inner_name));
121126
} else {
122127
self.use_crate(ExternCrate::C2RustAsmCasts);

0 commit comments

Comments
 (0)