Evolution of Rust Compiler Errors

kobzol.github.io

166 points by ingve 16 days ago


kstrauser - 16 days ago

A million thanks to everyone who’s worked on those error messages. More than any other language I’ve ever used, Rust goes to great lengths to explain exactly you did wrong, with enough context to demonstrate it, and an explanation of why it’s wrong, pointers of where to learn more about it, and how to fix it.

Yes, Rust has some inherently tricky parts that require programmers to really understand them before they can write it effectively. However, it goes out of its way to teach those concepts more than I realized it was possible for a compiler to do.

pcwalton - 16 days ago

When I was first developing early versions of rustc I was really fascinated with Clang's effort at good error messages, which was helping it gain traction vs. GCC at the time, and I tried to start the Rust compiler project off on the right foot. I'm really glad that the Rust compiler dev community has continued to value great error messages: they're the UX of a compiler, and are every bit as important as UX of any other app.

kaycebasques - 16 days ago

Effective error messages are one of my platonic ideals about how documentation is supposed to work. The docs shouldn't be shoved off to the side. They should appear just-in-time, when you need them. If you can fix the error within the product (e.g. when Rust tells you exactly how to fix the typo), just do it there. Otherwise link off to the full docs when it's too much content.

The general platonic ideal is "have the product automatically fix the issue" => "provide short documentation within the product if the problem can be explained with just a paragraph or two of content" => "link to a targeted doc that deals with this exact problem if it takes more than a few paragraphs to explain"

A lot of time, my work as a technical writer is advocating to update the product (or updating the product myself) to do the first two steps, rather than just jumping immediately to the last step. Startup people often refer to this as "the perfect product requires 0 documentation." When teams always resort to fixing product issues with docs, your docs start to get huge and complicated. We technical writers often refer to this as "putting docs lipstick on the product pig."

steveklabnik - 16 days ago

This reminds me of http://brson.github.io/archaea/, which is a really fantastic project by Brian Anderson. It shows iterations of Rust's test files over the years, so you can see what older Rust syntax looked like.

Regardless, very cool!

swsieber - 16 days ago

The wrong field error message change in 1.87 really is brilliant. Instead of just pointing out the correct field, it actually points out the spelling change needed to get to that field.

nfriedly - 16 days ago

The helpful error messages are one of the reasons I love rust. Perhaps even the top reason.

mahirsaid - 16 days ago

Interesting enough i still hear people say the error messages from rust is confusing and none informative. I wouldn't say that i am proficient in Rust but i know enough about it and it;s tooling to distinguish the difference between different (LV " Low Level " ) languages. When you get a grasp of the Rust lang then you will know how helpful the compiler is in Rust compared to other languages. Highlighting the progress of the Rust lang compiler messages in this post really Depicts the refinement of their ( Rust lang team ) compiler messages.

IshKebab - 16 days ago

This is surprisingly cool. Now I want to see it for GCC (and mark the point where Clang was released!).

artemonster - 15 days ago

I really wish there would be rust version with optional borrow checker :) I want to have a modern "C" with such good error messages. Idk why gcc spits out incomprehensible garbage if you forgot a semicolon

duttish - 15 days ago

I've been using rust on and off for the last...ten years or so? A while before 1.0, before the?-operator and the compiler error messages have made such massive improvements it's almost ridiculous.

They used to be quite confusing and bad, these days I usually just fix what the compiler is suggesting and go about my day. It has massively lowered the threshold to becoming and staying productive.

I really don't want to go back to the template errors, and especially stl, of c++.

badmonster - 16 days ago

This was a fantastic read — thanks for putting in the work to script and visualize the evolution of Rust's compiler errors

ori_b - 15 days ago

I find that I like the errors from 1.12 to 1.14 the most. 1.12 shows where things happened during the expansion of macros, which can be useful, but 1.14 tends to be a bit terser and cleaner.

The newest errors tend to be noisy for my taste, and I have to tune out the advice to see the error.

90s_dev - 16 days ago

This visualization is breathtaking, thanks for making it.

Sometimes I want an excuse to write some Rust. I think I'll make one in my upcoming web app, since it already uses web workers. I guess the side effect is that wasm (and therefore Rust) will become a first class citizen in my app? Neat.

feznyng - 15 days ago

If you're doing language implementation work in Rust, an excellent crate to get similar diagnostic layouts to the Rust compiler is Ariadne[0].

[0] https://github.com/zesterer/ariadne

dangoodmanUT - 15 days ago

this was cool, this should be a standard way to show various kinds of diffs

gitroom - 15 days ago

[dead]

01HNNWZ0MV43FF - 16 days ago

I'm surprised 1.0 didn't have the error codes. Error codes should be table stakes for anything that produces errors, really (Looking at you, proprietary codebases where I was putting in error codes while other people were writing the C++ equivalent of `.expect("the value to be right")`)