Skip to content

Simplify type_of_opaque.#153581

Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
nnethercote:rm-cycle_stash
Mar 12, 2026
Merged

Simplify type_of_opaque.#153581
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
nnethercote:rm-cycle_stash

Conversation

@nnethercote
Copy link
Contributor

There is a bunch of complexity supporting the "cannot check whether the hidden type of opaque type satisfies auto traits" error that shows up in tests/ui/impl-trait/auto-trait-leak.rs. This is an obscure error that shows up in a single test. If we are willing to downgrade that error message to a cycle error, we can do the following.

  • Simplify the type_of_opaque return value.
  • Remove the cycle_stash query modifier.
  • Remove the CyclePlaceholder type.
  • Remove the SelectionError::OpaqueTypeAutoTraitLeakageUnknown variant.
  • Remove a FromCycleError impl.
  • Remove report_opaque_type_auto_trait_leakage.
  • Remove the StashKey::Cycle variant.
  • Remove the CycleErrorHandling::Stash variant.

That's a lot! I think this is a worthwhile trade-off.

r? @oli-obk

@rustbot rustbot added A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) 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 9, 2026
@rustbot
Copy link
Collaborator

rustbot commented Mar 9, 2026

oli-obk is not on the review rotation at the moment.
They may take a while to respond.

@nnethercote
Copy link
Contributor Author

cc @Zoxc @Zalathar @zetanumbers

This overlaps with #153247, and implements the suggestion in this comment. Zoxc gave me the go ahead to take this over via Zulip DM.

Copy link
Contributor

@zetanumbers zetanumbers Mar 10, 2026

Choose a reason for hiding this comment

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

This new error message is a mouthful. As a C++ refuge I don't like this length of a diagnostic. Is there no way to keep it more tight?

Copy link
Contributor

Choose a reason for hiding this comment

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

That's a general cycle error problem. We should def tackle it, but lots of ppl have different opinions here so we need to likely cook up some PRs of variants and then start a discussion

Copy link
Contributor

Choose a reason for hiding this comment

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

Very well then

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it makes sense to replace multiple steps in the cycle error with single step that better represents the cycle in the source code.

The formatting of the error could be improved too, it should be a list, not notes.

@oli-obk
Copy link
Contributor

oli-obk commented Mar 11, 2026

@bors r+

@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 11, 2026

📌 Commit 45a010c 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 Mar 11, 2026
tcx: TyCtxt<'_>,
def_id: DefId,
) -> Result<ty::EarlyBinder<'_, Ty<'_>>, CyclePlaceholder> {
pub(super) fn type_of_opaque(tcx: TyCtxt<'_>, def_id: DefId) -> ty::EarlyBinder<'_, Ty<'_>> {
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if it makes sense to move it back into type_of now, but that can be experimented with in a separate PR

@rust-bors rust-bors bot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Mar 11, 2026
@rust-bors

This comment has been minimized.

@rust-bors rust-bors bot removed the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Mar 11, 2026
@zetanumbers
Copy link
Contributor

This PR basically just removes no longer used parts of query cycle handling, so it should be fine. Although I very briefly looked at the trait selection changes.

There is a bunch of complexity supporting the "cannot check whether the
hidden type of opaque type satisfies auto traits" error that shows up in
`tests/ui/impl-trait/auto-trait-leak.rs`. This is an obscure error that
shows up in a single test. If we are willing to downgrade that error
message to a cycle error, we can do the following.

- Simplify the `type_of_opaque` return value.
- Remove the `cycle_stash` query modifier.
- Remove the `CyclePlaceholder` type.
- Remove the `SelectionError::OpaqueTypeAutoTraitLeakageUnknown`
  variant.
- Remove a `FromCycleError` impl.
- Remove `report_opaque_type_auto_trait_leakage`.
- Remove the `StashKey::Cycle` variant.
- Remove the `CycleErrorHandling::Stash` variant.

That's a lot! I think this is a worthwhile trade-off.
@rustbot
Copy link
Collaborator

rustbot commented Mar 11, 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.

@nnethercote
Copy link
Contributor Author

I rebased.

@bors r=oli-obk

@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 11, 2026

📌 Commit 3399ed3 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 11, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Mar 11, 2026
Simplify `type_of_opaque`.

There is a bunch of complexity supporting the "cannot check whether the hidden type of opaque type satisfies auto traits" error that shows up in `tests/ui/impl-trait/auto-trait-leak.rs`. This is an obscure error that shows up in a single test. If we are willing to downgrade that error message to a cycle error, we can do the following.

- Simplify the `type_of_opaque` return value.
- Remove the `cycle_stash` query modifier.
- Remove the `CyclePlaceholder` type.
- Remove the `SelectionError::OpaqueTypeAutoTraitLeakageUnknown` variant.
- Remove a `FromCycleError` impl.
- Remove `report_opaque_type_auto_trait_leakage`.
- Remove the `StashKey::Cycle` variant.
- Remove the `CycleErrorHandling::Stash` variant.

That's a lot! I think this is a worthwhile trade-off.

r? @oli-obk
rust-bors bot pushed a commit that referenced this pull request Mar 11, 2026
…uwer

Rollup of 4 pull requests

Successful merges:

 - #153571 (Avoid ICE when an EII declaration conflicts with a constructor)
 - #153581 (Simplify `type_of_opaque`.)
 - #153685 (Introduce `for_each_query_vtable!` to move more code out of query macros)
 - #153710 (remove `.ftl` checks from tidy)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Mar 11, 2026
Simplify `type_of_opaque`.

There is a bunch of complexity supporting the "cannot check whether the hidden type of opaque type satisfies auto traits" error that shows up in `tests/ui/impl-trait/auto-trait-leak.rs`. This is an obscure error that shows up in a single test. If we are willing to downgrade that error message to a cycle error, we can do the following.

- Simplify the `type_of_opaque` return value.
- Remove the `cycle_stash` query modifier.
- Remove the `CyclePlaceholder` type.
- Remove the `SelectionError::OpaqueTypeAutoTraitLeakageUnknown` variant.
- Remove a `FromCycleError` impl.
- Remove `report_opaque_type_auto_trait_leakage`.
- Remove the `StashKey::Cycle` variant.
- Remove the `CycleErrorHandling::Stash` variant.

That's a lot! I think this is a worthwhile trade-off.

r? @oli-obk
rust-bors bot pushed a commit that referenced this pull request Mar 11, 2026
…uwer

Rollup of 9 pull requests

Successful merges:

 - #153571 (Avoid ICE when an EII declaration conflicts with a constructor)
 - #153581 (Simplify `type_of_opaque`.)
 - #153611 (interpret: go back to regular string interpolation for error messages)
 - #153635 (Unify same-span labels in move error diagnostics)
 - #153660 (mir-opt: Drop invalid debuginfos after SingleUseConsts.)
 - #153685 (Introduce `for_each_query_vtable!` to move more code out of query macros)
 - #153671 (Make Enzyme has dependent on LLVM hash)
 - #153710 (remove `.ftl` checks from tidy)
 - #153720 (doc/rustc: clarify how to contact arm-maintainers)
rust-bors bot pushed a commit that referenced this pull request Mar 11, 2026
…uwer

Rollup of 9 pull requests

Successful merges:

 - #153571 (Avoid ICE when an EII declaration conflicts with a constructor)
 - #153581 (Simplify `type_of_opaque`.)
 - #153611 (interpret: go back to regular string interpolation for error messages)
 - #153635 (Unify same-span labels in move error diagnostics)
 - #153660 (mir-opt: Drop invalid debuginfos after SingleUseConsts.)
 - #153685 (Introduce `for_each_query_vtable!` to move more code out of query macros)
 - #153671 (Make Enzyme has dependent on LLVM hash)
 - #153710 (remove `.ftl` checks from tidy)
 - #153720 (doc/rustc: clarify how to contact arm-maintainers)
rust-bors bot pushed a commit that referenced this pull request Mar 11, 2026
…uwer

Rollup of 9 pull requests

Successful merges:

 - #153571 (Avoid ICE when an EII declaration conflicts with a constructor)
 - #153581 (Simplify `type_of_opaque`.)
 - #153611 (interpret: go back to regular string interpolation for error messages)
 - #153635 (Unify same-span labels in move error diagnostics)
 - #153660 (mir-opt: Drop invalid debuginfos after SingleUseConsts.)
 - #153685 (Introduce `for_each_query_vtable!` to move more code out of query macros)
 - #153671 (Make Enzyme has dependent on LLVM hash)
 - #153710 (remove `.ftl` checks from tidy)
 - #153720 (doc/rustc: clarify how to contact arm-maintainers)
rust-bors bot pushed a commit that referenced this pull request Mar 11, 2026
…uwer

Rollup of 12 pull requests

Successful merges:

 - #152569 (Stop using rustc_layout_scalar_valid_range_* in rustc)
 - #153421 (Fix ICE in fn_delegation when child segment resolves to a trait)
 - #153571 (Avoid ICE when an EII declaration conflicts with a constructor)
 - #153581 (Simplify `type_of_opaque`.)
 - #153611 (interpret: go back to regular string interpolation for error messages)
 - #153635 (Unify same-span labels in move error diagnostics)
 - #153660 (mir-opt: Drop invalid debuginfos after SingleUseConsts.)
 - #153685 (Introduce `for_each_query_vtable!` to move more code out of query macros)
 - #153722 (miri-test-libstd: use --tests and update some comments)
 - #153671 (Make Enzyme has dependent on LLVM hash)
 - #153710 (remove `.ftl` checks from tidy)
 - #153720 (doc/rustc: clarify how to contact arm-maintainers)
@rust-bors rust-bors bot merged commit 4e64a8b into rust-lang:main Mar 12, 2026
11 checks passed
@rustbot rustbot added this to the 1.96.0 milestone Mar 12, 2026
@nnethercote nnethercote deleted the rm-cycle_stash branch March 12, 2026 01:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

5 participants