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 error location at eof in LitStr::parse #1590

Merged
merged 1 commit into from Feb 16, 2024
Merged

Improve error location at eof in LitStr::parse #1590

merged 1 commit into from Feb 16, 2024

Conversation

dtolnay
Copy link
Owner

@dtolnay dtolnay commented Feb 16, 2024

I noticed this in colin-kiegel/rust-derive-builder#310. When using litstr.parse() on a string literal token whose contents are empty, there previously were not any tokens in which the span could be transferred to the inner parser. This is what the "scope" span is supposed to be for, which is also used for parsing the contents of empty delimiters, for the same reason.

Before:

error: unexpected end of input, expected expression
 --> tests/compile-fail/deny_empty_default.rs:6:10
  |
6 | #[derive(Builder)]
  |          ^^^^^^^
  |
  = note: this error originates in the derive macro `Builder` (in Nightly builds, run with -Z macro-backtrace for more info)

After:

error: unexpected end of input, expected expression
 --> tests/compile-fail/deny_empty_default.rs:8:25
  |
8 |     #[builder(default = "")]
  |                         ^^

@dtolnay dtolnay merged commit 981359c into master Feb 16, 2024
28 checks passed
@dtolnay dtolnay deleted the streof branch February 16, 2024 00:46
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.

None yet

1 participant