Skip to content

Commit

Permalink
Reject parse on LitStr containing suffix
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Jul 9, 2023
1 parent 7e8358a commit d59afb2
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 d59afb2

Please sign in to comment.