Closed
Description
I’m using rustc 1.33.0-nightly (a2b0f247b 2018-12-30)
.
trait MyTrait {
type Item;
}
struct MyStruct<T> {
item: T
}
impl<T> MyTrait for MyStruct<T> {
type Item = T;
}
fn func<T: MyTrait<Item=i32>>(t: T) { }
fn main() {
func(MyStruct { item: "str" });
}
func
expects an MyTrait<Item=i32>
, so the error message should say: “expected type i32
, found type &str
.” Instead, they’re interchanged and it says:
error[E0271]: type mismatch resolving `<MyStruct<&str> as MyTrait>::Item == i32`
--> src/main.rs:17:5
|
17 | func(my_struct);
| ^^^^ expected &str, found i32
|
= note: expected type `&str`
found type `i32`
note: required by `func`
--> src/main.rs:13:1
|
13 | fn func<T: MyTrait<Item=i32>>(t: T) { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^