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

Parser struct approach to error reporting #461

Closed
wants to merge 6 commits into from
Closed

Parser struct approach to error reporting #461

wants to merge 6 commits into from

Conversation

dtolnay
Copy link
Owner

@dtolnay dtolnay commented Jul 22, 2018

This is based on Sergio's work in SergioBenitez@b49a4b4. Custom error messages like the following:

error: expected 2 element(s), got 3
 --> src/main.rs:7:20
  |
7 |     demo!((a, b) = (1, 2, 3));
  |                    ^^^^^^^^^
  |
note: because of this
 --> src/main.rs:7:11
  |
7 |     demo!((a, b) = (1, 2, 3));
  |           ^^^^^^

error: expected 1 element(s), got 3
 --> src/main.rs:9:17
  |
9 |     demo!((c) = (1, 2, 3));
  |                 ^^^^^^^^^
  |
note: because of this
 --> src/main.rs:9:11
  |
9 |     demo!((c) = (1, 2, 3));
  |           ^^^

error: failed to parse: expected `=`
  --> src/main.rs:10:15
   |
10 |     demo!((c) ? (1, 2, 3));
   |               ^

error: failed to parse: expected tuple
  --> src/main.rs:11:11
   |
11 |     demo!(c = (1, 2, 3));
   |           ^

error: trailing characters; expected eof
  --> src/main.rs:12:33
   |
12 |     demo!((a, b, c) = (1, 2, 3) hi);
   |                                 ^^

Relevant to #47.

@dtolnay dtolnay closed this Jul 22, 2018
@dtolnay dtolnay deleted the demo branch July 22, 2018 16:59
@dtolnay
Copy link
Owner Author

dtolnay commented Jul 22, 2018

As one commit for convenient cherry-picking: 03d6727.

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.

1 participant