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 messages wrt. patterns named the same as a type could be better #49145

Closed
Centril opened this issue Mar 18, 2018 · 1 comment
Closed

Error messages wrt. patterns named the same as a type could be better #49145

Centril opened this issue Mar 18, 2018 · 1 comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-feature-request Category: A feature request, i.e: not implemented / a PR. WG-diagnostics Working group: Diagnostics

Comments

@Centril
Copy link
Contributor

Centril commented Mar 18, 2018

Given:

struct f; fn main() { let f = 1; }

a rust compiler (playground, stable) will error with:

error[E0308]: mismatched types
 --> src/main.rs:1:27
  |
1 | struct f; fn main() { let f = 1; }
  |                           ^ expected integral variable, found struct `f`
  |
  = note: expected type `{integer}`
             found type `f`

this is morally right; but the error message could highlight the fact that the user most likely confused the pattern f (as in the equivalent unit struct pattern f {}) with a variable binding f.

Tho, the names coinciding is somewhat pathological, so it might not warrant special care; but perhaps it does?

@Centril Centril added A-diagnostics Area: Messages for errors, warnings, and lints C-feature-request Category: A feature request, i.e: not implemented / a PR. WG-diagnostics Working group: Diagnostics labels Mar 18, 2018
@estebank
Copy link
Contributor

Duplicate of #48062.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-feature-request Category: A feature request, i.e: not implemented / a PR. WG-diagnostics Working group: Diagnostics
Projects
None yet
Development

No branches or pull requests

2 participants