@@ -201,6 +201,27 @@ impl<'gcc, 'tcx> BaseTypeMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
201201 fn val_ty ( & self , value : RValue < ' gcc > ) -> Type < ' gcc > {
202202 value. get_type ( )
203203 }
204+
205+ fn type_array ( & self , ty : Type < ' gcc > , mut len : u64 ) -> Type < ' gcc > {
206+ if let Some ( struct_type) = ty. is_struct ( ) {
207+ if struct_type. get_field_count ( ) == 0 {
208+ // NOTE: since gccjit only supports i32 for the array size and libcore's tests uses a
209+ // size of usize::MAX in test_binary_search, we workaround this by setting the size to
210+ // zero for ZSTs.
211+ // FIXME(antoyo): fix gccjit API.
212+ len = 0 ;
213+ }
214+ }
215+
216+ // NOTE: see note above. Some other test uses usize::MAX.
217+ if len == u64:: MAX {
218+ len = 0 ;
219+ }
220+
221+ let len: i32 = len. try_into ( ) . expect ( "array len" ) ;
222+
223+ self . context . new_array_type ( None , ty, len)
224+ }
204225}
205226
206227impl < ' gcc , ' tcx > CodegenCx < ' gcc , ' tcx > {
@@ -227,27 +248,6 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
227248 self . context . new_opaque_struct_type ( None , name)
228249 }
229250
230- pub fn type_array ( & self , ty : Type < ' gcc > , mut len : u64 ) -> Type < ' gcc > {
231- if let Some ( struct_type) = ty. is_struct ( ) {
232- if struct_type. get_field_count ( ) == 0 {
233- // NOTE: since gccjit only supports i32 for the array size and libcore's tests uses a
234- // size of usize::MAX in test_binary_search, we workaround this by setting the size to
235- // zero for ZSTs.
236- // FIXME(antoyo): fix gccjit API.
237- len = 0 ;
238- }
239- }
240-
241- // NOTE: see note above. Some other test uses usize::MAX.
242- if len == u64:: MAX {
243- len = 0 ;
244- }
245-
246- let len: i32 = len. try_into ( ) . expect ( "array len" ) ;
247-
248- self . context . new_array_type ( None , ty, len)
249- }
250-
251251 pub fn type_bool ( & self ) -> Type < ' gcc > {
252252 self . context . new_type :: < bool > ( )
253253 }
0 commit comments