Go to definition feature of rust analyzer not working in a macro

When I try to find the definition of ChaCha in state:ChaCha, I get no definitions found. This is from the rand_chacha crate.

Is there some setting I can tweak to fix this or is it a know problem in rust analyzer?
Asked this because I am about to post a issue on rust analyzer and won't post that if it was a widely known limitation.

If you are trying to go to definition from within macro_rules, it's probably because the ChaCha identifier only had a meaning once the macro is instantiated somewhere. There, it will refer to whatever is in scope and called ChaCha, so it could be anything from any crate. Even something that has been aliased as ChaCha. It's just a word at this point. Rust analyser will try to be helpful and highlights it as a type, but I think it's only syntactic and macros are inherently tricky in many ways. There is still possibly room for improvement when it comes to what it does when you try to go to the definition.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.