@@ -84,13 +84,10 @@ pub(crate) fn blob(layout: Layout) -> syn::Type {
8484 // some things that legitimately are more than 8-byte aligned.
8585 //
8686 // Eventually we should be able to `unwrap` here, but...
87- let ty = match opaque. known_rust_type_for_array ( ) {
88- Some ( ty) => ty,
89- None => {
90- warn ! ( "Found unknown alignment on code generation!" ) ;
91- syn:: parse_quote! { u8 }
92- }
93- } ;
87+ let ty = opaque. known_rust_type_for_array ( ) . unwrap_or_else ( || {
88+ warn ! ( "Found unknown alignment on code generation!" ) ;
89+ syn:: parse_quote! { u8 }
90+ } ) ;
9491
9592 let data_len = opaque. array_size ( ) . unwrap_or ( layout. size ) ;
9693
@@ -245,24 +242,21 @@ pub(crate) mod ast_ty {
245242 ( FloatKind :: Float , false ) => raw_type ( ctx, "c_float" ) ,
246243 ( FloatKind :: Double , false ) => raw_type ( ctx, "c_double" ) ,
247244 ( FloatKind :: LongDouble , _) => {
248- match layout {
249- Some ( layout) => {
250- match layout. size {
251- 4 => syn:: parse_quote! { f32 } ,
252- 8 => syn:: parse_quote! { f64 } ,
253- // TODO(emilio): If rust ever gains f128 we should
254- // use it here and below.
255- _ => super :: integer_type ( layout)
256- . unwrap_or ( syn:: parse_quote! { f64 } ) ,
257- }
258- }
259- None => {
260- debug_assert ! (
261- false ,
262- "How didn't we know the layout for a primitive type?"
263- ) ;
264- syn:: parse_quote! { f64 }
245+ if let Some ( layout) = layout {
246+ match layout. size {
247+ 4 => syn:: parse_quote! { f32 } ,
248+ 8 => syn:: parse_quote! { f64 } ,
249+ // TODO(emilio): If rust ever gains f128 we should
250+ // use it here and below.
251+ _ => super :: integer_type ( layout)
252+ . unwrap_or ( syn:: parse_quote! { f64 } ) ,
265253 }
254+ } else {
255+ debug_assert ! (
256+ false ,
257+ "How didn't we know the layout for a primitive type?"
258+ ) ;
259+ syn:: parse_quote! { f64 }
266260 }
267261 }
268262 ( FloatKind :: Float128 , _) => {
@@ -365,17 +359,14 @@ pub(crate) mod ast_ty {
365359 signature
366360 . argument_types ( )
367361 . iter ( )
368- . map ( |& ( ref name, _ty) | match * name {
369- Some ( ref name) => {
370- let name = ctx. rust_ident ( name) ;
371- quote ! { #name }
372- }
373- None => {
362+ . map ( |& ( ref name, _ty) | {
363+ let name = if let Some ( ref name) = * name {
364+ ctx. rust_ident ( name)
365+ } else {
374366 unnamed_arguments += 1 ;
375- let name =
376- ctx. rust_ident ( format ! ( "arg{unnamed_arguments}" ) ) ;
377- quote ! { #name }
378- }
367+ ctx. rust_ident ( format ! ( "arg{unnamed_arguments}" ) )
368+ } ;
369+ quote ! { #name }
379370 } )
380371 . collect ( )
381372 }
0 commit comments