Skip to content

Suggests to initialize struct with private fields, instead of looking for typo #39226

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

Closed
nagisa opened this issue Jan 21, 2017 · 3 comments
Closed

Comments

@nagisa
Copy link
Member

nagisa commented Jan 21, 2017

I typo’d handle (local variable) with Handle (type with private fields I have no access to). Would have expected rustc to not emit such a note and maybe look for typos instead.

error[E0423]: expected value, found struct `Handle`
   |
73 |                     handle: Handle,
   |                             ^^^^^^ did you mean `Handle { /* fields */ }`?
@Freyskeyd
Copy link
Contributor

I agree. I think it's better to look for context before looking for Struct or any other Expression.

I will try to modify check order.

bors added a commit that referenced this issue Apr 29, 2017
Checker:: Execute levenshtein before other context checking

As explain [here]() i think it's better to check for a miss typing before checking context dependent help.

```rust
struct Handle {}

struct Something {
     handle: Handle
}

fn main() {
     let handle: Handle = Handle {};

     let s: Something = Something {
         // Checker detect an error and propose a solution with `Handle { /* ... */ }`
         // but it's a miss typing of `handle`
         handle: Handle
    };
}
```

Ping: @nagisa for #39226

Signed-off-by: Freyskeyd <simon.paitrault@gmail.com>
@Freyskeyd
Copy link
Contributor

This PR can be closed I think: refer to #39291

cc @nagisa

@nagisa
Copy link
Member Author

nagisa commented May 2, 2017

Great!

@nagisa nagisa closed this as completed May 2, 2017
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

No branches or pull requests

2 participants