How to approach a huge number of compiler errors in a systematic way?

It looks like cargo clippy supports all the same arguments as cargo check, so you can use cargo clippy --message-format json to get the output in a machine-readable format. That way you can make a script which doesn't rely on magic strings.

1 Like

Yes, but then it is no longer a small script, it is an enormous script that has to do all kinds of formatting and processing. I'm sure I've made the right choice to create a small script which can be easily adapted in a moment to whatever output cargo produces!

1 Like

That might have been their point though: there's no official documentation for the arch of rustc and thus the phases because the implementation might change at any time, and in fact is going through a major refactoring atm w.r.t. the query system and what's needed for that.

Within a single query you can still reason about before and after I think. But between more or less unrelated queries (e.g. 2 queries executed by a larger query), yeah that's where simple 1-dimensional before/after relations fall apart conceptually, similarly to distributed systems (and the solution for ordering them would be roughly the same I'd imagine, with Lamport and vector clocks).

I've learned to be wary of using regexes for complex data, an infamous example being HTML processing. The danger is that regexes are perhaps not expressive enough (they definitely aren't for HTML processing), leading to silent failures because the regexes still seem to match. Hence you get garbage output without even knowing it.

That danger doesn't exist when processing structured data, even if it is JSON.

Actually, this reminds me: We completely forgot to tell @fpoli that https://rustc-dev-guide.rust-lang.org/ exists! It's obviously not normative and doesn't imply any stability guarantees, but it arguably counts as "official".

In particular, I'd recommend looking at Queries: demand-driven compilation - Rust Compiler Development Guide for an intro to this "query system" we're all talking about.

2 Likes

That's all fine and very sensible in the general case, but in this specific case the error text is designed to be interpreted by editors such as Emacs, which will use regexes to pick out the bits of information that they need. Also the script either dumps out lines early or late. So nothing will be lost. I did look at the JSON output first, and I decided against using it, because what I actually want is exactly the existing text output, just in another order.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.