Managing Generated Code with rust-analyzer

Hello,

Does anyone who uses zbus have advice on managing the generated code during development time using rust-analyzer as an LSP server? Would it be possible to, say, have it macroexpand the generated files so that the type information will be available while I am coding. Otherwise, I suppose I can dump the macroexpanded file out into a file and read it that way. Additionally, what is the prefered way to organize the code? At present, I have a src/generated/mod.rs that holds all the generated code, but I suspect that this will turn out to be a gigantic mess in the long run.

Thanks for any guidance you can provide.

I'm not familiar with zbus, but it seems to be using attribute macros. Have you tried enabling rust-analyzer.experimental.procAttrMacros? Or is there some other code generation there that I missed?

You are correct in that it is using proc macros for its code generation; will need to see if there is a corresponding Emacs setting.

Are there any other variables I need to turn on in conjunction to that one? I am getting an unresolved procmacro dbus_proxy, yet the code runs fine and compiles correclty.

That sadly means there's a bug in rust-analyzer.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.