From: marcandre.lureau@redhat.com
To: qemu-devel@nongnu.org
Cc: "Manos Pitsidianakis" <manos.pitsidianakis@linaro.org>,
"Daniel P. Berrangé" <berrange@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
pbonzini@redhat.com, qemu-rust@nongnu.org,
"Marc-André Lureau" <marcandre.lureau@redhat.com>
Subject: [PATCH 4/4] rust/qemu-api-macros: make derive(Object) friendly when missing parent
Date: Tue, 26 Aug 2025 17:31:32 +0400 [thread overview]
Message-ID: <20250826133132.4064478-5-marcandre.lureau@redhat.com> (raw)
In-Reply-To: <20250826133132.4064478-1-marcandre.lureau@redhat.com>
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
rust/qemu-api-macros/src/lib.rs | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/rust/qemu-api-macros/src/lib.rs b/rust/qemu-api-macros/src/lib.rs
index b525d89c09..a614741889 100644
--- a/rust/qemu-api-macros/src/lib.rs
+++ b/rust/qemu-api-macros/src/lib.rs
@@ -85,7 +85,15 @@ fn derive_object_or_error(input: DeriveInput) -> Result<proc_macro2::TokenStream
is_c_repr(&input, "#[derive(Object)]")?;
let name = &input.ident;
- let parent = &get_fields(&input, "#[derive(Object)]")?[0].ident;
+ let parent = &get_fields(&input, "#[derive(Object)]")?
+ .get(0)
+ .ok_or_else(|| {
+ Error::new(
+ input.ident.span(),
+ "#[derive(Object)] requires a parent field",
+ )
+ })?
+ .ident;
Ok(quote! {
::qemu_api::assert_field_type!(#name, #parent,
--
2.50.1
next prev parent reply other threads:[~2025-08-26 13:32 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-26 13:31 [PATCH 0/4] rust: little clean-ups and updates marcandre.lureau
2025-08-26 13:31 ` [PATCH 1/4] rust: run cargo update marcandre.lureau
2025-08-26 17:43 ` Paolo Bonzini
2025-08-26 13:31 ` [PATCH 2/4] rust: remove unused global qemu "allocator" marcandre.lureau
2025-08-26 13:31 ` [PATCH 3/4] build-sys/rust: update syn to v2.0.106 marcandre.lureau
2025-08-26 13:31 ` marcandre.lureau [this message]
2025-08-27 2:58 ` [PATCH 4/4] rust/qemu-api-macros: make derive(Object) friendly when missing parent Zhao Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250826133132.4064478-5-marcandre.lureau@redhat.com \
--to=marcandre.lureau@redhat.com \
--cc=berrange@redhat.com \
--cc=manos.pitsidianakis@linaro.org \
--cc=pbonzini@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-rust@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).