From nobody Sat Nov 15 22:25:03 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1746176499; cv=none; d=zohomail.com; s=zohoarc; b=FGxEh716HPAkeNOANEeXKNhW6B0WBooZmOB9BGLOBdp1HHE5j5J/1dvSSlZ0xZ79SaxVY2hlKSMLFL1QGVd57X1XTS0GxMFAN6pHoTxWDh1Zm4+64B19HlNwGv4CzJhC62z55AefZvUnzaQotDSQJsU6FsafQnxb0Flw1u7Xz6U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1746176499; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=SVdtL49sOwGbUcvuljWA7jXxsATBmy/UlSJlZk7Ssrs=; b=SsWSDp06ui/ggOyeGOVXgF9D677dQNgReO4RAQEFX9FdxYVidxpFB8lB0vla+/S83ncMknXaXjzUf/A8yaOAhkbsNa1/EB0zW++9wARm5s1/c/1UJyPlFoIuujG5n6etLlWcQf4B35+4YvGk15V5Dw45AbsJLS4jSJT/PsvIKAM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1746176499236673.767764769964; Fri, 2 May 2025 02:01:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uAmGO-0006kZ-0e; Fri, 02 May 2025 05:00:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uAmGM-0006hR-AP for qemu-devel@nongnu.org; Fri, 02 May 2025 05:00:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uAmGK-0004xx-Ea for qemu-devel@nongnu.org; Fri, 02 May 2025 05:00:54 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-120-ssaLqLv5NmaqIfMLUfWMMA-1; Fri, 02 May 2025 05:00:50 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3a064c45f03so758864f8f.0 for ; Fri, 02 May 2025 02:00:50 -0700 (PDT) Received: from [192.168.10.48] ([151.95.54.106]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-441b2b20a65sm82883545e9.32.2025.05.02.02.00.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 May 2025 02:00:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1746176451; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SVdtL49sOwGbUcvuljWA7jXxsATBmy/UlSJlZk7Ssrs=; b=VInrMzdNNhlowvN12iPnr6jIGXHWhQo4Hdqx9ki1prxakvl/bYZ9Hkqz9sgWmywtk+dGRj 9cxC3XPsmiCk9Hp2hDbvuBpNAaqphz5ilndf06rlDTR4Pr1m4WaAGiU3vsWzo5AhBF8WgI 4j3VTa6JixzxRjOVhupPL3minGGIVj0= X-MC-Unique: ssaLqLv5NmaqIfMLUfWMMA-1 X-Mimecast-MFC-AGG-ID: ssaLqLv5NmaqIfMLUfWMMA_1746176449 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746176448; x=1746781248; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SVdtL49sOwGbUcvuljWA7jXxsATBmy/UlSJlZk7Ssrs=; b=emJ80SQB2SVUdrF7sj9akZszppTgUvWSP1iuEkw+OipcoO4xv2l9UKsJeQwtKanVvk a1BuHNZ8M/a7hD4Qakz0cSEa2ZMtlmAzK+RKHCLU0xkX2O3u9VTExraQcwI0Td7s+WaS WEz6Qgu47ijmIExRFKt8MgZ1wZ5kA4zz4U5UHRLJvzvL7fv4jQGm/8mAsXfHPAckd598 XcMf+sVYPbAc4S5VkXBSySX4MYczDaEddSYo1vAOMCfjz4UDL5TdpqTXYeSHjKoxgn6+ F2Fn0Zh9OawupuJcW5CoaI8L5TAGEMdXTq6IVJtV4tEOsrYEYQnywnsowWcyFpfR9Nbv E3RQ== X-Gm-Message-State: AOJu0YzGOQK0RRwVxUiFCIjG5UXtZl2RwJwv7PDX/3Hy3HryIYcuDAcQ hibtOMA/n7GgcI6qrIRlB8HcLw0nXz5dI7fty7aRG0iHqvJXtFAkV00PhC2G9AZcVPmJ+eUDA5a n8eo+TtB4bl0Dh0LrbScpAuR5Vzw2lwcb9SE6nepRodZlhx0vidBo1955ywIqDxBQkuoleNrM38 3TiavaZUa5Jqk+z31jcyXnF+MMf65fxqRXci8I X-Gm-Gg: ASbGncvqi+Yo2hVX6hgu6EhrKc7eLyBEVBJEsrGnm9Wc5Ghj4GzM5ogGrxQRVbFagzF 4paVAMSYPBC70+tmXB9PdNJqyB3G3b8gxdLKgOTW2PsRm8QOfiv3lldFdoU+nzMn5I6CveiVhlp G9LihO8ypAdIGbqyO1ljuBSjt0v7unesYht11Q7X0Zf5o6AgAneuRJz4zyf8JkynNGuwaPHYJND HaLcEc0hktBHaVq0O4HUG7DD/MHhsV3+Biv1M3VPnWkwA+TW8pXmwu3Ho781rRXMlufYdVwOPCv vvLp/PCCGR1nnUA= X-Received: by 2002:a05:6000:40c9:b0:391:b93:c971 with SMTP id ffacd0b85a97d-3a094058683mr4165664f8f.20.1746176448016; Fri, 02 May 2025 02:00:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHm25j0Nsvu5M2HoQeEQs5LoUFhkGNDq1rFjU+ziHrFWu39A0tvrGRqLp+V/+6SpRaTrYubsQ== X-Received: by 2002:a05:6000:40c9:b0:391:b93:c971 with SMTP id ffacd0b85a97d-3a094058683mr4165631f8f.20.1746176447641; Fri, 02 May 2025 02:00:47 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: qemu-rust@nongnu.org, zhao1.liu@intel.com Subject: [PATCH 1/2] rust: vmstate: support varray for vmstate_clock! Date: Fri, 2 May 2025 11:00:43 +0200 Message-ID: <20250502090044.85557-2-pbonzini@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250502090044.85557-1-pbonzini@redhat.com> References: <20250502090044.85557-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.644, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1746176499748019000 Content-Type: text/plain; charset="utf-8" Make vmstate_struct and vmstate_clock more similar; they are basically the same thing, except for the clock case having a built-in VMStateDescription. Signed-off-by: Paolo Bonzini --- rust/qemu-api/src/vmstate.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/rust/qemu-api/src/vmstate.rs b/rust/qemu-api/src/vmstate.rs index 7d9f3a2ca6f..98152e5964d 100644 --- a/rust/qemu-api/src/vmstate.rs +++ b/rust/qemu-api/src/vmstate.rs @@ -506,7 +506,7 @@ macro_rules! vmstate_struct { #[doc(alias =3D "VMSTATE_CLOCK")] #[macro_export] macro_rules! vmstate_clock { - ($struct_name:ty, $field_name:ident) =3D> {{ + ($struct_name:ty, $field_name:ident $([0 .. $num:ident $(* $factor:exp= r)?])?) =3D> {{ $crate::bindings::VMStateField { name: ::core::concat!(::core::stringify!($field_name), "\0") .as_bytes() @@ -515,7 +515,7 @@ macro_rules! vmstate_clock { $crate::assert_field_type!( $struct_name, $field_name, - $crate::qom::Owned<$crate::qdev::Clock> + $crate::qom::Owned<$crate::qdev::Clock> $(, num =3D $n= um)? ); $crate::offset_of!($struct_name, $field_name) }, @@ -526,7 +526,14 @@ macro_rules! vmstate_clock { ), vmsd: unsafe { ::core::ptr::addr_of!($crate::bindings::vmstate= _clock) }, ..$crate::zeroable::Zeroable::ZERO - } + } $(.with_varray_flag_unchecked( + $crate::call_func_with_field!( + $crate::vmstate::vmstate_varray_flag, + $struct_name, + $num + ) + ) + $(.with_varray_multiply($factor))?)? }}; } =20 --=20 2.49.0 From nobody Sat Nov 15 22:25:03 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1746176471; cv=none; d=zohomail.com; s=zohoarc; b=dZzliEFml4firUTzLWOmKuD90N9v1nbBfpxEPAYUTOw170/c41TL8qeqD9LWok7a0sgrVzNSOSwpikyZoXDVELiCHllm1ePbuVB4ylUWiP7Dwai6oD+OL+uHjikPmT+BoiJ4RGiiOE6n3wcw4ZCNU7onDeGpSPHS2xNmt45tjBw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1746176471; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=LqeniZgXmPTdrTI+xq1XQTwnSc7B7nOzlTpRU2OjaDw=; b=IbyjGrsM7GkTOzos8+XOS7jmxxYB2rg1DKfixRLnSk0BFG72k8nMxzbBKS9NfszccO/7jnIz89Of2GiDcVr/FKI79qYej4qAVhqDZtm34Ja+/Suy0w6SYQd7ymzB4i7UKNpAq/ptjgc/5o31oYkrmv9nAdv47OyEqt6/X58pn/0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1746176471657131.70021753514754; Fri, 2 May 2025 02:01:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uAmGP-0006nx-Vr; Fri, 02 May 2025 05:00:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uAmGO-0006l8-Hw for qemu-devel@nongnu.org; Fri, 02 May 2025 05:00:56 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uAmGM-0004yO-RM for qemu-devel@nongnu.org; Fri, 02 May 2025 05:00:56 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-665-eLF1UTk5NZ2AQ0LcMQnDKg-1; Fri, 02 May 2025 05:00:52 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-43cf3168b87so6941765e9.2 for ; Fri, 02 May 2025 02:00:52 -0700 (PDT) Received: from [192.168.10.48] ([151.95.54.106]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-441b8a2873csm37255055e9.30.2025.05.02.02.00.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 May 2025 02:00:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1746176454; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LqeniZgXmPTdrTI+xq1XQTwnSc7B7nOzlTpRU2OjaDw=; b=TY3GMfrlEc1weiUR5Q347Z5Ws44AsCuXbx6P7gxdi/lbKb8BgyhB8xdFYLNxU8N6lK2RlC Lh48ffL3hAr7uMxtd3gKBj3AkUvX1jerIhzar6LKL9CTN9AKEp2S2kADagAmnnjravoD8y LcHyEbCp2S6Glqp4i6vxDSkSvxqFe7k= X-MC-Unique: eLF1UTk5NZ2AQ0LcMQnDKg-1 X-Mimecast-MFC-AGG-ID: eLF1UTk5NZ2AQ0LcMQnDKg_1746176451 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746176451; x=1746781251; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LqeniZgXmPTdrTI+xq1XQTwnSc7B7nOzlTpRU2OjaDw=; b=XzEnv8ei14F6LyltrHmJrUMzdKVKnC8j1GTh+RKy1Pio53FJy97SJTIh2EbhYZpE6N Xv26GmXKwifVVZVo3OZGLqXNQBpy0CTuujQBDPSRx6K5fGnSozy9eAiOUrWlvu6m6i0v 16Ios+JidpEcTe5qNjKMDUyWS2v5uLETA/B5Xyt13NqRvgZezQCAOAdEOBPe/5t3jyaq eSNYyxVBTnH0HSDaojHMj6kRPpNR5TnQFxLZrWTlNHEs46SuEb6p6h5LXY0YimtjeeS1 qn1ub0G68HjM/4wCO9sn/12SXB7v5e9MjwZ1FP9+G8M96G0EIFzkQlk9ofuTtxGrK8pD WNiQ== X-Gm-Message-State: AOJu0YwkEktpb+VRiYlteh4+izOC+QSqGJSqVyXQPrA5HGUdxXpTG6pq 2otYfkrRiPyyCkEO33dV0CzGvCPeURaaHvBjwAOkHTURJWOH5YFLqwZmdAKv/3IEtWPqdxXI1Yu 9bLFuzbtDXs714Sb6KpUL51dwHTuDh/e4I6SFeyeinC4SZxaA+ZEsfG4wnMpB5NGgDIiB851kpt LSybwqUR3lGYYC5a3Iyfbra7aflvntcataL0k0 X-Gm-Gg: ASbGnct5aJoGEodrNuTQlVcscksI+aaneanURfOgEKgVV9ETphXjNM+iMUYWUeNNjV+ P0AS3iDpwX6UPr4AOYP+1Pc9ItiSGlt5hxH7PjgLTGkIUDLA5dqF/IHD7Vz0ZF0KY7MIEeAHjcF I/yRz9wMyh7exly46agYo0DBiQpV8sLVEqDdyfWpoFhCwnP6Mt1DMopiznkZIegGyA/8JGKUrf4 ajqe5TyaSlCiVnQjfoWTK8EG2zLPf1BUQCy85S6pzSwpMfd+wVjKv3Y3e8yCPBqEbhB/GBrYGVM /NlTIxdcWcA2Pww= X-Received: by 2002:a05:600c:350e:b0:43c:e478:889 with SMTP id 5b1f17b1804b1-441bbe2c815mr15376105e9.0.1746176451016; Fri, 02 May 2025 02:00:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG+tzGHivF2o1epk5esBZ6yOZ/tw87gcc3F+4KjQOedrrPJ6XNosdMscmRTR4AVNNmWzkRMKg== X-Received: by 2002:a05:600c:350e:b0:43c:e478:889 with SMTP id 5b1f17b1804b1-441bbe2c815mr15375545e9.0.1746176450510; Fri, 02 May 2025 02:00:50 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: qemu-rust@nongnu.org, zhao1.liu@intel.com Subject: [PATCH 2/2] rust: assertions: Support index field wrapped in BqlCell Date: Fri, 2 May 2025 11:00:44 +0200 Message-ID: <20250502090044.85557-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250502090044.85557-1-pbonzini@redhat.com> References: <20250502090044.85557-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.644, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1746176473390019100 Content-Type: text/plain; charset="utf-8" Currently, if the `num` field of a varray is not a numeric type, such as being placed in a wrapper, the array variant of assert_field_type will fail the check. HPET currently wraps num_timers in BqlCell<>. Although BqlCell<> is not necessary from strictly speaking, it makes sense for vmstate to respect BqlCell. The failure of assert_field_type is because it cannot convert BqlCell into usize for use as the index. Use a constant 0 instead for the index, by avoiding $(...)? and extracting the common parts of assert_field_type! into an internal case. Commit message based on a patch by Zhao Liu . Link: https://lore.kernel.org/r/20250414144943.1112885-3-zhao1.liu@intel.com Signed-off-by: Paolo Bonzini --- rust/qemu-api/src/assertions.rs | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/rust/qemu-api/src/assertions.rs b/rust/qemu-api/src/assertions= .rs index eb12e9499a7..a2d38c877df 100644 --- a/rust/qemu-api/src/assertions.rs +++ b/rust/qemu-api/src/assertions.rs @@ -78,33 +78,26 @@ fn types_must_be_equal(_: T) /// ``` #[macro_export] macro_rules! assert_field_type { - ($t:ty, $i:tt, $ti:ty) =3D> { + (@internal $param_name:ident, $ti:ty, $t:ty, $($field:tt)*) =3D> { const _: () =3D { #[allow(unused)] - fn assert_field_type(v: $t) { - fn types_must_be_equal(_: T) + fn assert_field_type($param_name: &$t) { + fn types_must_be_equal(_: &T) where T: $crate::assertions::EqType, { } - types_must_be_equal::<_, $ti>(v.$i); + types_must_be_equal::<_, $ti>(&$($field)*); } }; }; =20 + ($t:ty, $i:tt, $ti:ty) =3D> { + $crate::assert_field_type!(@internal v, $ti, $t, v.$i); + }; + ($t:ty, $i:tt, $ti:ty, num =3D $num:ident) =3D> { - const _: () =3D { - #[allow(unused)] - fn assert_field_type(v: $t) { - fn types_must_be_equal(_: T) - where - T: $crate::assertions::EqType, - { - } - let index: usize =3D v.$num.try_into().unwrap(); - types_must_be_equal::<_, &$ti>(&v.$i[index]); - } - }; + $crate::assert_field_type!(@internal v, $ti, $t, v.$i[0]); }; } =20 --=20 2.49.0