Skip to content

Commit

Permalink
Merge pull request #1484 from dtolnay/parsesuffix
Browse files Browse the repository at this point in the history
Reject parse on LitStr containing suffix
  • Loading branch information
dtolnay committed Jul 9, 2023
2 parents 7e8358a + d59afb2 commit 4d72543
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/lit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,17 @@ impl LitStr {
let mut tokens = TokenStream::from_str(&self.value())?;
tokens = respan_token_stream(tokens, self.span());

parser.parse2(tokens)
let result = parser.parse2(tokens)?;

let suffix = self.suffix();
if !suffix.is_empty() {
return Err(Error::new(
self.span(),
format!("unexpected suffix `{}` on string literal", suffix),
));
}

Ok(result)
}

pub fn span(&self) -> Span {
Expand Down

0 comments on commit 4d72543

Please sign in to comment.