diff options
| author | Matthias Krüger <476013+matthiaskrgr@users.noreply.github.com> | 2025-06-05 16:02:04 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-05 16:02:04 +0200 |
| commit | e80eadafa5bf4a0ccc048bee585b4c155a3ecb35 (patch) | |
| tree | 966658a1422febf742ce505d2f7530e5593b897c /compiler | |
| parent | 19798d62dc172b8950e3ee901a87ed6eade82725 (diff) | |
| parent | 55f59fb0e329d0815a06d51dd469d774eb455cba (diff) | |
| download | rust-e80eadafa5bf4a0ccc048bee585b4c155a3ecb35.tar.gz rust-e80eadafa5bf4a0ccc048bee585b4c155a3ecb35.zip | |
Rollup merge of #142032 - matthewjasper:frontmatter-lexing, r=fee1-dead
Fix parsing of frontmatters with inner hyphens closes rust-lang/rust#141483 r? fee1-dead
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_lexer/src/lib.rs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/compiler/rustc_lexer/src/lib.rs b/compiler/rustc_lexer/src/lib.rs index 2374f388250..ece3f9107b0 100644 --- a/compiler/rustc_lexer/src/lib.rs +++ b/compiler/rustc_lexer/src/lib.rs @@ -545,11 +545,12 @@ impl Cursor<'_> { let mut s = self.as_str(); let mut found = false; + let mut size = 0; while let Some(closing) = s.find(&"-".repeat(length_opening as usize)) { let preceding_chars_start = s[..closing].rfind("\n").map_or(0, |i| i + 1); if s[preceding_chars_start..closing].chars().all(is_whitespace) { // candidate found - self.bump_bytes(closing); + self.bump_bytes(size + closing); // in case like // ---cargo // --- blahblah @@ -562,6 +563,7 @@ impl Cursor<'_> { break; } else { s = &s[closing + length_opening as usize..]; + size += closing + length_opening as usize; } } |
