Skip to content

Commit

Permalink
Require \r whitespace to be followed by \n
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Jun 24, 2023
1 parent 8c99c83 commit 0c550b2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,14 @@ fn skip_whitespace(input: Cursor) -> Cursor {
}
}
match byte {
b' ' | 0x09..=0x0d => {
b' ' | 0x09..=0x0c => {
s = s.advance(1);
continue;
}
b'\r' if s.as_bytes().get(1) == Some(&b'\n') => {
s = s.advance(2);
continue;
}
b if b <= 0x7f => {}
_ => {
let ch = s.chars().next().unwrap();
Expand Down
2 changes: 1 addition & 1 deletion tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ fn whitespace() {
assert_eq!(tokens.into_iter().count(), 0);

let lone_carriage_return = " \r ";
lone_carriage_return.parse::<TokenStream>().unwrap(); // FIXME
lone_carriage_return.parse::<TokenStream>().unwrap_err();
}

#[test]
Expand Down

0 comments on commit 0c550b2

Please sign in to comment.