Skip to content

Commit 1e5fabb

Browse files
authored
Unrolled build for #142032
Rollup merge of #142032 - matthewjasper:frontmatter-lexing, r=fee1-dead Fix parsing of frontmatters with inner hyphens closes #141483 r? fee1-dead
2 parents 0b20963 + 55f59fb commit 1e5fabb

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

compiler/rustc_lexer/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,11 +545,12 @@ impl Cursor<'_> {
545545

546546
let mut s = self.as_str();
547547
let mut found = false;
548+
let mut size = 0;
548549
while let Some(closing) = s.find(&"-".repeat(length_opening as usize)) {
549550
let preceding_chars_start = s[..closing].rfind("\n").map_or(0, |i| i + 1);
550551
if s[preceding_chars_start..closing].chars().all(is_whitespace) {
551552
// candidate found
552-
self.bump_bytes(closing);
553+
self.bump_bytes(size + closing);
553554
// in case like
554555
// ---cargo
555556
// --- blahblah
@@ -562,6 +563,7 @@ impl Cursor<'_> {
562563
break;
563564
} else {
564565
s = &s[closing + length_opening as usize..];
566+
size += closing + length_opening as usize;
565567
}
566568
}
567569

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
x ---🚧️
3+
---
4+
5+
// Regression test for #141483
6+
//@check-pass
7+
8+
#![feature(frontmatter)]
9+
10+
fn main() {}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
x ---y
3+
---
4+
5+
// Test that hypens are allowed inside frontmatters if there is some
6+
// non-whitespace character preceding them.
7+
//@check-pass
8+
9+
#![feature(frontmatter)]
10+
11+
fn main() {}

0 commit comments

Comments
 (0)