diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index 8363c1f39aa37..5353ff9a1e13d 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -1450,6 +1450,13 @@ impl<'a> StringReader<'a> { self.bump(); let mut hash_count: u16 = 0; while self.ch_is('#') { + if hash_count == 65535 { + let bpos = self.next_pos; + self.fatal_span_(start_bpos, + bpos, + "too many `#` symbols: raw strings may be \ + delimited by up to 65535 `#` symbols").raise(); + } self.bump(); hash_count += 1; } @@ -1680,6 +1687,13 @@ impl<'a> StringReader<'a> { self.bump(); let mut hash_count = 0; while self.ch_is('#') { + if hash_count == 65535 { + let bpos = self.next_pos; + self.fatal_span_(start_bpos, + bpos, + "too many `#` symbols: raw byte strings may be \ + delimited by up to 65535 `#` symbols").raise(); + } self.bump(); hash_count += 1; }