Paolo Bonzini <pbonz...@redhat.com> writes:
> Il lun 21 ott 2024, 09:24 Junjie Mao <junjie....@hotmail.com> ha scritto: > > > Thanks. I still prefer to keep the procedural macro code minimal, and > have the > > code generation in a separate macro, but this is a nice start! > > > > I'm not sure if I get your point right. > > My understanding is that preferring minimizing proc macros is because > they generate a big, arbitrary block of code that is hard to read and > debug directly (which requires cargo expand the whole crate). That is > thus more error-prone and makes maintenance harder. > > As for having "the code generation in a separate macro", are you > referring to `macro_rules!`? > > Yes, keeping the generation of the impl block in with_offsets!. Then you can > get the best of both worlds in my opinion, for example the #[repr(C)] check > is more robust in the procedural macro. Got it. Will try that approach in v2. > > Sure. Will use quote_spanned! here and make reported errors being a > tuple of error msg and span to use. > > If it's okay for you let's first get the fixes in, and then I can repost the > MSRV series and include your procedural macro and unit tests. The v2 fixes look good to me overall. Thanks! -- Best Regards Junjie Mao