[Pre-RFC] Improved compiler diagnostics


#1

A big problem, especially for newcomers, is missing trait impls. While rustc’s error messages are usually very helpful, the messages about missing trait impls are precise but fail to give actionable suggestions on how to best rectify the issue – which of course is impossible in the general case.

However, for many types, there is a known standard way to get a specific trait, and the type could be equipped with meta-information that may be used to augment the error messages.

Imagine having a ReadOnlyFile type with a #[suggest(missing="Write" msg="To get a writeable file, use _.writeable() on the File object right after creation.")] attribute, whosemsg` would show up in the error message.

What do you folks think? What other situations could warrant specialized suggestions based on meta-information?


#2

Don’t we already have https://github.com/rust-lang/rust/pull/20889?

A more general version of that would be nice though.


#3

Ah, I had missed that. This feature appears to be underused and perhaps under-advertised.