@@ -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,16 +4360,17 @@ 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. used_template_params ( ctx)
4371
+ if item. is_opaque ( ctx, & ( ) )
4372
+ && item
4373
+ . used_template_params ( ctx)
4373
4374
. into_iter ( )
4374
4375
. any ( |param| param. is_template_param ( ctx, & ( ) ) )
4375
4376
{
@@ -4385,8 +4386,8 @@ impl TryToRustTy for Type {
4385
4386
}
4386
4387
TypeKind :: Comp ( ref info) => {
4387
4388
let template_params = item. all_template_params ( ctx) ;
4388
- if info. has_non_type_template_params ( ) ||
4389
- ( item. is_opaque ( ctx, & ( ) ) && !template_params. is_empty ( ) )
4389
+ if info. has_non_type_template_params ( )
4390
+ || ( item. is_opaque ( ctx, & ( ) ) && !template_params. is_empty ( ) )
4390
4391
{
4391
4392
return self . try_to_opaque ( ctx, item) ;
4392
4393
}
@@ -4717,28 +4718,29 @@ impl CodeGenerator for Function {
4717
4718
// Unfortunately this can't piggyback on the `attributes` list because
4718
4719
// the #[link(wasm_import_module)] needs to happen before the `extern
4719
4720
// "C"` block. It doesn't get picked up properly otherwise
4720
- let link_attribute = match (
4721
- ctx. options ( ) . wasm_import_module_name . as_ref ( ) ,
4722
- & ctx. options ( ) . windows_link_as_raw_dylib ,
4723
- ) {
4724
- ( Some ( _) , ( Some ( _) , _) ) => {
4725
- panic ! ( "Cannot link against a wasm import module and a raw dylib at the same time" ) ;
4726
- }
4727
- ( Some ( name) , ( None , _) ) => {
4728
- Some ( quote ! { #[ link( wasm_import_module = #name) ] } )
4721
+ let mut link_attribute = quote ! { } ;
4722
+ if let Some ( ref wasm_name) = ctx. options ( ) . wasm_import_module_name {
4723
+ link_attribute. extend ( quote ! {
4724
+ #[ link( wasm_import_module = #wasm_name) ]
4725
+ } ) ;
4726
+ }
4727
+ if let ( Some ( ref windows_name) , verbatim) =
4728
+ ctx. options ( ) . windows_link_as_raw_dylib
4729
+ {
4730
+ if verbatim {
4731
+ link_attribute. extend ( quote ! {
4732
+ #[ cfg_attr( windows, link( name = #windows_name, kind = "raw-dylib" , modifiers = "+verbatim" ) ) ]
4733
+ } ) ;
4734
+ } else {
4735
+ link_attribute. extend ( quote ! {
4736
+ #[ cfg_attr( windows, link( name = #windows_name, kind = "raw-dylib" ) ) ]
4737
+ } ) ;
4729
4738
}
4730
- ( None , ( Some ( name) , false ) ) => Some (
4731
- quote ! { #[ cfg_attr( windows, link( name = #name, kind = "raw-dylib" ) ) ] } ,
4732
- ) ,
4733
- ( None , ( Some ( name) , true ) ) => Some (
4734
- quote ! { #[ cfg_attr( windows, link( name = #name, kind = "raw-dylib" , modifiers = "+verbatim" ) ) ] } ,
4735
- ) ,
4736
- _ => None ,
4737
- } ;
4739
+ }
4738
4740
4739
- let should_wrap = is_internal &&
4740
- ctx. options ( ) . wrap_static_fns &&
4741
- link_name_attr. is_none ( ) ;
4741
+ let should_wrap = is_internal
4742
+ && ctx. options ( ) . wrap_static_fns
4743
+ && link_name_attr. is_none ( ) ;
4742
4744
4743
4745
if should_wrap {
4744
4746
let name = canonical_name. clone ( ) + ctx. wrap_static_fns_suffix ( ) ;
@@ -5282,8 +5284,8 @@ pub(crate) mod utils {
5282
5284
std:: fs:: create_dir_all ( dir) ?;
5283
5285
}
5284
5286
5285
- let is_cpp = args_are_cpp ( & context. options ( ) . clang_args ) ||
5286
- context
5287
+ let is_cpp = args_are_cpp ( & context. options ( ) . clang_args )
5288
+ || context
5287
5289
. options ( )
5288
5290
. input_headers
5289
5291
. iter ( )
@@ -5381,8 +5383,8 @@ pub(crate) mod utils {
5381
5383
ctx : & BindgenContext ,
5382
5384
result : & mut Vec < proc_macro2:: TokenStream > ,
5383
5385
) {
5384
- if ctx. options ( ) . blocklisted_items . matches ( BITFIELD_UNIT ) ||
5385
- ctx. options ( ) . blocklisted_types . matches ( BITFIELD_UNIT )
5386
+ if ctx. options ( ) . blocklisted_items . matches ( BITFIELD_UNIT )
5387
+ || ctx. options ( ) . blocklisted_types . matches ( BITFIELD_UNIT )
5386
5388
{
5387
5389
return ;
5388
5390
}
0 commit comments