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

Incorrect span when encountering incorrect opening delimiter in macro fragments #55322

Closed
estebank opened this issue Oct 24, 2018 · 1 comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@estebank
Copy link
Contributor

When writing a macro rule that tries to accept a () after a path, we correctly inform the user that ( cannot come after a path, but we point at the following character:

error: `$p:path` is followed by `(`, which is not allowed for `path` fragments
  --> $DIR/macro-follow.rs:104:15
   |
LL |     ($p:path ()) => {};
   |               ^

This is probably an off-by-one error in the span assignment of the tokens.

@estebank estebank added A-diagnostics Area: Messages for errors, warnings, and lints A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) labels Oct 24, 2018
@crlf0710 crlf0710 added C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 11, 2020
@estebank
Copy link
Contributor Author

Fixed:

error: `$p:path` is followed by `(`, which is not allowed for `path` fragments
 --> src/lib.rs:2:14
  |
2 |     ($p:path ()) => {};
  |              ^ not allowed after `path` fragments
  |
  = note: allowed there are: `{`, `[`, `=>`, `,`, `>`, `=`, `:`, `;`, `|`, `as` or `where`

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 A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants