Skip to content
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

Consistent Handler naming #699

Closed
3 tasks done
nnethercote opened this issue Dec 4, 2023 · 5 comments
Closed
3 tasks done

Consistent Handler naming #699

nnethercote opened this issue Dec 4, 2023 · 5 comments
Labels
major-change A proposal to make a major change to rustc major-change-accepted A major change proposal that was accepted T-compiler Add this label so rfcbot knows to poll the compiler team

Comments

@nnethercote
Copy link

nnethercote commented Dec 4, 2023

Proposal

rustc diagnostics are issued through the Handler type. There are some problems.

  • Handler isn't a good name. It's not descriptive, it could be used for almost anything.
  • Fields/functions/arguments/locals of type Handler have many different names: span_diagnostic, diagnostic, sd, diag_handler, err_handler, and occasionally, handler. These names occur a lot. I suspect the heavy use of diagnostic/diag is for historical reasons, and made more sense in the past. But today, diag/diagnostic is heavily used for Diagnostics and DiagnosticBuilders, so is a poor choice for Handler things.
  • EarlyErrorHandler is a more descriptive name than Handler, but is quite long. Plus "Diagnostic" would be better than "Error", given that it issues non-error diagnostics such as warnings.
  • handler is used for values of type EarlyErrorHandler, but that potentially overlaps with values of type Handler, and there are some functions with both a Handler and an EarlyErrorHandler in scope.

After some discussion on Zulip, the proposal is to rename the following types:

  • HandlerDiagCtxt
  • HandlerInnerDiagCtxtInner
  • EarlyErrorHandlerEarlyDiagCtxt
  • HandlerFlagsDiagCtxtFlags

And the following non-types:

  • ParseSess: span_diagnosticdcx
  • Session: diagnostic()dcx()
  • Parser: diagnostic()dcx()
  • ParseSess: with_span_handler()with_dcx()
  • AstValidator: err_handler()dcx()
  • ShowSpanVisitor: span_diagnosticdcx
  • CodegenContext: create_diag_handler()create_dcx()
  • UnstableOptions: diagnostic_handler_flags()dcx_flags()
  • SilentEmitter::fatal_handlerfatal_dcx
  • new_handler()new_dcx()
  • default_handler() -> default_dcx()
  • Locals/args/fields: {diag,diagnostic,span_diagnostic,sd,diag_handler,handler}dcx (for Handler values)
  • Locals/args/fields: handlerearly_dcx (for EarlyErrorHandler values)
  • '__diagnostic_handler_sess'sess

(This is an exhaustive list, or very close to one.)

DiagCtxt/dcx are more descriptive names than Handler/handler, and mirror names like TyCtxt/tcx. They are also short, which is good for these names which are used a lot.

Alternatives

DiagCx/EarlyDiagCx are also possible for the type names, and would match types like FunctionCx, CodegenCx.

Mentors or Reviewers

I can do the work; as mentioned above, I already have a draft implementation.

@compiler-errors or @estebank might be suitable reviewers.

Process

The main points of the Major Change Process are as follows:

  • File an issue describing the proposal.
  • A compiler team member or contributor who is knowledgeable in the area can second by writing @rustbot second.
    • Finding a "second" suffices for internal changes. If however, you are proposing a new public-facing feature, such as a -C flag, then full team check-off is required.
    • Compiler team members can initiate a check-off via @rfcbot fcp merge on either the MCP or the PR.
  • Once an MCP is seconded, the Final Comment Period begins. If no objections are raised after 10 days, the MCP is considered approved.

You can read more about Major Change Proposals on forge.

Comments

This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.

@nnethercote nnethercote added T-compiler Add this label so rfcbot knows to poll the compiler team major-change A proposal to make a major change to rustc labels Dec 4, 2023
@rustbot
Copy link
Collaborator

rustbot commented Dec 4, 2023

This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.

cc @rust-lang/compiler @rust-lang/compiler-contributors

@rustbot rustbot added the to-announce Announce this issue on triage meeting label Dec 4, 2023
@davidtwco
Copy link
Member

@rustbot second

@rustbot rustbot added the final-comment-period The FCP has started, most (if not all) team members are in agreement label Dec 6, 2023
@apiraino apiraino removed the to-announce Announce this issue on triage meeting label Dec 12, 2023
@nnethercote
Copy link
Author

nnethercote commented Dec 18, 2023

Ten days have passed without objection. I have made the changes in rust-lang/rust#119063.

bors added a commit to rust-lang-ci/rust that referenced this issue Dec 18, 2023
Consistent `Handler` naming

This PR implements the renaming described in rust-lang/compiler-team#699.

r? `@compiler-errors`
@nnethercote
Copy link
Author

nnethercote commented Dec 18, 2023

rust-lang/rust#119063 has merged.

@apiraino
Copy link
Contributor

@rustbot label -final-comment-period +major-change-accepted

@rustbot rustbot added major-change-accepted A major change proposal that was accepted to-announce Announce this issue on triage meeting and removed final-comment-period The FCP has started, most (if not all) team members are in agreement labels Dec 18, 2023
github-actions bot pushed a commit to rust-lang/miri that referenced this issue Dec 19, 2023
Consistent `Handler` naming

This PR implements the renaming described in rust-lang/compiler-team#699.

r? `@compiler-errors`
@apiraino apiraino removed the to-announce Announce this issue on triage meeting label Dec 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
major-change A proposal to make a major change to rustc major-change-accepted A major change proposal that was accepted T-compiler Add this label so rfcbot knows to poll the compiler team
Projects
None yet
Development

No branches or pull requests

4 participants