Skip to content

“expected” and “found” interchanged in error message E0308 #57226

@gralpli

Description

@gralpli

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) { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsD-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions