rust-analyzer: Regression: Proc macros not being expanded
It seems that proc macro support degraded heavily from the previous version of RA for me. In the last version, both web-sys autocomplete and proc macro inlay hints worked.
Now, it seems that RA is blind to any web-sys types (once again) and none of my proc macros are being expanded (proc macro not expanded rust-analyzerunresolved-proc-macro). My proc macro is fairly well behaved and, in the past, had significant IDE support for hovers/go-to/inlay hints.
For instance, my code
let g = rsx!(div {});
expands to
let g = NodeFactory::annotate_lazy(move |__cx: NodeFactory| -> VNode {
__cx.element(dioxus_elements::div, [], [], [], None)
});
I would expect to see hints on div since I re-use the token literally, but the macro simply fails to expand.
Is there a different proc-macro server I can use that works?
rust-analyzer version: d9b2291f5 2021-11-29 stable
rustc version: rustc 1.56.1 (59eed8a2a 2021-11-01)
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 14
- Comments: 28 (11 by maintainers)
Chiming in to say I had an issue with this when writing a fresh derive macro, and it went away when I reloaded rust-analyzer (
rust-analyzer: Restart Serverin VSCode).My precise output from rust-analyzer was “Proc macro not expanded: no proc macro dynlib present”.
Digging a bit deeper it turns out that yes, I simply didn’t correctly enable proc-macros in the LSP config. For anyone else in my same situation, the answer was
(setq-default lsp-rust-analyzer-proc-macro-enable t).I agree that it’d be nice to have more informative errors. Something along the lines of
proc-macro expansion disabled in configurationwould help separate user configuration errors from legitimate rust-analyzer errors.Let’s close this since the original issue is not reproducible, and the ticket risks becoming a dumping ground for proc macro expansion problems.
I also run into this problem on Doom Emacs, I use
rust-analyzer ba3305480 2022-02-07 stableandrustc 1.56.1 (59eed8a2a 2021-11-01).I’m sure my
lsp-rust-analyzer-proc-macro-enableis set tot, in fact I have no problem expand locally declared macro, but failed to correctly expand foreign (imported) proc macro.(btw, I also confirm the output of expanded code on vscode via “Rust Analyzer: Expand macro recursively” to perfectly matched that of my emacs, both have no issue with locally defined macro, but both failed with imported macro)
I can confirm this is still an issue.
rust-analyzer was installed with
cargo install rust-analyzer --git https://github.com/rust-analyzer/rust-analyzer.git --lockedRunning in Spacemacs with the Rust layer.I am positive this is the only version of rust-analyzer I have installed - Spacemacs does not install its own version.
@al2me6 can you try with the next RA nightly? This seems to work now for me.
@alexjg false alert 😃.
for me, the issue turned out to be that I had a sub project in my repo that I decided to delete and remove…but the vscode/settings.json had this in it:
{ “rust-analyzer.linkedProjects”: [ “./Cargo.toml”, “./Deleted_Project/Cargo.toml” ] }
I deleted the “./Deleted_Project/Cargo.toml” line and the problem went away
i’td be awesome if rust-analyzer reported that I was asking for it to link to a project that no longer existed and stopped executing.
@al2me6 you need to try with the next nightly.