Skip to content

RFC: (Re)standardise error code documentation#3370

Open
Ezrashaw wants to merge 2 commits intorust-lang:masterfrom
Ezrashaw:add-standardize-error-docs-rfc
Open

RFC: (Re)standardise error code documentation#3370
Ezrashaw wants to merge 2 commits intorust-lang:masterfrom
Ezrashaw:add-standardize-error-docs-rfc

Conversation

@Ezrashaw
Copy link

@Ezrashaw Ezrashaw commented Jan 12, 2023

(Re)-standardize long-form error code explanations (referred to in this RFC as "error docs") with a more flexible system that also takes into account new errors which do not fit into the format as defined by RFC 1567. This RFC replaces RFC 1567 as the primary specification for error docs. This RFC ultimately wishes to make error docs more accessible and easy to read for both new and proficient Rust users.

Some discussion also occurred on Zulip here.

The devtools teams (as referenced in the RFC) is not the correct team to handle changes to the proposed "style spec". It is unclear which team would maintain this, that should be decided before this is accepted (everything else I'm happy with).

cc @GuillaumeGomez @ehuss @rylev @calebcartwright (from Zulip)

Rendered

@Ezrashaw Ezrashaw changed the title add standardize-error-docs RFC RFC: add standardize-error-docs RFC Jan 12, 2023
@Ezrashaw Ezrashaw changed the title RFC: add standardize-error-docs RFC RFC: (Re)standardise error code documentation Jan 12, 2023

This RFC makes three changes to error docs in order to fulfill this RFC's (and [RFC 1567]'s) goals:

- Firstly, that the style of error docs is not defined by RFC but by a "style spec" located in the `rust-lang/rust` repository. This style spec can be updated from time-to-time in order to ensure consistent formatting across error docs. Any change to the style spec must be with the consensus of the dev-tools team. It is recommended that the style spec is initially extracted from [RFC 1567].
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth giving the path to the style spec.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, should we put it in compiler/rustc_error_codes/STYLE_SPEC.md?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just realized that it doesn't exist yet. Question for other reviewers: should this style spec be written before this RFC is merged or after is fine?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, should we put it in compiler/rustc_error_codes/STYLE_SPEC.md?

That seems like a good idea.

[unresolved-questions]: #unresolved-questions

- Is the current `mdBook` format used to present error docs still sufficient? Its index page is very unappealing and makes it hard to quickly jump to an error. Furthermore, it does not interface well with the new idea of error doc labels and cannot quickly show labels applied to an error.
- Should changes to the style spec require more or less than "dev-tools team consensus"?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's actually two questions:

  1. Should changes to the style spec require more or less a "team" consensus?
  2. Which team should be in charge of error codes?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Hmm, perhaps a good standard would be "changes that would in turn require modifications to the docs" (so then spelling changes, etc to the spec would be fine)?

  2. As for the team, I obviously agree that dev-tools is wrong. I also am somewhat opposed to wg-diagnostics having anything to do with it, they seem focused on changes to error messages themselves, no docs. Worst case, the docs team is reformed or something.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the docs team is reformed or something.

It's complicated. ^^'

# Rationale and alternatives
[rationale-and-alternatives]: #rationale-and-alternatives

Some changes must be made, otherwise PR authors coming up with their own formatting for error docs will continue to increase. *This is already happening* and only makes error docs harder to understand.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem here is that we need a better way to "split" the error code explanation. For example have the following parts well defined:

  1. Short explanation
  2. Erroneous code example
  3. Long explanation of what's going on
  4. (optional) How to fix it
  5. (optional) Fixed code example

If we have a format that forces to follow this, it'd be much simpler.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, obviously this gets more complex when you bring in code examples that involve multiple crates, feature gates, etc. Also things like defining where the error is with comments (like UI tests) is a bit nonstandard.

Hopefully one day I can have some fun with a finite-state machine parser in tidy :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, since you're adding labels, we can also add labels for parts. That would make it much simpler.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite get it? Labels are optional attributes for certain error codes (like real Rust attributes) whereas that sounds more mandatory (like trait impls) with more internal compiler maintenance, not just a style spec.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The primary goal of this RFC is to enforce a style on the error code explanations/ You suggested to add labels to know the "kind" of the error code. We can go even further and even force to have specific sections that can be checked with tidy to prevent having multiple styles (or at least limit it even more).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, as mentioned in the RFC, tidy linting is a important part of this. I'm not sure about expanding labels like this. Not opposed, just need to think about it for a bit.

@Ezrashaw
Copy link
Author

@GuillaumeGomez I've applied one of your suggestions, I think the rest are more unresolved questions. I also have a initial style spec, pulled from RFC 1567, ready to PR on the main repo if you want.

@GuillaumeGomez
Copy link
Member

RFC looks good to me, thanks for writing it! I'm not sure what happens for the RFC approval and merge now though.

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.

2 participants