Simplify type_of_opaque.#153581
Conversation
|
|
|
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. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
|
@bors r+ |
| tcx: TyCtxt<'_>, | ||
| def_id: DefId, | ||
| ) -> Result<ty::EarlyBinder<'_, Ty<'_>>, CyclePlaceholder> { | ||
| pub(super) fn type_of_opaque(tcx: TyCtxt<'_>, def_id: DefId) -> ty::EarlyBinder<'_, Ty<'_>> { |
There was a problem hiding this comment.
I wonder if it makes sense to move it back into type_of now, but that can be experimented with in a separate PR
This comment has been minimized.
This comment has been minimized.
|
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.
45a010c to
3399ed3
Compare
|
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. |
|
I rebased. @bors r=oli-obk |
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
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
…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)
…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)
…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)
…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)
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.type_of_opaquereturn value.cycle_stashquery modifier.CyclePlaceholdertype.SelectionError::OpaqueTypeAutoTraitLeakageUnknownvariant.FromCycleErrorimpl.report_opaque_type_auto_trait_leakage.StashKey::Cyclevariant.CycleErrorHandling::Stashvariant.That's a lot! I think this is a worthwhile trade-off.
r? @oli-obk