Skip to content

Commit 4d72543

Browse files
authored
Merge pull request #1484 from dtolnay/parsesuffix
Reject parse on LitStr containing suffix
2 parents 7e8358a + d59afb2 commit 4d72543

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/lit.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,17 @@ impl LitStr {
228228
let mut tokens = TokenStream::from_str(&self.value())?;
229229
tokens = respan_token_stream(tokens, self.span());
230230

231-
parser.parse2(tokens)
231+
let result = parser.parse2(tokens)?;
232+
233+
let suffix = self.suffix();
234+
if !suffix.is_empty() {
235+
return Err(Error::new(
236+
self.span(),
237+
format!("unexpected suffix `{}` on string literal", suffix),
238+
));
239+
}
240+
241+
Ok(result)
232242
}
233243

234244
pub fn span(&self) -> Span {

0 commit comments

Comments
 (0)