Stream: t-compiler/wg-rls-2.0

Topic: Avoid parsing items to determine if they are deprecated


Martin Asquino (Nov 04 2019 at 16:00, on Zulip):

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.

matklad (Nov 04 2019 at 16:16, on Zulip):

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

matklad (Nov 04 2019 at 16:17, on Zulip):

Scope thing is a small debug helper which allows one to delimit dynamic scope (for exapmle, things happening during completion)

matklad (Nov 04 2019 at 16:18, on Zulip):

print_backtrace can then be used to figure out why did you end up parsing things

Martin Asquino (Nov 04 2019 at 16:19, on Zulip):

oh, nice! will look into it! thanks!

matklad (Nov 04 2019 at 16:25, on Zulip):

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

matklad (Nov 04 2019 at 16:43, on Zulip):

@Jeremy Kolb this zulip thread :)

matklad (Nov 04 2019 at 16:44, on Zulip):

I think, once this ground work with attrs done, we should:

Martin Asquino (Nov 04 2019 at 17:02, on Zulip):

That was actually my original idea (moving hygiene before match), but I couldn't figure out how to get file_id from 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:

Last update: Nov 12 2019 at 15:45UTC