Merge branch 'main' into rust1_65

Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com>
This commit is contained in:
Anton-4 2023-01-17 18:14:30 +01:00 committed by GitHub
commit bbf35af8fa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
179 changed files with 7089 additions and 3846 deletions

View file

@ -378,6 +378,10 @@ where
}
}
fn begins_with_crlf(bytes: &[u8]) -> bool {
bytes.len() >= 2 && bytes[0] == b'\r' && bytes[1] == b'\n'
}
pub fn spaces<'a, E>() -> impl Parser<'a, &'a [CommentOrNewline<'a>], E>
where
E: 'a + SpaceProblem,
@ -399,6 +403,7 @@ where
let is_doc_comment = state.bytes().first() == Some(&b'#')
&& (state.bytes().get(1) == Some(&b' ')
|| state.bytes().get(1) == Some(&b'\n')
|| begins_with_crlf(&state.bytes()[1..])
|| Option::is_none(&state.bytes().get(1)));
if is_doc_comment {
@ -422,7 +427,10 @@ where
newlines.push(comment);
state.advance_mut(len);
if state.bytes().first() == Some(&b'\n') {
if begins_with_crlf(state.bytes()) {
state.advance_mut(1);
state = state.advance_newline();
} else if state.bytes().first() == Some(&b'\n') {
state = state.advance_newline();
}