Skip to content

Commit 313d6c5

Browse files
author
David Cao
committed
provide error message when using more than 65535 hash symbols for raw strings
1 parent c40275b commit 313d6c5

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
@@ -1452,6 +1452,13 @@ impl<'a> StringReader<'a> {
14521452
self.bump();
14531453
let mut hash_count: u16 = 0;
14541454
while self.ch_is('#') {
1455+
if hash_count == 65535 {
1456+
let bpos = self.next_pos;
1457+
self.fatal_span_(start_bpos,
1458+
bpos,
1459+
"too many `#` symbols: raw strings may be \
1460+
delimited by up to 65535 `#` symbols").raise();
1461+
}
14551462
self.bump();
14561463
hash_count += 1;
14571464
}
@@ -1682,6 +1689,13 @@ impl<'a> StringReader<'a> {
16821689
self.bump();
16831690
let mut hash_count = 0;
16841691
while self.ch_is('#') {
1692+
if hash_count == 65535 {
1693+
let bpos = self.next_pos;
1694+
self.fatal_span_(start_bpos,
1695+
bpos,
1696+
"too many `#` symbols: raw byte strings may be \
1697+
delimited by up to 65535 `#` symbols").raise();
1698+
}
16851699
self.bump();
16861700
hash_count += 1;
16871701
}

0 commit comments

Comments
 (0)