From a397fdcc3858a4c6d63f7dd88994d2214ded4482 Mon Sep 17 00:00:00 2001 From: Ibraheem Ahmed Date: Mon, 26 Jul 2021 20:17:28 -0400 Subject: [PATCH 1/2] Remove ASCII fast path from rustc_lexer::{is_id_continue, is_id_start} --- compiler/rustc_lexer/src/lib.rs | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/compiler/rustc_lexer/src/lib.rs b/compiler/rustc_lexer/src/lib.rs index 4cb2a6ca50f8d..b5e6d256a996a 100644 --- a/compiler/rustc_lexer/src/lib.rs +++ b/compiler/rustc_lexer/src/lib.rs @@ -273,24 +273,14 @@ pub fn is_whitespace(c: char) -> bool { /// a formal definition of valid identifier name. pub fn is_id_start(c: char) -> bool { // This is XID_Start OR '_' (which formally is not a XID_Start). - // We also add fast-path for ascii idents - ('a'..='z').contains(&c) - || ('A'..='Z').contains(&c) - || c == '_' - || (c > '\x7f' && unicode_xid::UnicodeXID::is_xid_start(c)) + c == '_' || unicode_xid::UnicodeXID::is_xid_start(c) } /// True if `c` is valid as a non-first character of an identifier. /// See [Rust language reference](https://doc.rust-lang.org/reference/identifiers.html) for /// a formal definition of valid identifier name. pub fn is_id_continue(c: char) -> bool { - // This is exactly XID_Continue. - // We also add fast-path for ascii idents - ('a'..='z').contains(&c) - || ('A'..='Z').contains(&c) - || ('0'..='9').contains(&c) - || c == '_' - || (c > '\x7f' && unicode_xid::UnicodeXID::is_xid_continue(c)) + unicode_xid::UnicodeXID::is_xid_continue(c) } /// The passed string is lexically an identifier. From de27d68beb6e5b53247a7aaad83680d172ab93ba Mon Sep 17 00:00:00 2001 From: ibraheemdev Date: Mon, 26 Jul 2021 20:55:31 -0400 Subject: [PATCH 2/2] update unicode-xid dependency --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 553d9d05e57ba..b0dbe28352357 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5409,9 +5409,9 @@ dependencies = [ [[package]] name = "unicode-xid" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" +checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" [[package]] name = "unicode_categories"