-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Diagnostics] Introduce "Educational Notes" for diagnostics #28052
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@swift-ci please test |
Hi @shahmishal , I recently got commit access but don't seem to be able to trigger the CI yet. Do you mind taking a look when you have a chance? |
@swift-ci please test |
Looking into this |
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.
Good start, but let's think about some things at the outset.
cccfe67
to
33bf0f6
Compare
Educational notes are small pieces of documentation which explain a concept relevant to some diagnostic message. If -enable-descriptive-diagnostics is passed, they will be printed after a diagnostic message if available. Educational notes can be found at /usr/share/doc/diagnostics in a toolchain, and are associated with specific compiler diagnostics in EducationalNotes.def.
33bf0f6
to
7b025d7
Compare
I added a high level overview of the feature to |
@swift-ci please test |
This comment has been minimized.
This comment has been minimized.
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.
Found a tiny grammar error, but I'm sure you'll fix that. Otherwise, looks like a good start.
Build failed |
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.
This is really cool, thank you for pushing it forward!
7b025d7
to
da7e1ca
Compare
@swift-ci please smoke test |
@shahmishal sorry to ping again, but were you able to figure out this issue? |
@swift-ci please smoke test |
This seems to have broken the build on Windows: https://dev.azure.com/compnerd/windows-swift/_build/results?buildId=13763&view=logs&j=b9e62f99-1a98-5ed7-01d2-f4794231ed79&t=9d1c7fdf-e7ea-5e83-bbfd-5e0708569c31&l=4917 |
Educational notes are small pieces of documentation which explain a concept
relevant to some diagnostic message. If -enable-descriptive-diagnostics is
passed, they will be printed after a diagnostic message if available.
Educational notes can be found at /usr/share/doc/diagnostics in a
toolchain, and are associated with specific compiler diagnostics in
EducationalNotes.def.
This is my first pass at implementing the feature as described here. The terminal UX has plenty of room for improvement, but this is gated behind
-Xfrontend -enable-descriptive-diagnostics
so that shouldn't be an issue for now. As a proof of concept I added a note explaining the difference between nominal and non-nominal types inspired by the many related questions on Stack Overflow and Brent's excellent answer here. Once this lands I plan on putting together some style guidelines before adding any more.A couple of notes on the approach I took here:
usr/share/doc
in the toolchain. I picked this because it seemed to match Unix conventions and there didn't seem to be an existing location for this kind of contentEducationalNotes.def
instead of the existingDiagnostics*.def
files for now. This avoids some nasty macro usage and preserves git history better. I'm starting to think about migrating diagnostic definitions to TableGen at some point though, they're becoming difficult to maintain...