@@ -252,9 +252,9 @@ where
252252 T : Copy + Into < ItemId > ,
253253{
254254 fn can_derive_partialord ( & self , ctx : & BindgenContext ) -> bool {
255- ctx. options ( ) . derive_partialord &&
256- ctx. lookup_can_derive_partialeq_or_partialord ( * self ) ==
257- CanDerive :: Yes
255+ ctx. options ( ) . derive_partialord
256+ && ctx. lookup_can_derive_partialeq_or_partialord ( * self )
257+ == CanDerive :: Yes
258258 }
259259}
260260
@@ -263,9 +263,9 @@ where
263263 T : Copy + Into < ItemId > ,
264264{
265265 fn can_derive_partialeq ( & self , ctx : & BindgenContext ) -> bool {
266- ctx. options ( ) . derive_partialeq &&
267- ctx. lookup_can_derive_partialeq_or_partialord ( * self ) ==
268- CanDerive :: Yes
266+ ctx. options ( ) . derive_partialeq
267+ && ctx. lookup_can_derive_partialeq_or_partialord ( * self )
268+ == CanDerive :: Yes
269269 }
270270}
271271
@@ -274,10 +274,10 @@ where
274274 T : Copy + Into < ItemId > ,
275275{
276276 fn can_derive_eq ( & self , ctx : & BindgenContext ) -> bool {
277- ctx. options ( ) . derive_eq &&
278- ctx. lookup_can_derive_partialeq_or_partialord ( * self ) ==
279- CanDerive :: Yes &&
280- !ctx. lookup_has_float ( * self )
277+ ctx. options ( ) . derive_eq
278+ && ctx. lookup_can_derive_partialeq_or_partialord ( * self )
279+ == CanDerive :: Yes
280+ && !ctx. lookup_has_float ( * self )
281281 }
282282}
283283
@@ -286,10 +286,10 @@ where
286286 T : Copy + Into < ItemId > ,
287287{
288288 fn can_derive_ord ( & self , ctx : & BindgenContext ) -> bool {
289- ctx. options ( ) . derive_ord &&
290- ctx. lookup_can_derive_partialeq_or_partialord ( * self ) ==
291- CanDerive :: Yes &&
292- !ctx. lookup_has_float ( * self )
289+ ctx. options ( ) . derive_ord
290+ && ctx. lookup_can_derive_partialeq_or_partialord ( * self )
291+ == CanDerive :: Yes
292+ && !ctx. lookup_has_float ( * self )
293293 }
294294}
295295
@@ -353,7 +353,7 @@ pub(crate) struct BindgenContext {
353353 /// hard errors while parsing duplicated macros, as well to allow macro
354354 /// expression parsing.
355355 ///
356- /// This needs to be an `std::HashMap` because the `cexpr` API requires it.
356+ /// This needs to be an `std::HashMap` because the [ `cexpr`] API requires it.
357357 parsed_macros : StdHashMap < Vec < u8 > , cexpr:: expr:: EvalResult > ,
358358
359359 /// A map with all include locations.
@@ -702,11 +702,11 @@ If you encounter an error missing from this list, please file an issue or a PR!"
702702 ) {
703703 debug ! ( "BindgenContext::add_item({item:?}, declaration: {declaration:?}, loc: {location:?}" ) ;
704704 debug_assert ! (
705- declaration. is_some( ) ||
706- !item. kind( ) . is_type( ) ||
707- item. kind( ) . expect_type( ) . is_builtin_or_type_param( ) ||
708- item. kind( ) . expect_type( ) . is_opaque( self , & item) ||
709- item. kind( ) . expect_type( ) . is_unresolved_ref( ) ,
705+ declaration. is_some( )
706+ || !item. kind( ) . is_type( )
707+ || item. kind( ) . expect_type( ) . is_builtin_or_type_param( )
708+ || item. kind( ) . expect_type( ) . is_opaque( self , & item)
709+ || item. kind( ) . expect_type( ) . is_unresolved_ref( ) ,
710710 "Adding a type without declaration?"
711711 ) ;
712712
@@ -1067,10 +1067,10 @@ If you encounter an error missing from this list, please file an issue or a PR!"
10671067 } ;
10681068
10691069 match * ty. kind ( ) {
1070- TypeKind :: Comp ( ..) |
1071- TypeKind :: TemplateAlias ( ..) |
1072- TypeKind :: Enum ( ..) |
1073- TypeKind :: Alias ( ..) => { }
1070+ TypeKind :: Comp ( ..)
1071+ | TypeKind :: TemplateAlias ( ..)
1072+ | TypeKind :: Enum ( ..)
1073+ | TypeKind :: Alias ( ..) => { }
10741074 _ => continue ,
10751075 }
10761076
@@ -1665,9 +1665,9 @@ If you encounter an error missing from this list, please file an issue or a PR!"
16651665
16661666 for child in children. iter ( ) . rev ( ) {
16671667 match child. kind ( ) {
1668- clang_sys:: CXCursor_TypeRef |
1669- clang_sys:: CXCursor_TypedefDecl |
1670- clang_sys:: CXCursor_TypeAliasDecl => {
1668+ clang_sys:: CXCursor_TypeRef
1669+ | clang_sys:: CXCursor_TypedefDecl
1670+ | clang_sys:: CXCursor_TypeAliasDecl => {
16711671 // The `with_id` ID will potentially end up unused if we give up
16721672 // on this type (for example, because it has const value
16731673 // template args), so if we pass `with_id` as the parent, it is
@@ -1691,8 +1691,8 @@ If you encounter an error missing from this list, please file an issue or a PR!"
16911691 child,
16921692 ) ?;
16931693
1694- if num_expected_template_args == 0 ||
1695- child. has_at_least_num_children (
1694+ if num_expected_template_args == 0
1695+ || child. has_at_least_num_children (
16961696 num_expected_template_args,
16971697 )
16981698 {
@@ -1864,8 +1864,8 @@ If you encounter an error missing from this list, please file an issue or a PR!"
18641864 // * we have already parsed and resolved this type, and
18651865 // there's nothing left to do.
18661866 if let Some ( location) = location {
1867- if decl. cursor ( ) . is_template_like ( ) &&
1868- * ty != decl. cursor ( ) . cur_type ( )
1867+ if decl. cursor ( ) . is_template_like ( )
1868+ && * ty != decl. cursor ( ) . cur_type ( )
18691869 {
18701870 // For specialized type aliases, there's no way to get the
18711871 // template parameters as of this writing (for a struct
@@ -1877,10 +1877,10 @@ If you encounter an error missing from this list, please file an issue or a PR!"
18771877 // exposed.
18781878 //
18791879 // This is _tricky_, I know :(
1880- if decl. cursor ( ) . kind ( ) ==
1881- CXCursor_TypeAliasTemplateDecl &&
1882- !location. contains_cursor ( CXCursor_TypeRef ) &&
1883- ty. canonical_type ( ) . is_valid_and_exposed ( )
1880+ if decl. cursor ( ) . kind ( )
1881+ == CXCursor_TypeAliasTemplateDecl
1882+ && !location. contains_cursor ( CXCursor_TypeRef )
1883+ && ty. canonical_type ( ) . is_valid_and_exposed ( )
18841884 {
18851885 return None ;
18861886 }
@@ -2129,6 +2129,7 @@ If you encounter an error missing from this list, please file an issue or a PR!"
21292129 }
21302130
21312131 /// Get the currently parsed macros.
2132+ /// This map only contains macros accepted by [`cexpr`]
21322133 pub ( crate ) fn parsed_macros (
21332134 & self ,
21342135 ) -> & StdHashMap < Vec < u8 > , cexpr:: expr:: EvalResult > {
@@ -2376,9 +2377,9 @@ If you encounter an error missing from this list, please file an issue or a PR!"
23762377 /// Is the given type a type from <stdint.h> that corresponds to a Rust primitive type?
23772378 pub ( crate ) fn is_stdint_type ( & self , name : & str ) -> bool {
23782379 match name {
2379- "int8_t" | "uint8_t" | "int16_t" | "uint16_t" | "int32_t" |
2380- "uint32_t" | "int64_t" | "uint64_t" | "uintptr_t" |
2381- "intptr_t" | "ptrdiff_t" => true ,
2380+ "int8_t" | "uint8_t" | "int16_t" | "uint16_t" | "int32_t"
2381+ | "uint32_t" | "int64_t" | "uint64_t" | "uintptr_t"
2382+ | "intptr_t" | "ptrdiff_t" => true ,
23822383 "size_t" | "ssize_t" => self . options . size_t_is_usize ,
23832384 _ => false ,
23842385 }
@@ -2406,11 +2407,11 @@ If you encounter an error missing from this list, please file an issue or a PR!"
24062407 . filter ( |& ( _, item) | {
24072408 // If nothing is explicitly allowlisted, then everything is fair
24082409 // game.
2409- if self . options ( ) . allowlisted_types . is_empty ( ) &&
2410- self . options ( ) . allowlisted_functions . is_empty ( ) &&
2411- self . options ( ) . allowlisted_vars . is_empty ( ) &&
2412- self . options ( ) . allowlisted_files . is_empty ( ) &&
2413- self . options ( ) . allowlisted_items . is_empty ( )
2410+ if self . options ( ) . allowlisted_types . is_empty ( )
2411+ && self . options ( ) . allowlisted_functions . is_empty ( )
2412+ && self . options ( ) . allowlisted_vars . is_empty ( )
2413+ && self . options ( ) . allowlisted_files . is_empty ( )
2414+ && self . options ( ) . allowlisted_items . is_empty ( )
24142415 {
24152416 return true ;
24162417 }
@@ -2463,19 +2464,19 @@ If you encounter an error missing from this list, please file an issue or a PR!"
24632464 // make the #[derive] analysis not be lame.
24642465 if !self . options ( ) . allowlist_recursively {
24652466 match * ty. kind ( ) {
2466- TypeKind :: Void |
2467- TypeKind :: NullPtr |
2468- TypeKind :: Int ( ..) |
2469- TypeKind :: Float ( ..) |
2470- TypeKind :: Complex ( ..) |
2471- TypeKind :: Array ( ..) |
2472- TypeKind :: Vector ( ..) |
2473- TypeKind :: Pointer ( ..) |
2474- TypeKind :: Reference ( ..) |
2475- TypeKind :: Function ( ..) |
2476- TypeKind :: ResolvedTypeRef ( ..) |
2477- TypeKind :: Opaque |
2478- TypeKind :: TypeParam => return true ,
2467+ TypeKind :: Void
2468+ | TypeKind :: NullPtr
2469+ | TypeKind :: Int ( ..)
2470+ | TypeKind :: Float ( ..)
2471+ | TypeKind :: Complex ( ..)
2472+ | TypeKind :: Array ( ..)
2473+ | TypeKind :: Vector ( ..)
2474+ | TypeKind :: Pointer ( ..)
2475+ | TypeKind :: Reference ( ..)
2476+ | TypeKind :: Function ( ..)
2477+ | TypeKind :: ResolvedTypeRef ( ..)
2478+ | TypeKind :: Opaque
2479+ | TypeKind :: TypeParam => return true ,
24792480 _ => { }
24802481 }
24812482 if self . is_stdint_type ( & name) {
@@ -2793,9 +2794,9 @@ If you encounter an error missing from this list, please file an issue or a PR!"
27932794 fn compute_cannot_derive_partialord_partialeq_or_eq ( & mut self ) {
27942795 let _t = self . timer ( "compute_cannot_derive_partialord_partialeq_or_eq" ) ;
27952796 assert ! ( self . cannot_derive_partialeq_or_partialord. is_none( ) ) ;
2796- if self . options . derive_partialord ||
2797- self . options . derive_partialeq ||
2798- self . options . derive_eq
2797+ if self . options . derive_partialord
2798+ || self . options . derive_partialeq
2799+ || self . options . derive_eq
27992800 {
28002801 self . cannot_derive_partialeq_or_partialord =
28012802 Some ( analyze :: < CannotDerive > ( (
@@ -2842,8 +2843,8 @@ If you encounter an error missing from this list, please file an issue or a PR!"
28422843 // derive `Copy` or not.
28432844 let id = id. into ( ) ;
28442845
2845- !self . lookup_has_type_param_in_array ( id) &&
2846- !self . cannot_derive_copy . as_ref ( ) . unwrap ( ) . contains ( & id)
2846+ !self . lookup_has_type_param_in_array ( id)
2847+ && !self . cannot_derive_copy . as_ref ( ) . unwrap ( ) . contains ( & id)
28472848 }
28482849
28492850 /// Compute whether the type has type parameter in array.
@@ -3070,15 +3071,15 @@ impl TemplateParameters for PartialType {
30703071 // Wouldn't it be nice if libclang would reliably give us this
30713072 // information‽
30723073 match self . decl ( ) . kind ( ) {
3073- clang_sys:: CXCursor_ClassTemplate |
3074- clang_sys:: CXCursor_FunctionTemplate |
3075- clang_sys:: CXCursor_TypeAliasTemplateDecl => {
3074+ clang_sys:: CXCursor_ClassTemplate
3075+ | clang_sys:: CXCursor_FunctionTemplate
3076+ | clang_sys:: CXCursor_TypeAliasTemplateDecl => {
30763077 let mut num_params = 0 ;
30773078 self . decl ( ) . visit ( |c| {
30783079 match c. kind ( ) {
3079- clang_sys:: CXCursor_TemplateTypeParameter |
3080- clang_sys:: CXCursor_TemplateTemplateParameter |
3081- clang_sys:: CXCursor_NonTypeTemplateParameter => {
3080+ clang_sys:: CXCursor_TemplateTypeParameter
3081+ | clang_sys:: CXCursor_TemplateTemplateParameter
3082+ | clang_sys:: CXCursor_NonTypeTemplateParameter => {
30823083 num_params += 1 ;
30833084 }
30843085 _ => { }
0 commit comments