Skip to content

[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

Merged
merged 2 commits into from
Nov 8, 2019

Conversation

owenv
Copy link
Contributor

@owenv owenv commented Nov 4, 2019

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:

  • The documentation content is installed in a subdirectory of 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 content
  • I chose to associate educational notes with diags in EducationalNotes.def instead of the existing Diagnostics*.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...

@owenv
Copy link
Contributor Author

owenv commented Nov 4, 2019

@swift-ci please test

@owenv
Copy link
Contributor Author

owenv commented Nov 4, 2019

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?

@hamishknight
Copy link
Contributor

@swift-ci please test

@shahmishal
Copy link
Member

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?

Looking into this

@owenv owenv requested a review from xedin November 4, 2019 20:41
Copy link
Contributor

@beccadax beccadax left a 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.

@owenv owenv force-pushed the educational-notes branch from cccfe67 to 33bf0f6 Compare November 5, 2019 16:17
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.
@owenv owenv force-pushed the educational-notes branch from 33bf0f6 to 7b025d7 Compare November 7, 2019 21:19
@owenv
Copy link
Contributor Author

owenv commented Nov 7, 2019

I added a high level overview of the feature to Diagnostics.md which includes some basic guidelines for writing these notes, with the caveat that everything is still experimental and subject to change.

@beccadax
Copy link
Contributor

beccadax commented Nov 8, 2019

@swift-ci please test

@swift-ci

This comment has been minimized.

Copy link
Contributor

@beccadax beccadax left a 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.

@swift-ci
Copy link
Contributor

swift-ci commented Nov 8, 2019

Build failed
Swift Test Linux Platform
Git Sha - cccfe67a697d4a335ba3e44cf5c0c6088582f2e1

Copy link
Member

@DougGregor DougGregor left a 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!

@owenv owenv force-pushed the educational-notes branch from 7b025d7 to da7e1ca Compare November 8, 2019 17:08
@owenv
Copy link
Contributor Author

owenv commented Nov 8, 2019

@swift-ci please smoke test

@owenv
Copy link
Contributor Author

owenv commented Nov 8, 2019

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?

Looking into this

@shahmishal sorry to ping again, but were you able to figure out this issue?

@theblixguy
Copy link
Collaborator

@swift-ci please smoke test

@compnerd
Copy link
Member

compnerd commented Nov 9, 2019

@owenv
Copy link
Contributor Author

owenv commented Nov 9, 2019

@compnerd #28170 is tracking a potential fix but is running into some Clang/MSVC compatibility issues. I have #28176 open to revert which might be best at this point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants