Skip to content

Invert dependency between rustc_errors and rustc_abi.#154449

Open
nnethercote wants to merge 2 commits intorust-lang:mainfrom
nnethercote:rustc_errors-dep-rustc_abi
Open

Invert dependency between rustc_errors and rustc_abi.#154449
nnethercote wants to merge 2 commits intorust-lang:mainfrom
nnethercote:rustc_errors-dep-rustc_abi

Conversation

@nnethercote
Copy link
Copy Markdown
Contributor

@nnethercote nnethercote commented Mar 27, 2026

Currently, rustc_errors depends on rustc_abi, which depends on rustc_error_messages. This is a bit odd.

rustc_errors depends on rustc_abi for a single reason: rustc_abi defines a type TargetDataLayoutErrors and rustc_errors impls Diagnostic for that type.

We can get a more natural relationship by inverting the dependency, moving the Diagnostic trait upstream. Then rustc_abi defines TargetDataLayoutErrors and also impls Diagnostic for it. rustc_errors is already pretty far upstream in the crate graph, it doesn't hurt to push it a little further because errors are a very low-level concept.

r? @davidtwco

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 27, 2026

These commits modify compiler targets.
(See the Target Tier Policy.)

rustc_error_messages was changed

cc @TaKO8Ki

These commits modify the Cargo.lock file. Unintentional changes to Cargo.lock can be introduced when switching branches and rebasing PRs.

If this was unintentional then you should revert the changes before this PR is merged.
Otherwise, you can ignore this comment.

@rustbot rustbot added A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 27, 2026
@rust-log-analyzer

This comment has been minimized.

@nnethercote nnethercote force-pushed the rustc_errors-dep-rustc_abi branch from 650aac9 to 2f9b158 Compare March 27, 2026 03:36
@rust-log-analyzer

This comment has been minimized.

@nnethercote nnethercote force-pushed the rustc_errors-dep-rustc_abi branch from 2f9b158 to 4b44bf0 Compare March 27, 2026 03:42
@nnethercote
Copy link
Copy Markdown
Contributor Author

Partial crate graph, before:
image

And after:
image

I doubt this has any effect on bootstrap times because the relevant crates are quite small.

Currently, `rustc_errors` depends on `rustc_abi`, which depends on
`rustc_error_messages`. This is a bit odd.

`rustc_errors` depends on `rustc_abi` for a single reason: `rustc_abi`
defines a type `TargetDataLayoutErrors` and `rustc_errors` impls
`Diagnostic` for that type.

We can get a more natural relationship by inverting the dependency,
moving the `Diagnostic` trait upstream. Then `rustc_abi` defines
`TargetDataLayoutErrors` and also impls `Diagnostic` for it.
`rustc_errors` is already pretty far upstream in the crate graph, it
doesn't hurt to push it a little further because errors are a very
low-level concept.
Error enum names should not be plural. Even though there are multiple
possible errors, each instance of an error enum describes a single
error. There are dozens of singular error enum names, and only two
plural error enum names. This commit makes them both singular.
@nnethercote nnethercote force-pushed the rustc_errors-dep-rustc_abi branch from 4b44bf0 to 0db4e3a Compare March 30, 2026 03:15
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 30, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. 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.

4 participants