Don't require specifying unrelated assoc types when trait alias is in dyn type#122123
Merged
bors merged 1 commit intorust-lang:masterfrom Mar 7, 2024
Merged
Conversation
compiler-errors
commented
Mar 7, 2024
| | | | | ||
| | | associated types `Item`, `IntoIter` must be specified | ||
| | associated types `Item`, `IntoIter` must be specified | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: specify the associated types: `IntoIterator<Item: IntoIterator<Item: >, Item = Type, IntoIter = Type>` |
Contributor
Author
There was a problem hiding this comment.
This is a meaningless suggestion, but also I don't particularly care 😆 this test was only committed because it used to ICE.
|
|
||
| // Get components of trait alias. | ||
| let predicates = tcx.implied_predicates_of(trait_ref.def_id()); | ||
| let predicates = tcx.super_predicates_of(trait_ref.def_id()); |
Contributor
Author
There was a problem hiding this comment.
Only expand trait aliases to their super predicates, not all of their where clauses.
| .iter() | ||
| // We filter out traits that don't have `Self` as their self type above, | ||
| // we need to do the same for projections. | ||
| .filter(|(bound, _)| bound.skip_binder().self_ty() == dummy_self) |
Contributor
Author
There was a problem hiding this comment.
Because we're elaborating correctly, we don't need to filter these anymore.
| for (base_trait_ref, span) in regular_traits_refs_spans { | ||
| let base_pred: ty::Predicate<'tcx> = base_trait_ref.to_predicate(tcx); | ||
| for pred in traits::elaborate(tcx, [base_pred]) { | ||
| for pred in traits::elaborate(tcx, [base_pred]).filter_only_self() { |
Contributor
Author
There was a problem hiding this comment.
Elaborate supertraits only.
| traits::expand_trait_aliases(tcx, trait_bounds.iter().map(|&(a, b)| (a, b))); | ||
|
|
||
| let (mut auto_traits, regular_traits): (Vec<_>, Vec<_>) = expanded_traits | ||
| .filter(|i| i.trait_ref().self_ty().skip_binder() == dummy_self) |
Contributor
Author
There was a problem hiding this comment.
Because we're elaborating correctly, we don't need to filter these anymore.
Contributor
|
@bors r+ rollup |
Collaborator
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Mar 7, 2024
…llaumeGomez Rollup of 10 pull requests Successful merges: - rust-lang#121863 (silence mismatched types errors for implied projections) - rust-lang#122043 (Apply `EarlyBinder` only to `TraitRef` in `ImplTraitHeader`) - rust-lang#122066 (Add proper cfgs for struct HirIdValidator used only with debug-assert) - rust-lang#122104 (Rust is a proper name: rust → Rust) - rust-lang#122110 (Make `x t miri` respect `MIRI_TEMP`) - rust-lang#122114 (Make not finding core a fatal error) - rust-lang#122115 (Cancel parsing ever made during recovery) - rust-lang#122123 (Don't require specifying unrelated assoc types when trait alias is in `dyn` type) - rust-lang#122126 (Fix `tidy --bless` on ̶X̶e̶n̶i̶x̶ Windows) - rust-lang#122129 (Set `RustcDocs` to only run on host) r? `@ghost` `@rustbot` modify labels: rollup
rust-timer
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Mar 7, 2024
Rollup merge of rust-lang#122123 - compiler-errors:object-trait-alias-bounds, r=oli-obk Don't require specifying unrelated assoc types when trait alias is in `dyn` type Object types must specify the associated types for all of the principal trait ref's supertraits. However, we weren't doing elaboration properly, so we incorrectly errored with erroneous suggestions to specify associated types that were unrelated to that principal trait ref. To fix this, use proper supertrait elaboration when expanding trait aliases in `conv_object_ty_poly_trait_ref`. **NOTE**: Please use the ignore-whitespace option when reviewing. This only touches a handful of lines. r? oli-obk or please feel free to reassign. Fixes rust-lang#122118
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.
Object types must specify the associated types for all of the principal trait ref's supertraits. However, we weren't doing elaboration properly, so we incorrectly errored with erroneous suggestions to specify associated types that were unrelated to that principal trait ref. To fix this, use proper supertrait elaboration when expanding trait aliases in
conv_object_ty_poly_trait_ref.NOTE: Please use the ignore-whitespace option when reviewing. This only touches a handful of lines.
r? oli-obk or please feel free to reassign.
Fixes #122118