forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
4 changed files
with
55 additions
and
50 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
7 changes: 2 additions & 5 deletions
7
tests/ui/associated-type-bounds/overlaping-bound-suggestion.stderr
This file contains 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
16 changes: 16 additions & 0 deletions
16
tests/ui/traits/alias/only-require-assocs-from-supertraits.rs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
//@ check-pass | ||
|
||
#![feature(trait_alias)] | ||
|
||
trait Foo<T> {} | ||
trait Bar { type Assoc; } | ||
|
||
trait Alias<T: Bar> = Foo<T>; | ||
|
||
// Check that an alias only requires us to specify the associated types | ||
// of the principal's supertraits. For example, we shouldn't require | ||
// specifying the type `Assoc` on trait `Bar` just because we have some | ||
// `T: Bar` where clause on the alias... because that makes no sense. | ||
fn use_alias<T: Bar>(x: &dyn Alias<T>) {} | ||
|
||
fn main() {} |