Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Add the ability to explain error at point #1122
In rust-lang, the compiler can produce clear (and lengthy!) explanations for error messages. For instance:
These explanations are quite useful, especially for beginners, and we should encourage users to look them up. By default, the rust compiler will emit the following message when there are errors with explanations:
We used to have this message as well in the echo area and the error list, but not since we switched to the new JSON parser in #1036, since this specific line is not part of the JSON output.
To remedy that, I added a function to display the explanation for the error under point in an help buffer, in flycheck/flycheck-rust#30. But I don't think many rust users noticed, unless they looked at the source or keep in touch with our pull requests.
This commit adds a new optional checker property,
It also adds an interactive function
I open the PR now so that we can discuss the merits of the feature, as well as the implementation strategy. It already works for Rust as is, but please overlook the specifics of the code yet, as much of the design isn't settled yet.
Here are some points I would like some feedback on:
I don't think that the round trip caused harm, and I'd rather like to avoid mutation unless it's absolutely necessary. Also returning structured data let's us swap the UI for explanations, e.g. iterate over all explanations at point, for instance. That's impossible if we'd just drop the explanations in the buffer.
I've updated the code to get the first error at point that has an
We could also collect all the explanations at point and keep the first one (but that would be wasteful, as in the case of rust-lang, we call
Besides adding docstrings and a line to
I've added a button on the
I updated the corresponding test as well. But I can revert if we only want the binding and not the button on
Let me know if I should add some tests as well.