Skip to content

Commit

Permalink
Improve error location at eof in LitStr::parse
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Feb 16, 2024
1 parent 270c633 commit adee7a9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/lit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,11 @@ impl LitStr {

// Parse string literal into a token stream with every span equal to the
// original literal's span.
let span = self.span();
let mut tokens = TokenStream::from_str(&self.value())?;
tokens = respan_token_stream(tokens, self.span());
tokens = respan_token_stream(tokens, span);

let result = parser.parse2(tokens)?;
let result = parser.__parse_scoped(span, tokens)?;

let suffix = self.suffix();
if !suffix.is_empty() {
Expand Down

0 comments on commit adee7a9

Please sign in to comment.