@@ -429,21 +429,21 @@ impl WithImplicitTemplateParams for syn::Type {
429429 unreachable ! ( "we resolved item through type refs" )
430430 }
431431 // 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 ,
447447 _ => {
448448 let params = item. used_template_params ( ctx) ;
449449 if params. is_empty ( ) {
@@ -590,9 +590,9 @@ impl CodeGenerator for Module {
590590 }
591591 } ;
592592
593- if !ctx. options ( ) . enable_cxx_namespaces
594- || ( self . is_inline ( )
595- && !ctx. options ( ) . conservative_inline_namespaces )
593+ if !ctx. options ( ) . enable_cxx_namespaces ||
594+ ( self . is_inline ( ) &&
595+ !ctx. options ( ) . conservative_inline_namespaces )
596596 {
597597 codegen_self ( result, & mut false ) ;
598598 return ;
@@ -836,19 +836,19 @@ impl CodeGenerator for Type {
836836 debug_assert ! ( item. is_enabled_for_codegen( ctx) ) ;
837837
838838 match * self . kind ( ) {
839- TypeKind :: Void
840- | TypeKind :: NullPtr
841- | TypeKind :: Int ( ..)
842- | TypeKind :: Float ( ..)
843- | TypeKind :: Complex ( ..)
844- | TypeKind :: Array ( ..)
845- | TypeKind :: Vector ( ..)
846- | TypeKind :: Pointer ( ..)
847- | TypeKind :: Reference ( ..)
848- | TypeKind :: Function ( ..)
849- | TypeKind :: ResolvedTypeRef ( ..)
850- | TypeKind :: Opaque
851- | TypeKind :: TypeParam => {
839+ TypeKind :: Void |
840+ TypeKind :: NullPtr |
841+ TypeKind :: Int ( ..) |
842+ TypeKind :: Float ( ..) |
843+ TypeKind :: Complex ( ..) |
844+ TypeKind :: Array ( ..) |
845+ TypeKind :: Vector ( ..) |
846+ TypeKind :: Pointer ( ..) |
847+ TypeKind :: Reference ( ..) |
848+ TypeKind :: Function ( ..) |
849+ TypeKind :: ResolvedTypeRef ( ..) |
850+ TypeKind :: Opaque |
851+ TypeKind :: TypeParam => {
852852 // These items don't need code generation, they only need to be
853853 // converted to rust types in fields, arguments, and such.
854854 // NOTE(emilio): If you add to this list, make sure to also add
@@ -1004,11 +1004,11 @@ impl CodeGenerator for Type {
10041004
10051005 // We prefer using `pub use` over `pub type` because of:
10061006 // https://github.com/rust-lang/rust/issues/26264
1007- if matches ! ( inner_rust_type, syn:: Type :: Path ( _) )
1008- && outer_params. is_empty ( )
1009- && !is_opaque
1010- && alias_style == AliasVariation :: TypeAlias
1011- && inner_item. expect_type ( ) . canonical_type ( ctx) . is_enum ( )
1007+ if matches ! ( inner_rust_type, syn:: Type :: Path ( _) ) &&
1008+ outer_params. is_empty ( ) &&
1009+ !is_opaque &&
1010+ alias_style == AliasVariation :: TypeAlias &&
1011+ inner_item. expect_type ( ) . canonical_type ( ctx) . is_enum ( )
10121012 {
10131013 tokens. append_all ( quote ! {
10141014 pub use
@@ -1185,9 +1185,9 @@ impl CodeGenerator for Vtable<'_> {
11851185 // For now, we will only generate vtables for classes that:
11861186 // - do not inherit from others (compilers merge VTable from primary parent class).
11871187 // - do not contain a virtual destructor (requires ordering; platforms generate different vtables).
1188- if ctx. options ( ) . vtable_generation
1189- && self . comp_info . base_members ( ) . is_empty ( )
1190- && self . comp_info . destructor ( ) . is_none ( )
1188+ if ctx. options ( ) . vtable_generation &&
1189+ self . comp_info . base_members ( ) . is_empty ( ) &&
1190+ self . comp_info . destructor ( ) . is_none ( )
11911191 {
11921192 let class_ident = ctx. rust_ident ( self . item_id . canonical_name ( ctx) ) ;
11931193
@@ -2367,10 +2367,10 @@ impl CodeGenerator for CompInfo {
23672367
23682368 // if a type has both a "packed" attribute and an "align(N)" attribute, then check if the
23692369 // "packed" attr is redundant, and do not include it if so.
2370- if packed
2371- && !is_opaque
2372- && !( explicit_align. is_some ( )
2373- && self . already_packed ( ctx) . unwrap_or ( false ) )
2370+ if packed &&
2371+ !is_opaque &&
2372+ !( explicit_align. is_some ( ) &&
2373+ self . already_packed ( ctx) . unwrap_or ( false ) )
23742374 {
23752375 let n = layout. map_or ( 1 , |l| l. align ) ;
23762376 let packed_repr = if n == 1 {
@@ -2410,32 +2410,32 @@ impl CodeGenerator for CompInfo {
24102410
24112411 let derivable_traits = derives_of_item ( item, ctx, packed) ;
24122412 if !derivable_traits. contains ( DerivableTraits :: DEBUG ) {
2413- needs_debug_impl = ctx. options ( ) . derive_debug
2414- && ctx. options ( ) . impl_debug
2415- && !ctx. no_debug_by_name ( item)
2416- && !item. annotations ( ) . disallow_debug ( ) ;
2413+ needs_debug_impl = ctx. options ( ) . derive_debug &&
2414+ ctx. options ( ) . impl_debug &&
2415+ !ctx. no_debug_by_name ( item) &&
2416+ !item. annotations ( ) . disallow_debug ( ) ;
24172417 }
24182418
24192419 if !derivable_traits. contains ( DerivableTraits :: DEFAULT ) {
2420- needs_default_impl = ctx. options ( ) . derive_default
2421- && !self . is_forward_declaration ( )
2422- && !ctx. no_default_by_name ( item)
2423- && !item. annotations ( ) . disallow_default ( ) ;
2420+ needs_default_impl = ctx. options ( ) . derive_default &&
2421+ !self . is_forward_declaration ( ) &&
2422+ !ctx. no_default_by_name ( item) &&
2423+ !item. annotations ( ) . disallow_default ( ) ;
24242424 }
24252425
24262426 let all_template_params = item. all_template_params ( ctx) ;
24272427
2428- if derivable_traits. contains ( DerivableTraits :: COPY )
2429- && !derivable_traits. contains ( DerivableTraits :: CLONE )
2428+ if derivable_traits. contains ( DerivableTraits :: COPY ) &&
2429+ !derivable_traits. contains ( DerivableTraits :: CLONE )
24302430 {
24312431 needs_clone_impl = true ;
24322432 }
24332433
24342434 if !derivable_traits. contains ( DerivableTraits :: PARTIAL_EQ ) {
2435- needs_partialeq_impl = ctx. options ( ) . derive_partialeq
2436- && ctx. options ( ) . impl_partialeq
2437- && ctx. lookup_can_derive_partialeq_or_partialord ( item. id ( ) )
2438- == CanDerive :: Manually ;
2435+ needs_partialeq_impl = ctx. options ( ) . derive_partialeq &&
2436+ ctx. options ( ) . impl_partialeq &&
2437+ ctx. lookup_can_derive_partialeq_or_partialord ( item. id ( ) ) ==
2438+ CanDerive :: Manually ;
24392439 }
24402440
24412441 let mut derives: Vec < _ > = derivable_traits. into ( ) ;
@@ -2617,8 +2617,8 @@ impl CodeGenerator for CompInfo {
26172617 . collect ( )
26182618 } ;
26192619
2620- let uninit_decl = if check_field_offset. is_empty ( )
2621- || compile_time
2620+ let uninit_decl = if check_field_offset. is_empty ( ) ||
2621+ compile_time
26222622 {
26232623 None
26242624 } else {
@@ -2954,11 +2954,11 @@ impl Method {
29542954 let cc = & ctx. options( ) . codegen_config;
29552955 match self . kind( ) {
29562956 MethodKind :: Constructor => cc. constructors( ) ,
2957- MethodKind :: Destructor
2958- | MethodKind :: VirtualDestructor { .. } => cc. destructors( ) ,
2959- MethodKind :: Static
2960- | MethodKind :: Normal
2961- | MethodKind :: Virtual { .. } => cc. methods( ) ,
2957+ MethodKind :: Destructor |
2958+ MethodKind :: VirtualDestructor { .. } => cc. destructors( ) ,
2959+ MethodKind :: Static |
2960+ MethodKind :: Normal |
2961+ MethodKind :: Virtual { .. } => cc. methods( ) ,
29622962 }
29632963 } ) ;
29642964
@@ -3459,8 +3459,8 @@ impl EnumBuilder {
34593459 }
34603460 variants
34613461 }
3462- EnumBuilderKind :: Consts { .. }
3463- | EnumBuilderKind :: ModuleConsts { .. } => {
3462+ EnumBuilderKind :: Consts { .. } |
3463+ EnumBuilderKind :: ModuleConsts { .. } => {
34643464 let mut variants = vec ! [ ] ;
34653465
34663466 for v in self . enum_variants {
@@ -3585,8 +3585,8 @@ impl CodeGenerator for Enum {
35853585 let repr_translated;
35863586 let repr = match self . repr ( ) . map ( |repr| ctx. resolve_type ( repr) ) {
35873587 Some ( repr)
3588- if !ctx. options ( ) . translate_enum_integer_types
3589- && !variation. is_rust ( ) =>
3588+ if !ctx. options ( ) . translate_enum_integer_types &&
3589+ !variation. is_rust ( ) =>
35903590 {
35913591 repr
35923592 }
@@ -3657,10 +3657,10 @@ impl CodeGenerator for Enum {
36573657 // Clone/Eq/PartialEq/Hash, even if we don't generate those by
36583658 // default.
36593659 derives. insert (
3660- DerivableTraits :: CLONE
3661- | DerivableTraits :: HASH
3662- | DerivableTraits :: PARTIAL_EQ
3663- | DerivableTraits :: EQ ,
3660+ DerivableTraits :: CLONE |
3661+ DerivableTraits :: HASH |
3662+ DerivableTraits :: PARTIAL_EQ |
3663+ DerivableTraits :: EQ ,
36643664 ) ;
36653665 let mut derives: Vec < _ > = derives. into ( ) ;
36663666 for derive in item. annotations ( ) . derives ( ) {
@@ -3801,8 +3801,8 @@ impl CodeGenerator for Enum {
38013801 Entry :: Occupied ( ref entry) => {
38023802 if variation. is_rust ( ) {
38033803 let variant_name = ctx. rust_mangle ( variant. name ( ) ) ;
3804- let mangled_name = if is_toplevel
3805- || enum_ty. name ( ) . is_some ( )
3804+ let mangled_name = if is_toplevel ||
3805+ enum_ty. name ( ) . is_some ( )
38063806 {
38073807 variant_name
38083808 } else {
@@ -3861,8 +3861,8 @@ impl CodeGenerator for Enum {
38613861 // If it's an unnamed enum, or constification is enforced,
38623862 // we also generate a constant so it can be properly
38633863 // accessed.
3864- if ( variation. is_rust ( ) && enum_ty. name ( ) . is_none ( ) )
3865- || variant. force_constification ( )
3864+ if ( variation. is_rust ( ) && enum_ty. name ( ) . is_none ( ) ) ||
3865+ variant. force_constification ( )
38663866 {
38673867 let mangled_name = if is_toplevel {
38683868 variant_name. clone ( )
@@ -4305,17 +4305,16 @@ impl TryToRustTy for Type {
43054305 inst. try_to_rust_ty ( ctx, item)
43064306 }
43074307 TypeKind :: ResolvedTypeRef ( inner) => inner. try_to_rust_ty ( ctx, & ( ) ) ,
4308- TypeKind :: TemplateAlias ( ..)
4309- | TypeKind :: Alias ( ..)
4310- | TypeKind :: BlockPointer ( ..) => {
4308+ TypeKind :: TemplateAlias ( ..) |
4309+ TypeKind :: Alias ( ..) |
4310+ TypeKind :: BlockPointer ( ..) => {
43114311 if self . is_block_pointer ( ) && !ctx. options ( ) . generate_block {
43124312 let void = c_void ( ctx) ;
43134313 return Ok ( void. to_ptr ( /* is_const = */ false ) ) ;
43144314 }
43154315
4316- if item. is_opaque ( ctx, & ( ) )
4317- && item
4318- . used_template_params ( ctx)
4316+ if item. is_opaque ( ctx, & ( ) ) &&
4317+ item. used_template_params ( ctx)
43194318 . into_iter ( )
43204319 . any ( |param| param. is_template_param ( ctx, & ( ) ) )
43214320 {
@@ -4331,8 +4330,8 @@ impl TryToRustTy for Type {
43314330 }
43324331 TypeKind :: Comp ( ref info) => {
43334332 let template_params = item. all_template_params ( ctx) ;
4334- if info. has_non_type_template_params ( )
4335- || ( item. is_opaque ( ctx, & ( ) ) && !template_params. is_empty ( ) )
4333+ if info. has_non_type_template_params ( ) ||
4334+ ( item. is_opaque ( ctx, & ( ) ) && !template_params. is_empty ( ) )
43364335 {
43374336 return self . try_to_opaque ( ctx, item) ;
43384337 }
@@ -4372,8 +4371,8 @@ impl TryToRustTy for Type {
43724371 if inner_ty. canonical_type ( ctx) . is_function ( ) || is_objc_pointer
43734372 {
43744373 Ok ( ty)
4375- } else if ctx. options ( ) . generate_cxx_nonnull_references
4376- && matches ! ( self . kind( ) , TypeKind :: Reference ( _) )
4374+ } else if ctx. options ( ) . generate_cxx_nonnull_references &&
4375+ matches ! ( self . kind( ) , TypeKind :: Reference ( _) )
43774376 {
43784377 // It's UB to pass null values in place of C++ references
43794378 let prefix = ctx. trait_prefix ( ) ;
@@ -4680,9 +4679,9 @@ impl CodeGenerator for Function {
46804679 } ) ;
46814680 }
46824681
4683- let should_wrap = is_internal
4684- && ctx. options ( ) . wrap_static_fns
4685- && link_name_attr. is_none ( ) ;
4682+ let should_wrap = is_internal &&
4683+ ctx. options ( ) . wrap_static_fns &&
4684+ link_name_attr. is_none ( ) ;
46864685
46874686 if should_wrap {
46884687 let name = canonical_name. clone ( ) + ctx. wrap_static_fns_suffix ( ) ;
@@ -5226,8 +5225,8 @@ pub(crate) mod utils {
52265225 std:: fs:: create_dir_all ( dir) ?;
52275226 }
52285227
5229- let is_cpp = args_are_cpp ( & context. options ( ) . clang_args )
5230- || context
5228+ let is_cpp = args_are_cpp ( & context. options ( ) . clang_args ) ||
5229+ context
52315230 . options ( )
52325231 . input_headers
52335232 . iter ( )
@@ -5325,8 +5324,8 @@ pub(crate) mod utils {
53255324 ctx : & BindgenContext ,
53265325 result : & mut Vec < proc_macro2:: TokenStream > ,
53275326 ) {
5328- if ctx. options ( ) . blocklisted_items . matches ( BITFIELD_UNIT )
5329- || ctx. options ( ) . blocklisted_types . matches ( BITFIELD_UNIT )
5327+ if ctx. options ( ) . blocklisted_items . matches ( BITFIELD_UNIT ) ||
5328+ ctx. options ( ) . blocklisted_types . matches ( BITFIELD_UNIT )
53305329 {
53315330 return ;
53325331 }
0 commit comments