From 156aef10c463f81ca0016583a9df83d7b8560e59 Mon Sep 17 00:00:00 2001 From: Kevin Stevens <48657161+stevenskevin@users.noreply.github.com> Date: Mon, 15 May 2023 03:35:46 -0400 Subject: [PATCH] Switch from unicode_xid to unicode_ident (#1208) --- Cargo.lock | 8 +------- Cargo.toml | 2 +- src/syntax/lexer.rs | 10 +++++----- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9235c7b6e..e747873ef 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2311,9 +2311,9 @@ dependencies = [ "ttf-parser", "typst-macros", "unicode-general-category", + "unicode-ident", "unicode-math-class", "unicode-segmentation", - "unicode-xid", "unscanny", "usvg", "xmp-writer", @@ -2525,12 +2525,6 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" -[[package]] -name = "unicode-xid" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" - [[package]] name = "unicode_names2" version = "0.6.0" diff --git a/Cargo.toml b/Cargo.toml index 570b0b79e..3bc57b697 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -60,9 +60,9 @@ tiny-skia = "0.9.0" tracing = "0.1.37" ttf-parser = "0.18.1" unicode-general-category = "0.6" +unicode-ident = "1.0" unicode-math-class = "0.1" unicode-segmentation = "1" -unicode-xid = "0.2" unscanny = "0.1" usvg = { version = "0.32", default-features = false, features = ["text"] } xmp-writer = "0.1" diff --git a/src/syntax/lexer.rs b/src/syntax/lexer.rs index eb19d8d96..ee73a595e 100644 --- a/src/syntax/lexer.rs +++ b/src/syntax/lexer.rs @@ -1,6 +1,6 @@ use ecow::{eco_format, EcoString}; +use unicode_ident::{is_xid_continue, is_xid_start}; use unicode_segmentation::UnicodeSegmentation; -use unicode_xid::UnicodeXID; use unscanny::Scanner; use super::{ErrorPos, SyntaxKind}; @@ -723,23 +723,23 @@ pub fn is_ident(string: &str) -> bool { /// Whether a character can start an identifier. #[inline] pub(crate) fn is_id_start(c: char) -> bool { - c.is_xid_start() || c == '_' + is_xid_start(c) || c == '_' } /// Whether a character can continue an identifier. #[inline] pub(crate) fn is_id_continue(c: char) -> bool { - c.is_xid_continue() || c == '_' || c == '-' + is_xid_continue(c) || c == '_' || c == '-' } /// Whether a character can start an identifier in math. #[inline] fn is_math_id_start(c: char) -> bool { - c.is_xid_start() + is_xid_start(c) } /// Whether a character can continue an identifier in math. #[inline] fn is_math_id_continue(c: char) -> bool { - c.is_xid_continue() && c != '_' + is_xid_continue(c) && c != '_' }