Minimize DiagCtxt methods - #162453
Merged
Merged
Conversation
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.
Collaborator
|
cc @rust-lang/clippy |
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
approved these changes
Sep 9, 2026
Contributor
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 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
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We have
DiagCtxt,DiagCtxtInner, andDiagCtxtHandle. They're all necessary, but the method placement is inconsistent. This commit establishes a clearer rule: methods should not go onDiagCtxtwhenever possible.Benefits:
Simpler rule for deciding where to put a method.
impl Deref for DiagCtxtHandlecan be removed, including its non-standard double-reference&&'a DiagCtxtreturn value. This makes it impossible to accidentally discard a taint target by callinghandleon aDiagCtxtHandle.Catches some places where we were calling
dcx.handle()whendcxwas already a handle.r? @oli-obk