Rust Glancer v0.4.0: better IDE experience

I guess it's a good time for a new Rust Glancer version (BTW, if you're seeing this for the first time, Rust Glancer is a new experimental LSP that targets using no more than 100MB of memory while idle; it's young and incomplete but already pretty capable).

This time I focused almost solely on the day-to-day experience: better inlay hints, faster reference search, basic dyn Trait and auto traits support, improved declarative macro experience, const evaluation, etc. Please check out the demo video, and also there will be a bunch of screenshots below, since the changes are easier to show than to explain :)

However, in terms of "metrics", the improvement is also quite good. I have an internal tool that compares Rust Glancer against rust-analyzer on a fixed project with a wide set of queries, and here are the results for v0.3 / v0.4. Note that this is a subjective comparison, so consider it a relative improvement, not an actual percentage of "rust-analyzer completeness".

Featurev0.3.0v0.4.0Change
Saved files: overall85.3%93.0%+7.7pp
Find references98.2%98.3%+0.1pp
Go to definition73.0%81.8%+8.8pp
Go to type definition95.7%97.9%+2.2pp
Find implementations43.9%99.6%+55.6pp
Rename98.6%98.6%0.0pp
Document highlights96.5%99.1%+2.6pp
Document symbols92.2%92.2%0.0pp
Workspace symbols73.4%73.4%0.0pp
Inlay hints47.7%63.6%+15.9pp
Hover94.5%97.7%+3.2pp
Unsaved buffers: overall87.6%95.3%+7.7pp
Go to definition70.6%88.9%+18.3pp
Go to type definition92.3%100.0%+7.7pp
Document highlights90.9%95.7%+4.7pp
Document symbols96.7%96.7%0.0pp
Inlay hints47.9%70.1%+22.2pp
Hover84.2%95.2%+11.0pp

If you want to try out Rust Glancer, you can use:

Ugh, and also: obligatory LLM usage disclaimer.

Now, onto the actual release contents.

Improvements

Full changelog is available here, so let's focus on the most important stuff.

OK, where do I start?

Inlay hints

Probably, the most noticeable change is the rework of inlay hints

Inlay hints with inferred closure parameters and compact type labels

It has a bunch of real quality of life improvements (inspired by and aligned with rust-analyzer behavior):

  • Inferred closure parameters now have hints
  • Obvious/noisy parameters are filtered out
  • Default generic arguments like Global for Vec are not shown.
  • Complex/nested types are collapsed and have tooltip to show the full type.
  • Iterator adapters are replaced with impl Iterator (full type is also available in the tooltip).

..and some other minor things. Overall, the inlay hints now should look pretty close to what you are used to in rust-analyzer.

Traits

We now have (basic) support for auto traits:

Analysis support for auto traits such as Send and Sync

It means that the code with, say, Send and Sync (including generics) is interpreted correctly. Now, it is somewhat optimistic, e.g. Send might be assumed unless a concrete negative impl exists for the type, which means that there might be some false positives here and there. I don't think the impact should be very big, though.

Additionally, we now have dyn Trait support as well:

Analysis support for dyn Trait objects

And it works with auto traits too, e.g. dyn Foo + Send.

Until now, the references search (Find All References) was by far the slowest kind of query. Well, not anymore. Optimization required to reduce the "completeness" of search and stop following aliases when looking for references, but that's what rust-analyzer also does (I guess for the same reason), so it should be fine.

Reference search performance before and after optimization

Const evaluation

const and static values will now show the initializer (if it's not too long) and where possible, try to evaluate the expression and add it to the hover hint.

Const and static hover information with initializers and evaluated values

Better IDE support for declarative macros

Probably the feature I wanted to have the most (out of remaining missing areas). You can now hover and use goto on the declarative macro parameters, including format_args captures. And captures now get semantic highlighting too.

The support is not complete, more work can be done here, but it should cover 80% of common use cases.

Hover and navigation for macro arguments, with highlighted format string captures

What's next

With this release, my day-to-day workflow with Rust Glancer feels perfectly normal, I don't feel like I'm using an "experimental incomplete LSP" anymore. Everything that I use is generally supported. Functionality that should work, works reasonably fast. The memory stays low. Obviously, there is a ton of things that are missing in general, starting with procedural macros and missing opportunities for type inference, but this now feels like adding functionality to a "real" product, rather than getting to a "usable" state.

For the next release, I have quite a bunch of optimizations planned that should make many things faster (mainly initial indexing), as well as some quality of analysis improvements (e.g. proper support of the Future trait; right now I rely on shortcuts that are somewhat hacky). I still plan to add proc macros support without actual proc macro execution, but I decided that providing a polished experience for things that already exist is more important.

Otherwise, thanks for reading. As usual, the best way to support if you like the project is to star the repo (but only if you like it!) and/or follow me on twitter.