msg_socket: allow Enum with no variant filed types

This is to allow the Enum which doesn't have filed type for all its variants
to derive the MsgOnSocket.

BUG=None
TEST=cargo test -p msg_socket

Change-Id: Iab9edda777f42e25af40e4ec0e5870401c17572b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2143572
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chuanxiao Dong <chuanxiao.dong@intel.corp-partner.google.com>
This commit is contained in:
Chuanxiao Dong 2020-04-09 14:04:20 +08:00 committed by Commit Bot
parent 220eaf5d2d
commit 1d6af551b9

View file

@ -190,6 +190,11 @@ fn define_uses_fd_for_enum(de: &DataEnum) -> TokenStream {
variant_field_types.push(variant_field_ty); variant_field_types.push(variant_field_ty);
} }
} }
if variant_field_types.len() == 0 {
return quote!();
}
quote! { quote! {
fn uses_fd() -> bool { fn uses_fd() -> bool {
#(<#variant_field_types>::uses_fd())||* #(<#variant_field_types>::uses_fd())||*