feat: support macro expansion in #[doc = ...] attributes#21928
Conversation
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
This comment has been minimized.
This comment has been minimized.
|
I cannot vouch for which is better but note that #21303 also implements that however by text-matching on |
|
Yes, this PR uses rust-analyzer's internal macro expansion mechanism, enabling all macro expansion within |
|
Then this PR is preferred. |
|
Just applied the suggestions! |
Co-authored-by: Chayim Refael Friedman <chayimfr@gmail.com>
There was a problem hiding this comment.
I'm really sorry, but it looks like even outer doc comments in module resolve inside the module (https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=a98e60abf9c8b018f0d47ed687c7416e). Which is very weird IMO (unintended behavior?) but we should follow rustc 😅
|
Updated! |
|
amazing! |
|
Unlike #21303, this didn't add Should we bite the bullet and load those into the VFS? |
|
Yea I think we should |
|
There aren't many markdown files usually so I believe it shouldn't cause perf problems. |
|
@asukaminato0721 want to do the honors? :) |
|
Ah, I never considered that the expansion of |
|
Tests always includes the specified files in the VFS. |
sure :) |
|
This does not appear to actually work (for the axum source code at least). It does not appear to have fixed the problem: https://github.com/tokio-rs/axum/blob/441216428893d13544f12722b54dcaaadd47135a/axum/src/error_handling/mod.rs#L1 Function level doc: I'd recommend re-opening at least one of the mentioned issues to track this (and perhaps consolidating on one of them?) |
|
@joshka As explained literally just above, the expansion does work but rust-analyzer in its current version does not load md files. If you'll make the file extension |
|
Ah, I see now. I missed that the VFS piece meant markdown wouldn’t work yet. Thanks for clarifying. |



fixes #7688, fixes #8092, fixes #11137, fixes #20494, closes #21303
Macro expansion part is hand-written; AI (specifically, GPT 5.4) was used to generate tests.