Hey, a couple of folks (60fps & discord) independently reached out to me about https://github.com/rust-analyzer/rust-analyzer/issues/3767, and that's a fun issue to think about.
In a nutshell, we can't goto definition inside the
include! macro. In some sense, this is expected behavior. From a programming model point of view,
include! is indistinguishable from a proc macro which creates the tokens out of thin air (imagine
proc_include which does
From a user's perspective though, the IDE clearly should just "see through" this macro. I wonder if anyone has idea about how to special case this best?
In rustc the spans of the tokens are from the included file, not the macro invocation itself afaik.
Maybe something like parse the included file as if it is a regular module and then take the tokens from this module and place them at the macro invocation site? Does that make sense?
yeah, rustc has an easier time here since it just loads all files into its source map and can then address any part of any file with a
I think we might be able to special-case this in the builtin macro logic by adding an extra
we already track included files there