Stream: t-compiler/rust-analyzer

Topic: Code to convert RA ast to rustc ast

Luca Barbieri (Apr 03 2020 at 18:15, on Zulip):

@matklad I wrote some code to convert RA asts to rustc asts as a pull request for rustc. It is essentially complete and can build real projects, provided they only use the Rust 2018 edition, since the RA parser currently doesn't support 2015. It can be used as a development tool to check that RA and rustc produce the same AST, and could theoretically replace the rustc parser (but that would need much better error reporting, ensuring that all invalid code is rejected and more misc work). Pull request at

matklad (Apr 03 2020 at 18:18, on Zulip):


matklad (Apr 03 2020 at 18:19, on Zulip):

:tada: :100:

matklad (Apr 03 2020 at 18:19, on Zulip):

Can rustc with rust-analyzer's parser build rust-analyzer?

matklad (Apr 03 2020 at 18:22, on Zulip):

(I am still speechless by the way)

Luca Barbieri (Apr 03 2020 at 18:30, on Zulip):

IIRC it can't at least due to some dependencies using Rust 2015

matklad (Apr 03 2020 at 18:31, on Zulip):

I'd love to fix that (supporting subsets of 2015 shouldn't be too hard I hope)! Not because it would be useful, but because that would be super cool!

matklad (Apr 03 2020 at 18:32, on Zulip):

I've obviously haven't looked into the PRs yet (and probably won't be able to dig into them today), but, right of the bat, I have an organizational question

matklad (Apr 03 2020 at 18:33, on Zulip):

@Luca Barbieri how do you feel about driving the task of unifing rustc and rust-analyzer parsers? I guess, at the moment you know more about this than anyone else in the universe :)

Luca Barbieri (Apr 03 2020 at 18:36, on Zulip):

actually I don't think I'll do any more significant work on rust-analyzer/rustc at the moment

matklad (Apr 03 2020 at 18:37, on Zulip):

That's fair!

Last update: Jul 28 2021 at 04:30UTC