Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

impl Trait error message expected/found order are confusing #68561

Open
nikomatsakis opened this issue Jan 27, 2020 · 0 comments
Open

impl Trait error message expected/found order are confusing #68561

nikomatsakis opened this issue Jan 27, 2020 · 0 comments

Comments

@nikomatsakis
Copy link
Contributor

@nikomatsakis nikomatsakis commented Jan 27, 2020

@jonas-schievink pointed out that the "expected/found" ordering for -> impl trait return types can be quite confusing:

trait Tr {
    type A;
}

impl<A> Tr for A {
    type A = A;
}

fn f() -> impl Tr<A=u8> {
    ()
}

gives

error[E0271]: type mismatch resolving `<() as Tr>::A == u8`
 --> src/lib.rs:9:11
  |
9 | fn f() -> impl Tr<A=u8> {
  |           ^^^^^^^^^^^^^ expected (), found u8
  |
  = note: expected type `()`
             found type `u8`
  = note: the return type of a function must have a statically known size

Additionally, the second note is wrong (() is Sized).

This does not happen when changing the code to use a boxed trait instead (expected and found are in the right order).

Originally posted by @jonas-schievink in #54326 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.