-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Derive] #[doc = macro_name!()]
doesn't play well with doc comments
#2639
Comments
I investigated the current codebase for quite a while, and the main problem we have here seems to be the following: When will the macro be expanded? Ideally |
I went down a different rabbit hole, in hopes that bumping MSRV and maybe proc macro deps might be of assistance. I'm guessing not but at least we have #2640 I'll look into that part. Part of the problem is we do post-processing on the doc comment to better format it. iirc we have a verbatim flag which could work with it. I'll dig a little into these parts. |
From rust-lang/rust#83366
Still fairly weak on my proc macros but I think this is confirming that we have to pass along the macro call for later expansion, which means it is unlikely to work with |
I guess one option is we can either generate or embed some const-fns that do the post-processing for us. |
@epage Yeah, I saw that post-processing part. Before, with only doc literals, it's reasonable to do this in the derive macro. However, when the doc macros come into play, it seems impossible (at least to both of us) to keep it this way: the call site has to be changed. But don't worry, once the macro call has been transferred to the call side, we should be able to use something like the It's true that Of course, we have to be very careful about |
@epage Wait a second, does rust-lang/rust#87264 include the eager expansion that we want? If so, we can wait for it! (And in that case I know exactly which function should be modified!) |
This is a big problem to me. I need to generate commands from a macro, and the macro documents commands automatically, but it needs to interpolate a few strings inside documentation. I am using |
@brunoczim Since rust-lang/rust#87264 has already landed with ... But don't expect that to be available in |
I'd appreciate it, thanks! |
Please complete the following tasks
Rust Version
1.54.0
Clap Version
master
Minimal reproducible code
Steps to reproduce the bug with the above code
Run the test above.
Actual Behaviour
Assertions fail with no comments help message detected:
Expected Behaviour
Assertions pass with all help messages specified by the macro call.
Additional Context
No response
Debug Output
No response
The text was updated successfully, but these errors were encountered: