Skip to content
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

IDE support in fn-like proc macro arguments #5265

Closed
nitsky opened this issue Jul 8, 2020 · 8 comments
Closed

IDE support in fn-like proc macro arguments #5265

nitsky opened this issue Jul 8, 2020 · 8 comments
Labels
A-macro macro expansion E-hard S-actionable Someone could pick this issue up and work on it right now

Comments

@nitsky
Copy link

nitsky commented Jul 8, 2020

With support for fn-like proc macros as expressions becoming stable in rust 1.45 (rust-lang/rust#68717), I am opening this issue to track rust-analyzer support for language features within them.

For example, given the code below that uses a proc macro that implements jsx-like syntax...

let items = &["a", "b", "c"];
let html = html!(<ul>{items.iter().map(|item| html!(<li>{item}</li>))}</ul>);

... it would be awesome to be able to use "go to definition", "rename", "find references", etc when my cursor is over the last item identifier.

@bjorn3 bjorn3 added the A-macro macro expansion label Jul 8, 2020
@matklad matklad added the E-hard label Jul 11, 2020
@jonas-schievink jonas-schievink changed the title support for fn-like proc macros IDE support in fn-like proc macro arguments Nov 24, 2020
@lnicola lnicola added the S-actionable Someone could pick this issue up and work on it right now label Dec 21, 2020
@nitsky
Copy link
Author

nitsky commented Jan 6, 2021

Thanks to recent improvements by @jonas-schievink, language features in the example above now work perfectly. Thank you!

@nitsky nitsky closed this as completed Jan 6, 2021
@ivnsch
Copy link

ivnsch commented Feb 21, 2021

@nitsky Which version? I'm using Rust-Analyzer v0.2.489 (most recent version) and Yew 0.17, followed the intro tutorial in the docs, and it doesn't work.

@bjorn3
Copy link
Member

bjorn3 commented Feb 21, 2021

Did you enable proc-macro support using

{
    "rust-analyzer.cargo.loadOutDirsFromCheck": true,
    "rust-analyzer.procMacro.enable": true,
}

@nitsky
Copy link
Author

nitsky commented Feb 21, 2021

@i-schuetz in my experience macro not found errors are resolved by reloading the editor.

@ivnsch
Copy link

ivnsch commented Feb 21, 2021

Hmm sadly still not working, I restarted VSCode multiple times and double checked that the settings are in the workspace's settings.json (added them to the user's as well just in case) and the macro still doesn't work

could not resolve macro htmlrust-analyzer macro-error

@memoryruins
Copy link
Contributor

html! uses proc_macro_hack https://docs.rs/yew/0.17.4/src/yew/lib.rs.html#101. which tends to cause that error due to lack of attribute macro support #6029. Oh, after visiting that issue again, looks like another html! issue #7221 was closed for that reason.

To silence those warnings for now, "macro-error" can be added to "rust-analyzer.diagnostics.disabled"

@nitsky
Copy link
Author

nitsky commented Feb 21, 2021

@i-schuetz I am not seeing the issue because I am using an in-house html! macro, which does not use proc_macro_hack, and which we designed to ensure it emits the correct span information for rust-analyzer.

@ivnsch
Copy link

ivnsch commented Feb 21, 2021

Was able to fix it by using yew master yewstack/yew#1754

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macro macro expansion E-hard S-actionable Someone could pick this issue up and work on it right now
Projects
None yet
Development

No branches or pull requests

6 participants