@@ -255,7 +255,7 @@ impl<'ctx> CannotDerive<'ctx> {
255255 return CanDerive :: No ;
256256 }
257257
258- if self . derive_trait . can_derive_large_array ( ) {
258+ if self . derive_trait . can_derive_large_array ( & self . ctx ) {
259259 trace ! ( " array can derive {}" , self . derive_trait) ;
260260 return CanDerive :: Yes ;
261261 }
@@ -377,7 +377,7 @@ impl<'ctx> CannotDerive<'ctx> {
377377 // Bitfield units are always represented as arrays of u8, but
378378 // they're not traced as arrays, so we need to check here
379379 // instead.
380- if !self . derive_trait . can_derive_large_array ( ) &&
380+ if !self . derive_trait . can_derive_large_array ( & self . ctx ) &&
381381 info. has_too_large_bitfield_unit ( ) &&
382382 !item. is_opaque ( self . ctx , & ( ) )
383383 {
@@ -496,10 +496,17 @@ impl DeriveTrait {
496496 }
497497 }
498498
499- fn can_derive_large_array ( & self ) -> bool {
500- match self {
501- DeriveTrait :: Copy => true ,
502- _ => false ,
499+ fn can_derive_large_array ( & self , ctx : & BindgenContext ) -> bool {
500+ if ctx. options ( ) . rust_features ( ) . larger_arrays {
501+ match self {
502+ DeriveTrait :: Default => false ,
503+ _ => true ,
504+ }
505+ } else {
506+ match self {
507+ DeriveTrait :: Copy => true ,
508+ _ => false ,
509+ }
503510 }
504511 }
505512
@@ -686,7 +693,7 @@ impl<'ctx> MonotoneFramework for CannotDerive<'ctx> {
686693 Some ( ty) => {
687694 let mut can_derive = self . constrain_type ( item, ty) ;
688695 if let CanDerive :: Yes = can_derive {
689- if !self . derive_trait . can_derive_large_array ( ) &&
696+ if !self . derive_trait . can_derive_large_array ( & self . ctx ) &&
690697 ty. layout ( self . ctx ) . map_or ( false , |l| {
691698 l. align > RUST_DERIVE_IN_ARRAY_LIMIT
692699 } )
0 commit comments