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?
Did type inference work before?
Not for this same macro, AFAICT.
For the rest of the file, there's no problem.
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.
Ok, then I'll wait for next week's update. Thanks!
A minimized test case (copy the
clone definition to an empty project) would help if you want to file an issue.
I'll have a look, then.
It's this macro here: https://github.com/gtk-rs/glib/blob/f53054c8d392d22dba55ac122dddfe9fc9b191ef/src/clone.rs#L423 and it's indeed complex.
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.
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!
Hmm, this looks like it might be annoying to minimize
I still get "Fail to find macro definition" in https://bpa.st/FKLQ
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).
@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.
Just clone and run
cargo xtask install :-)
I'm using this week's release and the fix is working fine. Thanks a lot!