Skip to content

Commit b9114e6

Browse files
authored
Merge pull request #58 from alexcrichton/fix
Add a special case for empty `/*` comments
2 parents 8c03033 + f7df57c commit b9114e6

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/strnom.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ pub fn whitespace(input: Cursor) -> PResult<()> {
8080
continue;
8181
}
8282
break;
83+
} else if s.starts_with("/**/") {
84+
i += 4;
85+
continue
8386
} else if s.starts_with("/*") && (!s.starts_with("/**") || s.starts_with("/***")) &&
8487
!s.starts_with("/*!") {
8588
let (_, com) = block_comment(s)?;

tests/test.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,3 +170,10 @@ fn no_panic() {
170170
assert!(s.parse::<proc_macro2::TokenStream>().is_err());
171171
}
172172

173+
#[test]
174+
fn tricky_doc_commaent() {
175+
let stream = "/**/".parse::<proc_macro2::TokenStream>().unwrap();
176+
let tokens = stream.into_iter().collect::<Vec<_>>();
177+
assert!(tokens.is_empty(), "not empty -- {:?}", tokens);
178+
}
179+

0 commit comments

Comments
 (0)