refactor(parser): remove unsafe code (#2527)

Remove some unnecessary unsafe code.
This commit is contained in:
overlookmotel 2024-02-27 12:28:21 +00:00 committed by GitHub
parent 02c82c3f78
commit 0ddfc856d2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -51,16 +51,15 @@ macro_rules! handle_string_literal {
handle_string_literal_escape!($lexer, $delimiter, $table, after_opening_quote)
})
},
b'\r' | b'\n' => {
// This is impossible in valid JS, so cold path
_ => {
// Line break. This is impossible in valid JS, so cold path.
cold_branch(|| {
debug_assert!(matches!(next_byte, b'\r' | b'\n'));
$lexer.consume_char();
$lexer.error(diagnostics::UnterminatedString($lexer.unterminated_range()));
Kind::Undetermined
})
},
// SAFETY: Macro user guarantees `$table` does not match any other bytes
_ => assert_unchecked::unreachable_unchecked!()
}
}
},
handle_eof: || {