# Indexing Rust code in IntelliJ Rust

**URL:** <https://internals.rust-lang.org/t/indexing-rust-code-in-intellij-rust/3633>\
**Category:** tools and infrastructure\
**Created:** [June 27, 2016, 11:06pm UTC](https://internals.rust-lang.org/t/indexing-rust-code-in-intellij-rust/3633 "2016-06-27T23:06:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![matklad](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/matklad/32/12266_2.png) [@matklad](https://internals.rust-lang.org/u/matklad)\
**Post date:** [June 27, 2016, 11:06pm UTC](https://internals.rust-lang.org/t/indexing-rust-code-in-intellij-rust/3633/1 "2016-06-27T23:06:56Z")

</div>

Hi! We’ve started to work on the type inference in IntelliJ Rust, and one of the interesting problems there is finding an impl, given the type and the trait. I’ve written down my thoughts about how this can be achieved within IntelliJ [indexing infrastructure](http://www.jetbrains.org/intellij/sdk/docs/basics/indexing_and_psi_stubs/stub_indexes.html) in [this issue](https://github.com/intellij-rust/intellij-rust/issues/498). Perhaps it would be interesting for people working on the RLS.

---

<div class="post-metadata">

**Author:** ![eddyb](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/eddyb/32/8411_2.png) [@eddyb](https://internals.rust-lang.org/u/eddyb)\
**Post date:** [June 28, 2016, 2:17pm UTC](https://internals.rust-lang.org/t/indexing-rust-code-in-intellij-rust/3633/2 "2016-06-28T14:17:29Z")

</div>

The RLS will use the compiler and thus have access to the trait selection infrastructure. That seems like the most straight-forward approach, IMO.

---

<div class="post-metadata">

**Author:** ![matklad](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/matklad/32/12266_2.png) [@matklad](https://internals.rust-lang.org/u/matklad)\
**Post date:** [June 28, 2016, 3:30pm UTC](https://internals.rust-lang.org/t/indexing-rust-code-in-intellij-rust/3633/3 "2016-06-28T15:30:51Z")

</div>

I am curious, at what level of incrementality would RLS operate? My understanding is that RLS will periodically schedule a full rebuild of a crate, and would record a result of that process into some kind of an index (sort of like [https://www.kythe.io/](https://www.kythe.io/)). The approach in IntelliJ is, in some sense, the opposite: we index the source code on a per file basis after parsing, but before name resolution and type inference, and then use the indexes to quickly recalculate all the semantic information as the user edits the code.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/system/32/14092_2.png) [@system](https://internals.rust-lang.org/u/system)\
**Post date:** [March 25, 2019, 8:26am UTC](https://internals.rust-lang.org/t/indexing-rust-code-in-intellij-rust/3633/4 "2019-03-25T08:26:22Z")

</div>

Closed on March 25, 2019, 8:26am UTC

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
