From 51ac392ae48f0019592acb2fc96b24296d24b44d Mon Sep 17 00:00:00 2001 From: overlookmotel Date: Tue, 30 Jan 2024 04:23:35 +0000 Subject: [PATCH] refactor(parser): mark `ByteHandler`s unsafe (#2212) All the ASCII `ByteHandler`s are unsafe to call. I forgot to mark them as unsafe when making that change. This PR fixes that, and will make it harder for someone to accidentally call one of them without considering the safety invariants. --- crates/oxc_parser/src/lexer/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/oxc_parser/src/lexer/mod.rs b/crates/oxc_parser/src/lexer/mod.rs index b275d657b..ec6d50fea 100644 --- a/crates/oxc_parser/src/lexer/mod.rs +++ b/crates/oxc_parser/src/lexer/mod.rs @@ -1292,7 +1292,7 @@ unsafe fn handle_byte(byte: u8, lexer: &mut Lexer) -> Kind { BYTE_HANDLERS[byte as usize](lexer) } -type ByteHandler = fn(&mut Lexer<'_>) -> Kind; +type ByteHandler = unsafe fn(&mut Lexer<'_>) -> Kind; /// Lookup table mapping any incoming byte to a handler function defined below. ///