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

Error E0308 (type mismatch) is sometimes confusing #47499

Closed
jdahlstrom opened this issue Jan 16, 2018 · 1 comment
Closed

Error E0308 (type mismatch) is sometimes confusing #47499

jdahlstrom opened this issue Jan 16, 2018 · 1 comment
Labels
WG-diagnostics Working group: Diagnostics

Comments

@jdahlstrom
Copy link

jdahlstrom commented Jan 16, 2018

Consider the following short snippet (playground):

fn bar<T>(_: T, _: T) {}

fn foo<T, U>(t: T, u: U) {
    bar(t, u);
}

It has a type error, of course, but the error message is not the most helpful. At least to me it seems to imply that the compiler found a literal type parameter (ie. in this case T or U) but expects another type parameter, when in actuality it's about values of those types. The note helps a bit though.

error[E0308]: mismatched types
 --> src/main.rs:4:12
  |
4 |     bar(t, u);
  |            ^ expected type parameter, found a different type parameter
  |
  = note: expected type `T`
             found type `U`
@GuillaumeGomez GuillaumeGomez added the WG-diagnostics Working group: Diagnostics label Jan 16, 2018
@jdahlstrom
Copy link
Author

Oops, this is a near duplicate of #47319. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WG-diagnostics Working group: Diagnostics
Projects
None yet
Development

No branches or pull requests

2 participants