@@ -172,7 +172,8 @@ impl<'c> Translation<'c> {
172172 // Convert all of the provided initializer values
173173
174174 let to_array_element = |id : CExprId | -> TranslationResult < _ > {
175- self . convert_expr ( ctx. used ( ) , id, None ) ?. result_map ( |x| {
175+ let val = self . convert_expr ( ctx. used ( ) , id, Some ( CQualTypeId :: new ( ty) ) ) ?;
176+ val. result_map ( |x| {
176177 // Array literals require all of their elements to be
177178 // the correct type; they will not use implicit casts to
178179 // change mut to const. This becomes a problem when an
@@ -236,7 +237,7 @@ impl<'c> Translation<'c> {
236237 // * `ptr_extra_braces`
237238 // * `array_of_ptrs`
238239 // * `array_of_arrays`
239- self . convert_expr ( ctx. used ( ) , single, None )
240+ self . convert_expr ( ctx. used ( ) , single, Some ( ty ) )
240241 }
241242 & [ single] if is_zero_literal ( single) && n > 1 => {
242243 // This was likely a C array of the form `int x[16] = { 0 }`.
@@ -271,7 +272,7 @@ impl<'c> Translation<'c> {
271272 }
272273 ref kind if kind. is_scalar ( ) => {
273274 if let Some ( & first) = ids. first ( ) {
274- self . convert_expr ( ctx. used ( ) , first, None )
275+ self . convert_expr ( ctx. used ( ) , first, Some ( ty ) )
275276 } else {
276277 self . implicit_default_expr ( ctx. used ( ) , ty. ctype )
277278 }
0 commit comments