@@ -429,21 +429,21 @@ impl WithImplicitTemplateParams for syn::Type {
429
429
unreachable ! ( "we resolved item through type refs" )
430
430
}
431
431
// None of these types ever have implicit template parameters.
432
- TypeKind :: Void
433
- | TypeKind :: NullPtr
434
- | TypeKind :: Pointer ( ..)
435
- | TypeKind :: Reference ( ..)
436
- | TypeKind :: Int ( ..)
437
- | TypeKind :: Float ( ..)
438
- | TypeKind :: Complex ( ..)
439
- | TypeKind :: Array ( ..)
440
- | TypeKind :: TypeParam
441
- | TypeKind :: Opaque
442
- | TypeKind :: Function ( ..)
443
- | TypeKind :: Enum ( ..)
444
- | TypeKind :: ObjCId
445
- | TypeKind :: ObjCSel
446
- | TypeKind :: TemplateInstantiation ( ..) => None ,
432
+ TypeKind :: Void |
433
+ TypeKind :: NullPtr |
434
+ TypeKind :: Pointer ( ..) |
435
+ TypeKind :: Reference ( ..) |
436
+ TypeKind :: Int ( ..) |
437
+ TypeKind :: Float ( ..) |
438
+ TypeKind :: Complex ( ..) |
439
+ TypeKind :: Array ( ..) |
440
+ TypeKind :: TypeParam |
441
+ TypeKind :: Opaque |
442
+ TypeKind :: Function ( ..) |
443
+ TypeKind :: Enum ( ..) |
444
+ TypeKind :: ObjCId |
445
+ TypeKind :: ObjCSel |
446
+ TypeKind :: TemplateInstantiation ( ..) => None ,
447
447
_ => {
448
448
let params = item. used_template_params ( ctx) ;
449
449
if params. is_empty ( ) {
@@ -592,9 +592,9 @@ impl CodeGenerator for Module {
592
592
}
593
593
} ;
594
594
595
- if !ctx. options ( ) . enable_cxx_namespaces
596
- || ( self . is_inline ( )
597
- && !ctx. options ( ) . conservative_inline_namespaces )
595
+ if !ctx. options ( ) . enable_cxx_namespaces ||
596
+ ( self . is_inline ( ) &&
597
+ !ctx. options ( ) . conservative_inline_namespaces )
598
598
{
599
599
codegen_self ( result, & mut false ) ;
600
600
return ;
@@ -844,19 +844,19 @@ impl CodeGenerator for Type {
844
844
debug_assert ! ( item. is_enabled_for_codegen( ctx) ) ;
845
845
846
846
match * self . kind ( ) {
847
- TypeKind :: Void
848
- | TypeKind :: NullPtr
849
- | TypeKind :: Int ( ..)
850
- | TypeKind :: Float ( ..)
851
- | TypeKind :: Complex ( ..)
852
- | TypeKind :: Array ( ..)
853
- | TypeKind :: Vector ( ..)
854
- | TypeKind :: Pointer ( ..)
855
- | TypeKind :: Reference ( ..)
856
- | TypeKind :: Function ( ..)
857
- | TypeKind :: ResolvedTypeRef ( ..)
858
- | TypeKind :: Opaque
859
- | TypeKind :: TypeParam => {
847
+ TypeKind :: Void |
848
+ TypeKind :: NullPtr |
849
+ TypeKind :: Int ( ..) |
850
+ TypeKind :: Float ( ..) |
851
+ TypeKind :: Complex ( ..) |
852
+ TypeKind :: Array ( ..) |
853
+ TypeKind :: Vector ( ..) |
854
+ TypeKind :: Pointer ( ..) |
855
+ TypeKind :: Reference ( ..) |
856
+ TypeKind :: Function ( ..) |
857
+ TypeKind :: ResolvedTypeRef ( ..) |
858
+ TypeKind :: Opaque |
859
+ TypeKind :: TypeParam => {
860
860
// These items don't need code generation, they only need to be
861
861
// converted to rust types in fields, arguments, and such.
862
862
// NOTE(emilio): If you add to this list, make sure to also add
@@ -1020,11 +1020,11 @@ impl CodeGenerator for Type {
1020
1020
1021
1021
// We prefer using `pub use` over `pub type` because of:
1022
1022
// https://github.com/rust-lang/rust/issues/26264
1023
- if matches ! ( inner_rust_type, syn:: Type :: Path ( _) )
1024
- && outer_params. is_empty ( )
1025
- && !is_opaque
1026
- && alias_style == AliasVariation :: TypeAlias
1027
- && inner_item. expect_type ( ) . canonical_type ( ctx) . is_enum ( )
1023
+ if matches ! ( inner_rust_type, syn:: Type :: Path ( _) ) &&
1024
+ outer_params. is_empty ( ) &&
1025
+ !is_opaque &&
1026
+ alias_style == AliasVariation :: TypeAlias &&
1027
+ inner_item. expect_type ( ) . canonical_type ( ctx) . is_enum ( )
1028
1028
{
1029
1029
tokens. append_all ( quote ! {
1030
1030
pub use
@@ -1201,9 +1201,9 @@ impl CodeGenerator for Vtable<'_> {
1201
1201
// For now, we will only generate vtables for classes that:
1202
1202
// - do not inherit from others (compilers merge VTable from primary parent class).
1203
1203
// - do not contain a virtual destructor (requires ordering; platforms generate different vtables).
1204
- if ctx. options ( ) . vtable_generation
1205
- && self . comp_info . base_members ( ) . is_empty ( )
1206
- && self . comp_info . destructor ( ) . is_none ( )
1204
+ if ctx. options ( ) . vtable_generation &&
1205
+ self . comp_info . base_members ( ) . is_empty ( ) &&
1206
+ self . comp_info . destructor ( ) . is_none ( )
1207
1207
{
1208
1208
let class_ident = ctx. rust_ident ( self . item_id . canonical_name ( ctx) ) ;
1209
1209
@@ -1792,8 +1792,8 @@ impl FieldCodegen<'_> for BitfieldUnit {
1792
1792
continue ;
1793
1793
}
1794
1794
1795
- if layout. size > RUST_DERIVE_IN_ARRAY_LIMIT
1796
- && !ctx. options ( ) . rust_features ( ) . larger_arrays
1795
+ if layout. size > RUST_DERIVE_IN_ARRAY_LIMIT &&
1796
+ !ctx. options ( ) . rust_features ( ) . larger_arrays
1797
1797
{
1798
1798
continue ;
1799
1799
}
@@ -2395,10 +2395,10 @@ impl CodeGenerator for CompInfo {
2395
2395
2396
2396
// if a type has both a "packed" attribute and an "align(N)" attribute, then check if the
2397
2397
// "packed" attr is redundant, and do not include it if so.
2398
- if packed
2399
- && !is_opaque
2400
- && !( explicit_align. is_some ( )
2401
- && self . already_packed ( ctx) . unwrap_or ( false ) )
2398
+ if packed &&
2399
+ !is_opaque &&
2400
+ !( explicit_align. is_some ( ) &&
2401
+ self . already_packed ( ctx) . unwrap_or ( false ) )
2402
2402
{
2403
2403
let n = layout. map_or ( 1 , |l| l. align ) ;
2404
2404
assert ! ( ctx. options( ) . rust_features( ) . repr_packed_n || n == 1 ) ;
@@ -2439,32 +2439,32 @@ impl CodeGenerator for CompInfo {
2439
2439
2440
2440
let derivable_traits = derives_of_item ( item, ctx, packed) ;
2441
2441
if !derivable_traits. contains ( DerivableTraits :: DEBUG ) {
2442
- needs_debug_impl = ctx. options ( ) . derive_debug
2443
- && ctx. options ( ) . impl_debug
2444
- && !ctx. no_debug_by_name ( item)
2445
- && !item. annotations ( ) . disallow_debug ( ) ;
2442
+ needs_debug_impl = ctx. options ( ) . derive_debug &&
2443
+ ctx. options ( ) . impl_debug &&
2444
+ !ctx. no_debug_by_name ( item) &&
2445
+ !item. annotations ( ) . disallow_debug ( ) ;
2446
2446
}
2447
2447
2448
2448
if !derivable_traits. contains ( DerivableTraits :: DEFAULT ) {
2449
- needs_default_impl = ctx. options ( ) . derive_default
2450
- && !self . is_forward_declaration ( )
2451
- && !ctx. no_default_by_name ( item)
2452
- && !item. annotations ( ) . disallow_default ( ) ;
2449
+ needs_default_impl = ctx. options ( ) . derive_default &&
2450
+ !self . is_forward_declaration ( ) &&
2451
+ !ctx. no_default_by_name ( item) &&
2452
+ !item. annotations ( ) . disallow_default ( ) ;
2453
2453
}
2454
2454
2455
2455
let all_template_params = item. all_template_params ( ctx) ;
2456
2456
2457
- if derivable_traits. contains ( DerivableTraits :: COPY )
2458
- && !derivable_traits. contains ( DerivableTraits :: CLONE )
2457
+ if derivable_traits. contains ( DerivableTraits :: COPY ) &&
2458
+ !derivable_traits. contains ( DerivableTraits :: CLONE )
2459
2459
{
2460
2460
needs_clone_impl = true ;
2461
2461
}
2462
2462
2463
2463
if !derivable_traits. contains ( DerivableTraits :: PARTIAL_EQ ) {
2464
- needs_partialeq_impl = ctx. options ( ) . derive_partialeq
2465
- && ctx. options ( ) . impl_partialeq
2466
- && ctx. lookup_can_derive_partialeq_or_partialord ( item. id ( ) )
2467
- == CanDerive :: Manually ;
2464
+ needs_partialeq_impl = ctx. options ( ) . derive_partialeq &&
2465
+ ctx. options ( ) . impl_partialeq &&
2466
+ ctx. lookup_can_derive_partialeq_or_partialord ( item. id ( ) ) ==
2467
+ CanDerive :: Manually ;
2468
2468
}
2469
2469
2470
2470
let mut derives: Vec < _ > = derivable_traits. into ( ) ;
@@ -2646,8 +2646,8 @@ impl CodeGenerator for CompInfo {
2646
2646
. collect ( )
2647
2647
} ;
2648
2648
2649
- let uninit_decl = if check_field_offset. is_empty ( )
2650
- || compile_time
2649
+ let uninit_decl = if check_field_offset. is_empty ( ) ||
2650
+ compile_time
2651
2651
{
2652
2652
None
2653
2653
} else {
@@ -2993,11 +2993,11 @@ impl Method {
2993
2993
let cc = & ctx. options( ) . codegen_config;
2994
2994
match self . kind( ) {
2995
2995
MethodKind :: Constructor => cc. constructors( ) ,
2996
- MethodKind :: Destructor
2997
- | MethodKind :: VirtualDestructor { .. } => cc. destructors( ) ,
2998
- MethodKind :: Static
2999
- | MethodKind :: Normal
3000
- | MethodKind :: Virtual { .. } => cc. methods( ) ,
2996
+ MethodKind :: Destructor |
2997
+ MethodKind :: VirtualDestructor { .. } => cc. destructors( ) ,
2998
+ MethodKind :: Static |
2999
+ MethodKind :: Normal |
3000
+ MethodKind :: Virtual { .. } => cc. methods( ) ,
3001
3001
}
3002
3002
} ) ;
3003
3003
@@ -3517,8 +3517,8 @@ impl EnumBuilder {
3517
3517
}
3518
3518
variants
3519
3519
}
3520
- EnumBuilderKind :: Consts { .. }
3521
- | EnumBuilderKind :: ModuleConsts { .. } => {
3520
+ EnumBuilderKind :: Consts { .. } |
3521
+ EnumBuilderKind :: ModuleConsts { .. } => {
3522
3522
let mut variants = vec ! [ ] ;
3523
3523
3524
3524
for v in self . enum_variants {
@@ -3640,8 +3640,8 @@ impl CodeGenerator for Enum {
3640
3640
let repr_translated;
3641
3641
let repr = match self . repr ( ) . map ( |repr| ctx. resolve_type ( repr) ) {
3642
3642
Some ( repr)
3643
- if !ctx. options ( ) . translate_enum_integer_types
3644
- && !variation. is_rust ( ) =>
3643
+ if !ctx. options ( ) . translate_enum_integer_types &&
3644
+ !variation. is_rust ( ) =>
3645
3645
{
3646
3646
repr
3647
3647
}
@@ -3712,10 +3712,10 @@ impl CodeGenerator for Enum {
3712
3712
// Clone/Eq/PartialEq/Hash, even if we don't generate those by
3713
3713
// default.
3714
3714
derives. insert (
3715
- DerivableTraits :: CLONE
3716
- | DerivableTraits :: HASH
3717
- | DerivableTraits :: PARTIAL_EQ
3718
- | DerivableTraits :: EQ ,
3715
+ DerivableTraits :: CLONE |
3716
+ DerivableTraits :: HASH |
3717
+ DerivableTraits :: PARTIAL_EQ |
3718
+ DerivableTraits :: EQ ,
3719
3719
) ;
3720
3720
let mut derives: Vec < _ > = derives. into ( ) ;
3721
3721
for derive in item. annotations ( ) . derives ( ) {
@@ -3856,8 +3856,8 @@ impl CodeGenerator for Enum {
3856
3856
Entry :: Occupied ( ref entry) => {
3857
3857
if variation. is_rust ( ) {
3858
3858
let variant_name = ctx. rust_mangle ( variant. name ( ) ) ;
3859
- let mangled_name = if is_toplevel
3860
- || enum_ty. name ( ) . is_some ( )
3859
+ let mangled_name = if is_toplevel ||
3860
+ enum_ty. name ( ) . is_some ( )
3861
3861
{
3862
3862
variant_name
3863
3863
} else {
@@ -3916,8 +3916,8 @@ impl CodeGenerator for Enum {
3916
3916
// If it's an unnamed enum, or constification is enforced,
3917
3917
// we also generate a constant so it can be properly
3918
3918
// accessed.
3919
- if ( variation. is_rust ( ) && enum_ty. name ( ) . is_none ( ) )
3920
- || variant. force_constification ( )
3919
+ if ( variation. is_rust ( ) && enum_ty. name ( ) . is_none ( ) ) ||
3920
+ variant. force_constification ( )
3921
3921
{
3922
3922
let mangled_name = if is_toplevel {
3923
3923
variant_name. clone ( )
@@ -4360,17 +4360,16 @@ impl TryToRustTy for Type {
4360
4360
inst. try_to_rust_ty ( ctx, item)
4361
4361
}
4362
4362
TypeKind :: ResolvedTypeRef ( inner) => inner. try_to_rust_ty ( ctx, & ( ) ) ,
4363
- TypeKind :: TemplateAlias ( ..)
4364
- | TypeKind :: Alias ( ..)
4365
- | TypeKind :: BlockPointer ( ..) => {
4363
+ TypeKind :: TemplateAlias ( ..) |
4364
+ TypeKind :: Alias ( ..) |
4365
+ TypeKind :: BlockPointer ( ..) => {
4366
4366
if self . is_block_pointer ( ) && !ctx. options ( ) . generate_block {
4367
4367
let void = c_void ( ctx) ;
4368
4368
return Ok ( void. to_ptr ( /* is_const = */ false ) ) ;
4369
4369
}
4370
4370
4371
- if item. is_opaque ( ctx, & ( ) )
4372
- && item
4373
- . used_template_params ( ctx)
4371
+ if item. is_opaque ( ctx, & ( ) ) &&
4372
+ item. used_template_params ( ctx)
4374
4373
. into_iter ( )
4375
4374
. any ( |param| param. is_template_param ( ctx, & ( ) ) )
4376
4375
{
@@ -4386,8 +4385,8 @@ impl TryToRustTy for Type {
4386
4385
}
4387
4386
TypeKind :: Comp ( ref info) => {
4388
4387
let template_params = item. all_template_params ( ctx) ;
4389
- if info. has_non_type_template_params ( )
4390
- || ( item. is_opaque ( ctx, & ( ) ) && !template_params. is_empty ( ) )
4388
+ if info. has_non_type_template_params ( ) ||
4389
+ ( item. is_opaque ( ctx, & ( ) ) && !template_params. is_empty ( ) )
4391
4390
{
4392
4391
return self . try_to_opaque ( ctx, item) ;
4393
4392
}
@@ -4738,9 +4737,9 @@ impl CodeGenerator for Function {
4738
4737
}
4739
4738
}
4740
4739
4741
- let should_wrap = is_internal
4742
- && ctx. options ( ) . wrap_static_fns
4743
- && link_name_attr. is_none ( ) ;
4740
+ let should_wrap = is_internal &&
4741
+ ctx. options ( ) . wrap_static_fns &&
4742
+ link_name_attr. is_none ( ) ;
4744
4743
4745
4744
if should_wrap {
4746
4745
let name = canonical_name. clone ( ) + ctx. wrap_static_fns_suffix ( ) ;
@@ -5284,8 +5283,8 @@ pub(crate) mod utils {
5284
5283
std:: fs:: create_dir_all ( dir) ?;
5285
5284
}
5286
5285
5287
- let is_cpp = args_are_cpp ( & context. options ( ) . clang_args )
5288
- || context
5286
+ let is_cpp = args_are_cpp ( & context. options ( ) . clang_args ) ||
5287
+ context
5289
5288
. options ( )
5290
5289
. input_headers
5291
5290
. iter ( )
@@ -5383,8 +5382,8 @@ pub(crate) mod utils {
5383
5382
ctx : & BindgenContext ,
5384
5383
result : & mut Vec < proc_macro2:: TokenStream > ,
5385
5384
) {
5386
- if ctx. options ( ) . blocklisted_items . matches ( BITFIELD_UNIT )
5387
- || ctx. options ( ) . blocklisted_types . matches ( BITFIELD_UNIT )
5385
+ if ctx. options ( ) . blocklisted_items . matches ( BITFIELD_UNIT ) ||
5386
+ ctx. options ( ) . blocklisted_types . matches ( BITFIELD_UNIT )
5388
5387
{
5389
5388
return ;
5390
5389
}
0 commit comments