Skip to content

Minimize DiagCtxt methods - #162453

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
nnethercote:min-DiagCtxt-methods
Sep 9, 2026
Merged

Minimize DiagCtxt methods#162453
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
nnethercote:min-DiagCtxt-methods

Conversation

@nnethercote

Copy link
Copy Markdown
Contributor

We have DiagCtxt, DiagCtxtInner, and DiagCtxtHandle. They're all necessary, but the method placement is inconsistent. This commit establishes a clearer rule: methods should not go on DiagCtxt whenever possible.

Benefits:

  • Simpler rule for deciding where to put a method.

  • impl Deref for DiagCtxtHandle can be removed, including its non-standard double-reference &&'a DiagCtxt return value. This makes it impossible to accidentally discard a taint target by calling handle on a DiagCtxtHandle.

  • Catches some places where we were calling dcx.handle() when dcx was already a handle.

r? @oli-obk

We have `DiagCtxt`, `DiagCtxtInner`, and `DiagCtxtHandle`. They're all
necessary, but the method placement is inconsistent. This commit
establishes a clearer rule: methods should *not* go on `DiagCtxt`
whenever possible.

Benefits:

- Simpler rule for deciding where to put a method.

- `impl Deref for DiagCtxtHandle` can be removed, including its
  non-standard double-reference `&&'a DiagCtxt` return value.
  This makes it impossible to accidentally discard a taint target by
  calling `handle` on a `DiagCtxtHandle`.

- Catches some places where we were calling `dcx.handle()` when `dcx`
  was already a handle.
@rustbot

rustbot commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

clippy is developed in its own repository. If possible, consider making this change to rust-lang/rust-clippy instead.

cc @rust-lang/clippy

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 8, 2026
@nnethercote

Copy link
Copy Markdown
Contributor Author

LLM disclosure: this PR is partially based on suggestions from an LLM. I made all the code and text changes myself.

@oli-obk oli-obk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@rust-bors

rust-bors Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

📌 Commit d571cae has been approved by oli-obk

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 9, 2026
Zalathar added a commit to Zalathar/rust that referenced this pull request Sep 9, 2026
…r=oli-obk

Minimize `DiagCtxt` methods

We have `DiagCtxt`, `DiagCtxtInner`, and `DiagCtxtHandle`. They're all necessary, but the method placement is inconsistent. This commit establishes a clearer rule: methods should *not* go on `DiagCtxt` whenever possible.

Benefits:

- Simpler rule for deciding where to put a method.

- `impl Deref for DiagCtxtHandle` can be removed, including its non-standard double-reference `&&'a DiagCtxt` return value. This makes it impossible to accidentally discard a taint target by calling `handle` on a `DiagCtxtHandle`.

- Catches some places where we were calling `dcx.handle()` when `dcx` was already a handle.

r? @oli-obk
rust-bors Bot pushed a commit that referenced this pull request Sep 9, 2026
…uwer

Rollup of 5 pull requests

Successful merges:

 - #162470 (Subtree sync for rustc_codegen_cranelift)
 - #161734 (miri: enforce proper types for c-variadic arguments in shims)
 - #161821 (Add missing option to `-Zself-profile-event` help message as well as information about what the default options are)
 - #162453 (Minimize `DiagCtxt` methods)
 - #162528 (Add a mention to docs about promoting and demoting platform support)
@rust-bors
rust-bors Bot merged commit 82ffd1c into rust-lang:main Sep 9, 2026
13 checks passed
@rustbot rustbot added this to the 1.100.0 milestone Sep 9, 2026
rust-bors Bot pushed a commit that referenced this pull request Sep 9, 2026
Rollup merge of #162453 - nnethercote:min-DiagCtxt-methods, r=oli-obk

Minimize `DiagCtxt` methods

We have `DiagCtxt`, `DiagCtxtInner`, and `DiagCtxtHandle`. They're all necessary, but the method placement is inconsistent. This commit establishes a clearer rule: methods should *not* go on `DiagCtxt` whenever possible.

Benefits:

- Simpler rule for deciding where to put a method.

- `impl Deref for DiagCtxtHandle` can be removed, including its non-standard double-reference `&&'a DiagCtxt` return value. This makes it impossible to accidentally discard a taint target by calling `handle` on a `DiagCtxtHandle`.

- Catches some places where we were calling `dcx.handle()` when `dcx` was already a handle.

r? @oli-obk
@nnethercote
nnethercote deleted the min-DiagCtxt-methods branch September 9, 2026 19:59
pull Bot pushed a commit to xtqqczze/rust-lang-miri that referenced this pull request Sep 10, 2026
…uwer

Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#162470 (Subtree sync for rustc_codegen_cranelift)
 - rust-lang/rust#161734 (miri: enforce proper types for c-variadic arguments in shims)
 - rust-lang/rust#161821 (Add missing option to `-Zself-profile-event` help message as well as information about what the default options are)
 - rust-lang/rust#162453 (Minimize `DiagCtxt` methods)
 - rust-lang/rust#162528 (Add a mention to docs about promoting and demoting platform support)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants