Skip to content

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

Merged
dtolnay merged 1 commit intomasterfrom
streof
Feb 16, 2024
Merged

Improve error location at eof in LitStr::parse#1590
dtolnay merged 1 commit intomasterfrom
streof

Conversation

@dtolnay
Copy link
Copy Markdown
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
@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.

1 participant