Paolo Bonzini <pbonz...@redhat.com> writes:
> On 11/3/24 10:54, Junjie Mao wrote: >> Paolo Bonzini <pbonz...@redhat.com> writes: >> >>> diff --git a/rust/qemu-api-macros/src/lib.rs >>> b/rust/qemu-api-macros/src/lib.rs >>> index a4bc5d01ee8..c2ea22101e4 100644 >>> --- a/rust/qemu-api-macros/src/lib.rs >>> +++ b/rust/qemu-api-macros/src/lib.rs >>> @@ -3,8 +3,34 @@ >>> // SPDX-License-Identifier: GPL-2.0-or-later >>> >>> use proc_macro::TokenStream; >>> -use quote::quote; >>> -use syn::{parse_macro_input, DeriveInput}; >>> +use proc_macro2::Span; >>> +use quote::{quote, quote_spanned}; >>> +use syn::{ >>> + parse_macro_input, parse_quote, punctuated::Punctuated, token::Comma, >>> Data, DeriveInput, Field, >>> + Fields, Ident, Type, Visibility, >>> +}; >>> + >>> +struct CompileError(String, Span); >>> + >>> +impl From<CompileError> for proc_macro2::TokenStream { >>> + fn from(err: CompileError) -> Self { >>> + let CompileError(msg, span) = err; >>> + quote_spanned! { span => compile_error!(#msg); } >> The documentation [2] says "there should be no space before the => >> token" and that is by intention to tell that `span` is "evaluated in the >> context of proc macro" while those after the arm "in the generated >> code". Should we follow that convention (even though the extra white >> space does not impact building)? > > Ah, forgot to reply about this. Personally I think it's clear enough with the > space around both sides of "=>", but if there's agreement on removing the > space > I don't oppose it. > > Paolo I don't have any preference, either. I think we can keep it as is and make sure future calls to quote_spanned! have consistent style. Thanks. -- Best Regards Junjie Mao