-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't require specifying unrelated assoc types when trait alias is in dyn
type
#122123
Don't require specifying unrelated assoc types when trait alias is in dyn
type
#122123
Conversation
| | | | ||
| | 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>` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a meaningless suggestion, but also I don't particularly care 😆 this test was only committed because it used to ICE.
@@ -127,7 +127,7 @@ impl<'tcx> TraitAliasExpander<'tcx> { | |||
} | |||
|
|||
// 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()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we're elaborating correctly, we don't need to filter these anymore.
@@ -158,7 +156,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { | |||
|
|||
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() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Elaborate supertraits only.
@@ -83,9 +82,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { | |||
let expanded_traits = | |||
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we're elaborating correctly, we don't need to filter these anymore.
@bors r+ rollup |
…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
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
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