Skip to content

Commit cf9c20f

Browse files
committed
transpile: infer arg types from type of called fn ptr
1 parent f38311f commit cf9c20f

File tree

1 file changed

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

1 file changed

+4
-2
lines changed

c2rust-transpile/src/translator/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3801,7 +3801,7 @@ impl<'c> Translation<'c> {
38013801
_ => false,
38023802
};
38033803

3804-
let arg_tys = if let Some(CDeclKind::Function { parameters, .. }) =
3804+
let mut arg_tys = if let Some(CDeclKind::Function { parameters, .. }) =
38053805
self.ast_context.function_declref_decl(func)
38063806
{
38073807
self.ast_context.tys_of_params(parameters)
@@ -3857,10 +3857,12 @@ impl<'c> Translation<'c> {
38573857
transmute_expr(mk().infer_ty(), target_ty, fn_ptr)
38583858
})
38593859
}
3860-
Some(_) => {
3860+
Some(CTypeKind::Function(_, ty_arg_tys, ..)) => {
3861+
arg_tys = Some(ty_arg_tys.clone());
38613862
// Normal function pointer
38623863
callee.map(unwrap_function_pointer)
38633864
}
3865+
Some(_) => panic!("function pointer did not point to CTYpeKind::Function: {fn_ty:?}"),
38643866
}
38653867
}
38663868
};

0 commit comments

Comments
 (0)