-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Add -Zteach
documentation
#47843
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add -Zteach
documentation
#47843
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
Got a list or things that need Zteach? I'd like to help. I did a large fraction of the extended messages and wished something like this existed back then. (Have some ideas of my own for Zteach which i may try later) |
@Manishearth No list at the moment, I'm just going through the error index looking for explanations that do not need changes to the current diagnostics engine just to get coverage. I think there're are only 3 errors covered at the moment. From my high level look, about 1/3 of all errors do not need any improvement, about 1/3 just need notes added to them and the remaining 1/3 require changes to the diagnostic engine to make it possible to provide sample code, labels on subdiagnostics, etc. I would like to focus on the easy one firsts and get the ball rolling. I'll create an issue with a copy of the index so we can check them out as we add them, separated by difficulty/urgency. Does that sound reasonable? |
if self.tcx.sess.teach(&err.get_code().unwrap()) { | ||
err.note( | ||
"The value of statics and constants must be known at compile time, \ | ||
and they live for the entire lifetime of a program. Creating a boxed \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does the note
code word wrap?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't at the moment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like we should have some -Zteach
UI test cases for these -- or at least some of them, no?
Perhaps we can somehow automate this?
I'm a bit torn here. I like the idea of picking the low-hanging fruit, but I worry that we are going to give people the wrong idea on the overall direction here by hand-coding all the things into the code. I guess I'd be happier if we had some place -- be it an RFC, tracking issue, or internals thread -- where we were discussing the overall direction and plans with At the moment, I tend to think we ought to be working on getting the error strings out of the code, not moving them in. I'd rather see general templates being used. (But I worry maybe it won't give us the flexibility we need.) |
When I was working on the extended error codes we eventually built an issue where we tracked all of the errors. A templating system where you pass something like a hashmap of strings to a template would be nice. |
I envisioned roughly this, except that the parameters would come in two forms:
The spans would be used when constructing snippets or showing code. There are some gaps to fill though, like suggestions, which often require some custom code; but I guess that could be another sort of parameter to be passed in? |
i'd like to shout-out to https://crates.io/crates/handlebars if you're looking for templating, it is exactly
|
Indeed, I had hoped to use |
I'm slightly intrigued by how you envision a given template string to look like. Would it be something like the following?:
|
That's awesome! |
I was hoping we could go so far as to unify everything into a template (including the short-errors). In that case, let me pick a specific sample. Let's say this borrowck error:
I imagine the inputs might be something like:
and hence the invocation might be like:
And then the "short template" might be like:
(I have no idea if that's even remotely valid Handlebars syntax, but hopefully you get the idea.) The
(Note: not suggesting this is a particular good Obviously this format will be a bit tricky. Among other things, there are often "subtle variants" on how messages are presented; for a single error code, we may need the ability to have variants, e.g., E0593_1 and so forth. But this will be needed for translation at some point anyway. And naturally there are optional hints and suggestions; not sure how those would best fit into this scheme. (Also, we probably want to make the "short message" syntax a bit more descriptive, e.g. by just specifying the 'main message' and the labels, so that we can more readily make "mass changes" to the format.) |
Er, I forgot. r=me if we add some a ui test or two =) |
Add extra inline documentation to E0019, E0016, E0013, E0396, E0017, E0018, E0010, E0022, E0030, E0029, E0033, E0026 and E0027.
ed49727
to
6e8281b
Compare
@bors r=nikomatsakis |
📌 Commit 6e8281b has been approved by |
⌛ Testing commit 6e8281bf7427c4b7ef8f62bb9c41a69dc0b6ab50 with merge b816f42db48152433ac28bc6b03299bda04e131b... |
💔 Test failed - status-appveyor |
Legit, the E0583 UI test failed on Windows. The
|
📌 Commit 51f0c0d has been approved by |
Add `-Zteach` documentation Add extra inline documentation to E0019, E0016, E0013, E0396, E0017, E0018, E0010, E0022, E0030, E0029, E0033, E0026 and E0027. Follow up to #47652.
☀️ Test successful - status-appveyor, status-travis |
Add extra inline documentation to E0019, E0016, E0013, E0396, E0017,
E0018, E0010, E0022, E0030, E0029, E0033, E0026 and E0027.
Follow up to #47652.