Skip to content

Commit 5d5fdb3

Browse files
authored
Merge pull request #260 from dtolnay/lit
Disallow lifetime followed immediately by single quote
2 parents d7e204f + af9dd20 commit 5d5fdb3

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/parse.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -716,8 +716,11 @@ fn digits(mut input: Cursor) -> Result<Cursor, LexError> {
716716
fn op(input: Cursor) -> PResult<Punct> {
717717
match op_char(input) {
718718
Ok((rest, '\'')) => {
719-
ident(rest)?;
720-
Ok((rest, Punct::new('\'', Spacing::Joint)))
719+
if ident(rest)?.0.starts_with("'") {
720+
Err(LexError)
721+
} else {
722+
Ok((rest, Punct::new('\'', Spacing::Joint)))
723+
}
721724
}
722725
Ok((rest, ch)) => {
723726
let kind = match op_char(rest) {

tests/test.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ fn fail() {
198198
fail("b\"\r\""); // bare carriage return in byte string
199199
fail("r\"\r\""); // bare carriage return in raw string
200200
fail("\"\\\r \""); // backslash carriage return
201+
fail("'aa'aa");
201202
}
202203

203204
#[cfg(span_locations)]

0 commit comments

Comments
 (0)