Skip to content

Improve the diagnostics for mistakes in for loops #16762

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

Merged
merged 2 commits into from
Aug 29, 2014

Conversation

huonw
Copy link
Member

@huonw huonw commented Aug 26, 2014

  • print the type of x in for ... in x in the "does not implement Iterator" message
  • avoid printing that message if x has a type error

@huonw huonw changed the title Improve the diagnostics from mistakes in for loops Improve the diagnostics for mistakes in for loops Aug 26, 2014
This improves the error message by telling the user the exact type of
`x` if it doesn't implement `Iterator` in `for ... in x {}`.

Closes rust-lang#16043.
This squashes the

> `for` loop expression has type `[type error]` which does not implement
> the `Iterator` trait

message that one received when writing `for ... in x` where was
previously found to have a type error.

Fixes rust-lang#16042.
bors added a commit that referenced this pull request Aug 29, 2014
- print the type of `x` in `for ... in x` in the "does not implement Iterator" message
- avoid printing that message if `x` has a type error
@bors bors closed this Aug 29, 2014
@bors bors merged commit fd278a8 into rust-lang:master Aug 29, 2014
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 17, 2024
Added QuickFix for unresolved field.

Adds an AssistKind::QuickFix for unresolved field.

Currently, Snippets are not available for Diagnostics. So the type defaults to the Unit type if the type is not able to be inferred.

https://github.com/rust-lang/rust-analyzer/assets/11785959/bd4c67bd-f8cb-4254-9a87-641ae80a7a28

Closes rust-lang/rust-analyzer#4563
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants