diff options
| author | Michael Goulet <michael@errs.io> | 2024-03-07 01:32:01 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2024-03-07 01:32:01 +0000 |
| commit | 850cc34da2ec86ae5b84e48a03d6b451b1dcd4d7 (patch) | |
| tree | 22c7354397b1eb371e44d8b8eaa2d8ef0cfaaf70 /tests/ui | |
| parent | 7d3702e472b99be0f5de6608dd87af1df8f99428 (diff) | |
| download | rust-850cc34da2ec86ae5b84e48a03d6b451b1dcd4d7.tar.gz rust-850cc34da2ec86ae5b84e48a03d6b451b1dcd4d7.zip | |
Don't require specifying unrelated assoc types when trait alias is in dyn type
Diffstat (limited to 'tests/ui')
| -rw-r--r-- | tests/ui/associated-type-bounds/overlaping-bound-suggestion.stderr | 7 | ||||
| -rw-r--r-- | tests/ui/traits/alias/only-require-assocs-from-supertraits.rs | 16 |
2 files changed, 18 insertions, 5 deletions
diff --git a/tests/ui/associated-type-bounds/overlaping-bound-suggestion.stderr b/tests/ui/associated-type-bounds/overlaping-bound-suggestion.stderr index 2a308f83731..03d72f2ae2c 100644 --- a/tests/ui/associated-type-bounds/overlaping-bound-suggestion.stderr +++ b/tests/ui/associated-type-bounds/overlaping-bound-suggestion.stderr @@ -1,11 +1,8 @@ -error[E0191]: the value of the associated types `Item`, `Item`, `IntoIter` and `IntoIter` in `IntoIterator` must be specified +error[E0191]: the value of the associated types `Item` and `IntoIter` in `IntoIterator` must be specified --> $DIR/overlaping-bound-suggestion.rs:7:13 | LL | inner: <IntoIterator<Item: IntoIterator<Item: >>::IntoIterator as Item>::Core, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | | - | | 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>` error[E0223]: ambiguous associated type --> $DIR/overlaping-bound-suggestion.rs:7:13 diff --git a/tests/ui/traits/alias/only-require-assocs-from-supertraits.rs b/tests/ui/traits/alias/only-require-assocs-from-supertraits.rs new file mode 100644 index 00000000000..35149fdfba0 --- /dev/null +++ b/tests/ui/traits/alias/only-require-assocs-from-supertraits.rs @@ -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() {} |
