Stream: t-compiler/rust-analyzer

Topic: Fail to find macro definition under VSCode


pachi (Dec 18 2020 at 10:57, on Zulip):

Hi, I'm using rust-analyzer in VSCode with Gtk, and I'm having problems with some macros. These show an error, "Fail to find macro definition", even if it's indeed on scope (with an use statement) and the code compiles fine. As a result, I don't get type hints or any of the niceties that r-a usually provides (only code highlighting).
Is this a known problem? Is it a problem with my configuration?
Captura-de-pantalla-de-2020-12-18-11-57-33.png

Laurențiu (Dec 18 2020 at 11:05, on Zulip):

Did type inference work before?

pachi (Dec 18 2020 at 11:07, on Zulip):

Not for this same macro, AFAICT.
For the rest of the file, there's no problem.

Laurențiu (Dec 18 2020 at 11:08, on Zulip):

It's probably not your configuration. rust-analyzer has a few bugs/limitations wrt. macros and that diagnostic was recently added and made them more visible. You can disable the warning if you want to, and you could also test in the nightly version since a couple of bugs were fixed this week.

pachi (Dec 18 2020 at 11:09, on Zulip):

Ok, then I'll wait for next week's update. Thanks!

Laurențiu (Dec 18 2020 at 11:09, on Zulip):

A minimized test case (copy the clone definition to an empty project) would help if you want to file an issue.

pachi (Dec 18 2020 at 11:09, on Zulip):

I'll have a look, then.

pachi (Dec 18 2020 at 11:11, on Zulip):

It's this macro here: https://github.com/gtk-rs/glib/blob/f53054c8d392d22dba55ac122dddfe9fc9b191ef/src/clone.rs#L423 and it's indeed complex.

Laurențiu (Dec 18 2020 at 11:13, on Zulip):

https://github.com/serde-rs/json/blob/master/src/macros.rs#L69 is similar and we found an issue in https://github.com/rust-analyzer/rust-analyzer/issues/6876.

pachi (Dec 18 2020 at 11:17, on Zulip):

That looks like the same problem. In fact, I don't remember having this problem, but I haven't touched this project for a long time so it may well be the case.
Thanks for your help! It's a pleasure to use r-a!

Laurențiu (Dec 18 2020 at 11:19, on Zulip):

Hmm, this looks like it might be annoying to minimize

Laurențiu (Dec 18 2020 at 11:20, on Zulip):

I still get "Fail to find macro definition" in https://bpa.st/FKLQ

Laurențiu (Dec 18 2020 at 11:31, on Zulip):

Filed https://github.com/rust-analyzer/rust-analyzer/issues/6926

Laurențiu (Dec 20 2020 at 07:09, on Zulip):

@pachi my @Edwin Cheng's fix for that issue just landed, you could try a source build to see if it's working. Unfortunately, I don't think it will be in tomorrow's release (but I might be wrong about that).

pachi (Dec 20 2020 at 07:20, on Zulip):

@Laurențiu Nicola wow, that's great! I 'm not sure I will be able to do the source build, but thanks for pointing and thanks to @Edwin Cheng . If it gets into tomorrow release I'll report.

Laurențiu (Dec 20 2020 at 07:35, on Zulip):

Just clone and run cargo xtask install :-)

pachi (Dec 23 2020 at 10:10, on Zulip):

I'm using this week's release and the fix is working fine. Thanks a lot!

Last update: Jul 29 2021 at 21:15UTC