Skip to content

Commit 1c35895

Browse files
committed
Reject 'prefix#lifetime
1 parent 438f535 commit 1c35895

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/parse.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,10 @@ fn digits(mut input: Cursor) -> Result<Cursor, Reject> {
871871
fn punct(input: Cursor) -> PResult<Punct> {
872872
let (rest, ch) = punct_char(input)?;
873873
if ch == '\'' {
874-
if ident_any(rest)?.0.starts_with_char('\'') {
874+
let (after_lifetime, _ident) = ident_any(rest)?;
875+
if after_lifetime.starts_with_char('\'')
876+
|| (after_lifetime.starts_with_char('#') && !rest.starts_with("r#"))
877+
{
875878
Err(Reject)
876879
} else {
877880
Ok((rest, Punct::new('\'', Spacing::Joint)))

tests/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ fn lifetimes() {
523523
"' a".parse::<TokenStream>().unwrap_err();
524524
"' r#gen".parse::<TokenStream>().unwrap_err();
525525
"' prefix#lifetime".parse::<TokenStream>().unwrap_err();
526-
"'prefix#lifetime".parse::<TokenStream>().unwrap(); // FIXME
526+
"'prefix#lifetime".parse::<TokenStream>().unwrap_err();
527527
"'aa'bb".parse::<TokenStream>().unwrap_err();
528528
"'r#gen'a".parse::<TokenStream>().unwrap_err();
529529
}

0 commit comments

Comments
 (0)