@@ -255,7 +255,7 @@ impl<'ctx> CannotDerive<'ctx> {
255
255
return CanDerive :: No ;
256
256
}
257
257
258
- if self . derive_trait . can_derive_large_array ( ) {
258
+ if self . derive_trait . can_derive_large_array ( & self . ctx ) {
259
259
trace ! ( " array can derive {}" , self . derive_trait) ;
260
260
return CanDerive :: Yes ;
261
261
}
@@ -377,7 +377,7 @@ impl<'ctx> CannotDerive<'ctx> {
377
377
// Bitfield units are always represented as arrays of u8, but
378
378
// they're not traced as arrays, so we need to check here
379
379
// instead.
380
- if !self . derive_trait . can_derive_large_array ( ) &&
380
+ if !self . derive_trait . can_derive_large_array ( & self . ctx ) &&
381
381
info. has_too_large_bitfield_unit ( ) &&
382
382
!item. is_opaque ( self . ctx , & ( ) )
383
383
{
@@ -496,10 +496,17 @@ impl DeriveTrait {
496
496
}
497
497
}
498
498
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
+ }
503
510
}
504
511
}
505
512
@@ -686,7 +693,7 @@ impl<'ctx> MonotoneFramework for CannotDerive<'ctx> {
686
693
Some ( ty) => {
687
694
let mut can_derive = self . constrain_type ( item, ty) ;
688
695
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 ) &&
690
697
ty. layout ( self . ctx ) . map_or ( false , |l| {
691
698
l. align > RUST_DERIVE_IN_ARRAY_LIMIT
692
699
} )
0 commit comments