Skip to content

Commit 967c1f3

Browse files
committed
Auto merge of #50296 - cmdd:master, r=nikomatsakis
Add error message for using >= 65535 hashes for raw string literal escapes Fixes #50111.
2 parents 24edc41 + 313d6c5 commit 967c1f3

File tree

1 file changed

+14
-0
lines changed
  • src/libsyntax/parse/lexer

1 file changed

+14
-0
lines changed

src/libsyntax/parse/lexer/mod.rs

+14
Original file line numberDiff line numberDiff line change
@@ -1450,6 +1450,13 @@ impl<'a> StringReader<'a> {
14501450
self.bump();
14511451
let mut hash_count: u16 = 0;
14521452
while self.ch_is('#') {
1453+
if hash_count == 65535 {
1454+
let bpos = self.next_pos;
1455+
self.fatal_span_(start_bpos,
1456+
bpos,
1457+
"too many `#` symbols: raw strings may be \
1458+
delimited by up to 65535 `#` symbols").raise();
1459+
}
14531460
self.bump();
14541461
hash_count += 1;
14551462
}
@@ -1680,6 +1687,13 @@ impl<'a> StringReader<'a> {
16801687
self.bump();
16811688
let mut hash_count = 0;
16821689
while self.ch_is('#') {
1690+
if hash_count == 65535 {
1691+
let bpos = self.next_pos;
1692+
self.fatal_span_(start_bpos,
1693+
bpos,
1694+
"too many `#` symbols: raw byte strings may be \
1695+
delimited by up to 65535 `#` symbols").raise();
1696+
}
16831697
self.bump();
16841698
hash_count += 1;
16851699
}

0 commit comments

Comments
 (0)