I've been looking at https://github.com/rust-analyzer/rust-analyzer/issues/2167 and I think I've got something going. Would appreciate some more experienced eyes to look at how the implementation looks right now.
I've opened a PR on my own fork while I work on it so you can look at the diffs without me opening a PR in rust-analyzer/rust-analyzer: https://github.com/martskins/rust-analyzer/pull/2 The thing that I'm most worried about is that massive match I have in
attributes_query, but other than introducing a macro for that I'm not sure how to solve that.
Also, please disregard the commented code, I'll remove that once this is considered done.
Will take a look shortly! One thing I've realised is that I haven't shown how to test hypothesis that "deprecation tags cause parsing". See https://github.com/matklad/rust-analyzer/commit/bcf17f26401501a7350e706ab8a776779dcfc8fa for an example how to do it
Scope thing is a small debug helper which allows one to delimit dynamic scope (for exapmle, things happening during completion)
print_backtrace can then be used to figure out why did you end up parsing things
oh, nice! will look into it! thanks!
Yeah, that commit is roughly how it should be done! Don't worry about that gigantic match --- that's a pretty common pattern for rust-analyzer, the one for docs is similar. Though, you might slightly condence it, if you move hygiene bit to before the `match
@Jeremy Kolb this zulip thread :)
I think, once this ground work with attrs done, we should:
#[doc = "fooo"]
That was actually my original idea (moving hygiene before match), but I couldn't figure out how to get
AttrDef. In any case, I managed to clean it up a little and reduce the repetition only to two places. Could be better, but it's a start :smiley: