[red-knot] Ignore surrounding whitespace when looking for <!-- snapshot-diagnostics --> directives in mdtests (#16380)

This commit is contained in:
Alex Waygood 2025-02-27 13:25:31 +00:00 committed by GitHub
parent d56d241317
commit 040071bbc5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 54 additions and 15 deletions

View file

@ -95,7 +95,22 @@ impl<'a> Cursor<'a> {
/// Eats the next two characters if they are `c1` and `c2`. Does not
/// consume any input otherwise, even if the first character matches.
pub fn eat_char2(&mut self, c1: char, c2: char) -> bool {
if self.first() == c1 && self.second() == c2 {
let mut chars = self.chars.clone();
if chars.next() == Some(c1) && chars.next() == Some(c2) {
self.bump();
self.bump();
true
} else {
false
}
}
/// Eats the next three characters if they are `c1`, `c2` and `c3`
/// Does not consume any input otherwise, even if the first character matches.
pub fn eat_char3(&mut self, c1: char, c2: char, c3: char) -> bool {
let mut chars = self.chars.clone();
if chars.next() == Some(c1) && chars.next() == Some(c2) && chars.next() == Some(c3) {
self.bump();
self.bump();
self.bump();
true