@@ -1198,10 +1198,7 @@ impl CodeGenerator for Vtable<'_> {
11981198 let function_item = ctx. resolve_item ( m. signature ( ) ) ;
11991199 let function = function_item. expect_function ( ) ;
12001200 let signature_item = ctx. resolve_item ( function. signature ( ) ) ;
1201- let signature = match signature_item. expect_type ( ) . kind ( ) {
1202- TypeKind :: Function ( ref sig) => sig,
1203- _ => panic ! ( "Function signature type mismatch" ) ,
1204- } ;
1201+ let TypeKind :: Function ( ref signature) = signature_item. expect_type ( ) . kind ( ) else { panic ! ( "Function signature type mismatch" ) } ;
12051202
12061203 // FIXME: Is there a canonical name without the class prepended?
12071204 let function_name = function_item. canonical_name ( ctx) ;
@@ -1943,16 +1940,14 @@ impl<'a> FieldCodegen<'a> for Bitfield {
19431940 let bitfield_ty_layout = bitfield_ty
19441941 . layout ( ctx)
19451942 . expect ( "Bitfield without layout? Gah!" ) ;
1946- let bitfield_int_ty = match helpers :: integer_type ( bitfield_ty_layout ) {
1947- Some ( int_ty) => {
1943+ let bitfield_int_ty =
1944+ if let Some ( int_ty) = helpers :: integer_type ( bitfield_ty_layout ) {
19481945 * bitfield_representable_as_int = true ;
19491946 int_ty
1950- }
1951- None => {
1947+ } else {
19521948 * bitfield_representable_as_int = false ;
19531949 return ;
1954- }
1955- } ;
1950+ } ;
19561951
19571952 let bitfield_ty =
19581953 bitfield_ty. to_rust_ty_or_opaque ( ctx, bitfield_ty_item) ;
@@ -2974,20 +2969,18 @@ impl Method {
29742969 }
29752970 let function = function_item. expect_function ( ) ;
29762971 let times_seen = function. codegen ( ctx, result, function_item) ;
2977- let times_seen = match times_seen {
2978- Some ( seen) => seen,
2979- None => return ,
2980- } ;
2972+ let Some ( times_seen) = times_seen else { return } ;
29812973 let signature_item = ctx. resolve_item ( function. signature ( ) ) ;
29822974 let mut name = match self . kind ( ) {
29832975 MethodKind :: Constructor => "new" . into ( ) ,
29842976 MethodKind :: Destructor => "destruct" . into ( ) ,
29852977 _ => function. name ( ) . to_owned ( ) ,
29862978 } ;
29872979
2988- let signature = match * signature_item. expect_type ( ) . kind ( ) {
2989- TypeKind :: Function ( ref sig) => sig,
2990- _ => panic ! ( "How in the world?" ) ,
2980+ let TypeKind :: Function ( ref signature) =
2981+ * signature_item. expect_type ( ) . kind ( )
2982+ else {
2983+ panic ! ( "How in the world?" )
29912984 } ;
29922985
29932986 let supported_abi = signature. abi ( ctx, Some ( & * name) ) . is_ok ( ) ;
@@ -3564,18 +3557,17 @@ impl CodeGenerator for Enum {
35643557 // * the representation couldn't be determined from the C source
35653558 // * it was explicitly requested as a bindgen option
35663559
3567- let kind = match repr {
3568- Some ( repr ) => match * repr. canonical_type ( ctx) . kind ( ) {
3560+ let kind = if let Some ( repr ) = repr {
3561+ match * repr. canonical_type ( ctx) . kind ( ) {
35693562 TypeKind :: Int ( int_kind) => int_kind,
35703563 _ => panic ! ( "Unexpected type as enum repr" ) ,
3571- } ,
3572- None => {
3573- warn ! (
3574- "Guessing type of enum! Forward declarations of enums \
3575- shouldn't be legal!"
3576- ) ;
3577- IntKind :: Int
35783564 }
3565+ } else {
3566+ warn ! (
3567+ "Guessing type of enum! Forward declarations of enums \
3568+ shouldn't be legal!"
3569+ ) ;
3570+ IntKind :: Int
35793571 } ;
35803572
35813573 let signed = kind. is_signed ( ) ;
@@ -4488,9 +4480,8 @@ impl CodeGenerator for Function {
44884480
44894481 let signature_item = ctx. resolve_item ( self . signature ( ) ) ;
44904482 let signature = signature_item. kind ( ) . expect_type ( ) . canonical_type ( ctx) ;
4491- let signature = match * signature. kind ( ) {
4492- TypeKind :: Function ( ref sig) => sig,
4493- _ => panic ! ( "Signature kind is not a Function: {signature:?}" ) ,
4483+ let TypeKind :: Function ( ref signature) = * signature. kind ( ) else {
4484+ panic ! ( "Signature kind is not a Function: {signature:?}" )
44944485 } ;
44954486
44964487 if is_internal {
@@ -4966,9 +4957,8 @@ impl CodeGenerator for ObjCInterface {
49664957 . expect_type ( )
49674958 . kind ( ) ;
49684959
4969- let parent = match parent {
4970- TypeKind :: ObjCInterface ( ref parent) => parent,
4971- _ => break ,
4960+ let TypeKind :: ObjCInterface ( parent) = parent else {
4961+ break ;
49724962 } ;
49734963 parent_class = parent. parent_class ;
49744964
@@ -5683,12 +5673,11 @@ pub(crate) mod utils {
56835673 . map ( |( name, ty) | {
56845674 let arg_ty = fnsig_argument_type ( ctx, ty) ;
56855675
5686- let arg_name = match * name {
5687- Some ( ref name) => ctx. rust_mangle ( name) . into_owned ( ) ,
5688- None => {
5689- unnamed_arguments += 1 ;
5690- format ! ( "arg{unnamed_arguments}" )
5691- }
5676+ let arg_name = if let Some ( ref name) = * name {
5677+ ctx. rust_mangle ( name) . into_owned ( )
5678+ } else {
5679+ unnamed_arguments += 1 ;
5680+ format ! ( "arg{unnamed_arguments}" )
56925681 } ;
56935682
56945683 assert ! ( !arg_name. is_empty( ) ) ;
@@ -5727,12 +5716,11 @@ pub(crate) mod utils {
57275716 . argument_types ( )
57285717 . iter ( )
57295718 . map ( |& ( ref name, _ty) | {
5730- let arg_name = match * name {
5731- Some ( ref name) => ctx. rust_mangle ( name) . into_owned ( ) ,
5732- None => {
5733- unnamed_arguments += 1 ;
5734- format ! ( "arg{unnamed_arguments}" )
5735- }
5719+ let arg_name = if let Some ( ref name) = * name {
5720+ ctx. rust_mangle ( name) . into_owned ( )
5721+ } else {
5722+ unnamed_arguments += 1 ;
5723+ format ! ( "arg{unnamed_arguments}" )
57365724 } ;
57375725
57385726 assert ! ( !arg_name. is_empty( ) ) ;
0 commit comments