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

Improve diagnostics when attempting to match tuple enum variant with struct pattern #44786

Merged
merged 2 commits into from Sep 24, 2017

Conversation

Projects
None yet
5 participants
@thombles
Copy link
Contributor

thombles commented Sep 23, 2017

Adds an extra note as below to explain that a tuple pattern was probably intended.

error[E0026]: variant `X::Y` does not have a field named `data`
  --> src/main.rs:18:16
   |
18 |         X::Y { data } => println!("The data is {}", data)
   |                ^^^^ variant `X::Y` does not have field `data`

error[E0027]: pattern does not mention field `0`
  --> src/main.rs:18:9
   |
18 |         X::Y { data } => println!("The data is {}", data)
   |         ^^^^^^^^^^^^^ missing field `0`
   |
   = note: trying to match a tuple variant with a struct variant pattern

Fixes #41314.

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Sep 23, 2017

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @arielb1 (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@petrochenkov

This comment has been minimized.

Copy link
Contributor

petrochenkov commented Sep 23, 2017

Thanks!
@bors r+

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Sep 23, 2017

📌 Commit def660c has been approved by petrochenkov

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Sep 23, 2017

Rollup merge of rust-lang#44786 - thombles:tk/i41314, r=petrochenkov
Improve diagnostics when attempting to match tuple enum variant with struct pattern

Adds an extra note as below to explain that a tuple pattern was probably intended.

```
error[E0026]: variant `X::Y` does not have a field named `data`
  --> src/main.rs:18:16
   |
18 |         X::Y { data } => println!("The data is {}", data)
   |                ^^^^ variant `X::Y` does not have field `data`

error[E0027]: pattern does not mention field `0`
  --> src/main.rs:18:9
   |
18 |         X::Y { data } => println!("The data is {}", data)
   |         ^^^^^^^^^^^^^ missing field `0`
   |
   = note: trying to match a tuple variant with a struct variant pattern
```

Solution for rust-lang#41314.

bors added a commit that referenced this pull request Sep 23, 2017

Auto merge of #44791 - GuillaumeGomez:rollup, r=GuillaumeGomez
Rollup of 5 pull requests

- Successful merges: #44625, #44765, #44785, #44786, #44789
- Failed merges:
@bors

This comment has been minimized.

Copy link
Contributor

bors commented Sep 24, 2017

⌛️ Testing commit def660c with merge 6f90787...

bors added a commit that referenced this pull request Sep 24, 2017

Auto merge of #44786 - thombles:tk/i41314, r=petrochenkov
Improve diagnostics when attempting to match tuple enum variant with struct pattern

Adds an extra note as below to explain that a tuple pattern was probably intended.

```
error[E0026]: variant `X::Y` does not have a field named `data`
  --> src/main.rs:18:16
   |
18 |         X::Y { data } => println!("The data is {}", data)
   |                ^^^^ variant `X::Y` does not have field `data`

error[E0027]: pattern does not mention field `0`
  --> src/main.rs:18:9
   |
18 |         X::Y { data } => println!("The data is {}", data)
   |         ^^^^^^^^^^^^^ missing field `0`
   |
   = note: trying to match a tuple variant with a struct variant pattern
```

Fixes #41314.
@bors

This comment has been minimized.

Copy link
Contributor

bors commented Sep 24, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: petrochenkov
Pushing 6f90787 to master...

@bors bors merged commit def660c into rust-lang:master Sep 24, 2017

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.