dbus2 / zbus

Rust D-Bus crate.
Other
346 stars 78 forks source link

rust-analyzer unable to see some types in `zbus::fdo` #671

Open FineFindus opened 6 months ago

FineFindus commented 6 months ago

Due to a regression introduced with the new macros in 2189e16a333afe71ddb4c21ab24e49e36a29e53d, rust-analyzer is no longer able to see some of the generated interfaces / infer the types of e.g. zbus::fdo::ObjectManagerProxy. It's only rust-analyzer that has this problem, cargo check, clippy, and compiling and running the code work fine. There may be other types that have this problem, though I haven't noticed any. I found this with git bisect and confirmed it by manually changing the macros back to the old ones, after which rust-analyzer is able to infer the type correctly.

Before After
rust-analyzer correctly infers the type rust-analyzer is unable to infer the type of ObjectManagerProxy
auto-completion of all available fdo types in 3.15 auto-completion of all available fdo types in 4.1.2
TTWNO commented 5 months ago

There are a couple things I'm considering first. Given that the structures/traits/modules do indeed exist, they are just hidden from Rust Analyzer... it makes me think that it's actually a Rust Analyzer problem—even if I did introduce the change that broke it.

First of all, completion does not work within a macro_rules! invocations, and also using cfg_attr and proc-macros together causes completion to stop working. These together make me wonder (apologies I haven't had time to diagnose it yet), if we have somehow triggered a similar edge case in that commit—my guess is as good as yours as to the exact location of the problem, but I will look into this when I have time and see if this is an issue of incomplete code, or an issue upstream with Rust Analyxer itself.

(Edit: sorry, this is not directed at you, the reporter. I'm just writing down my thoughts. This is a very detailed report, and I thank you for that!)

zeenix commented 5 months ago

There are a couple things I'm considering first. Given that the structures/traits/modules do indeed exist, they are just hidden from Rust Analyzer... it makes me think that it's actually a Rust Analyzer problem—even if I did introduce the change that broke it.

That's always possible.

zeenix commented 3 months ago

First of all, completion does not work within a macro_rules! invocations,

I think that's likely our culprit. I'm right now switching fdo mod over to using the new proxy generation feature of interface macro and macro_rules use is going to be dropped as part of that. While working on that, I noticed that completion starts working perfectly if there is no macro_rules involved, so I'm 100% sure this is the issue.

In any case, the issue is in R-A really so I'm closing this one.

zeenix commented 3 months ago

I think that's likely our culprit. I'm right now switching fdo mod over to using the new proxy generation feature of interface macro and macro_rules use is going to be dropped as part of that. While working on that, I noticed that completion starts working perfectly if there is no macro_rules involved, so I'm 100% sure this is the issue.

Actually, no. I removed all macro_rules use but completion won't work. However, it works if interface generates the proxy, which is super strange since it also uses proxy macro. :exploding_head: