-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
149bd87
commit c591475
Showing
4 changed files
with
81 additions
and
0 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
28 changes: 28 additions & 0 deletions
28
tests/ui/associated-type-bounds/nested-associated-type-bound-incompleteness.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,28 @@ | ||
// Demonstrates a mostly-theoretical inference guidance now that we turn the where | ||
// clause on `Trait` into an item bound, given that we prefer item bounds somewhat | ||
// greedily in trait selection. | ||
|
||
trait Bound<T> {} | ||
impl<T, U> Bound<T> for U {} | ||
|
||
trait Trait | ||
where | ||
<<Self as Trait>::Assoc as Other>::Assoc: Bound<u32>, | ||
{ | ||
type Assoc: Other; | ||
} | ||
|
||
trait Other { | ||
type Assoc; | ||
} | ||
|
||
fn impls_trait<T: Bound<U>, U>() -> Vec<U> { vec![] } | ||
|
||
fn foo<T: Trait>() { | ||
let mut vec_u = impls_trait::<<<T as Trait>::Assoc as Other>::Assoc, _>(); | ||
vec_u.sort(); | ||
drop::<Vec<u8>>(vec_u); | ||
//~^ ERROR mismatched types | ||
} | ||
|
||
fn main() {} |
16 changes: 16 additions & 0 deletions
16
tests/ui/associated-type-bounds/nested-associated-type-bound-incompleteness.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/nested-associated-type-bound-incompleteness.rs:24:21 | ||
| | ||
LL | drop::<Vec<u8>>(vec_u); | ||
| --------------- ^^^^^ expected `Vec<u8>`, found `Vec<u32>` | ||
| | | ||
| arguments to this function are incorrect | ||
| | ||
= note: expected struct `Vec<u8>` | ||
found struct `Vec<u32>` | ||
note: function defined here | ||
--> $SRC_DIR/core/src/mem/mod.rs:LL:COL | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0308`. |
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,31 @@ | ||
//@ check-pass | ||
|
||
trait Trait | ||
where | ||
for<'a> Self::Gat<'a>: OtherTrait, | ||
for<'a, 'b, 'c> <Self::Gat<'a> as OtherTrait>::OtherGat<'b>: HigherRanked<'c>, | ||
{ | ||
type Gat<'a>; | ||
} | ||
|
||
trait OtherTrait { | ||
type OtherGat<'b>; | ||
} | ||
|
||
trait HigherRanked<'c> {} | ||
|
||
fn lower_ranked<T: for<'b, 'c> OtherTrait<OtherGat<'b>: HigherRanked<'c>>>() {} | ||
|
||
fn higher_ranked<T: Trait>() | ||
where | ||
for<'a> T::Gat<'a>: OtherTrait, | ||
for<'a, 'b, 'c> <T::Gat<'a> as OtherTrait>::OtherGat<'b>: HigherRanked<'c>, | ||
{ | ||
} | ||
|
||
fn test<T: Trait>() { | ||
lower_ranked::<T::Gat<'_>>(); | ||
higher_ranked::<T>(); | ||
} | ||
|
||
fn main() {} |