Syntax analysis for rust-analyzer

There are a few exercises that could benefit from the rust analyzer giving feedback to user code, off the top of my head:

  • sieve: warn when division or modulo are used
  • accumulate: warn when any kind of map operation is used

This would also make a future syllabus nicer to go through, since the analyzer could catch common mistakes that don’t bother clippy. I remember the Elixir track was really good for this when I went through it.

For instance, if a lesson is supposed to teach iterators, we could warn on usage of loops.

Rust’s syn crate would probably be a good candidate to help us do this, but I have 0 experience working with rust syntax trees so I’m all ears for other options.

Yeah that sounds cool. It used to exist actually. I removed it when I added clippy support, because it didn’t do anything useful (imo). You can check the commit history if you want to reuse that. My honest opinion is that that code mostly consists of abstractions without any useful code that demonstrates the necessity of those abstractions.

If you want to revive the effort, I would prefer a setup that’s a little simpler to understand, even if it means more code to add individual lints.

syn is definitely the way to go.

1 Like