From: Manos Pitsidianakis Date: Fri, 4 Jul 2025 10:26:57 +0000 (+0300) Subject: rust/qemu-api-macros: normalize TryInto output X-Git-Tag: v10.1.0-rc0~21^2~73 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c3a08c8dcbe568d9e7f8a66d300a668bcb8673c0;p=thirdparty%2Fqemu.git rust/qemu-api-macros: normalize TryInto output Remove extraneous `;` and add missing trailing comma to TryInto derive macro to match rustfmt style. We will add a test in the followup commit and we would like the inlined output in the test body to be properly formatted as well. No functional changes intended. Signed-off-by: Manos Pitsidianakis Reviewed-by: Zhao Liu Link: https://lore.kernel.org/r/20250704-rust_add_derive_macro_unit_tests-v1-1-ebd47fa7f78f@linaro.org Signed-off-by: Paolo Bonzini --- diff --git a/rust/qemu-api-macros/src/lib.rs b/rust/qemu-api-macros/src/lib.rs index 2cb79c799a..5bbf8c6127 100644 --- a/rust/qemu-api-macros/src/lib.rs +++ b/rust/qemu-api-macros/src/lib.rs @@ -199,7 +199,7 @@ fn derive_tryinto_body( let discriminants: Vec<&Ident> = variants.iter().map(|f| &f.ident).collect(); Ok(quote! { - #(const #discriminants: #repr = #name::#discriminants as #repr;)*; + #(const #discriminants: #repr = #name::#discriminants as #repr;)* match value { #(#discriminants => core::result::Result::Ok(#name::#discriminants),)* _ => core::result::Result::Err(value), @@ -227,7 +227,7 @@ fn derive_tryinto_or_error(input: DeriveInput) -> Result x, - Err(_) => panic!(#errmsg) + Err(_) => panic!(#errmsg), } } }