Skip to content

Commit 54367b9

Browse files
authored
Rollup merge of rust-lang#87499 - ibraheemdev:patch-6, r=dtolnay
Remove ASCII fast path from `rustc_lexer::{is_id_continue, is_id_start}` `unicode_xid` now has a fast path built-in: unicode-rs/unicode-xid@122b387
2 parents a981cff + de27d68 commit 54367b9

File tree

2 files changed

+4
-14
lines changed

2 files changed

+4
-14
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5409,9 +5409,9 @@ dependencies = [
54095409

54105410
[[package]]
54115411
name = "unicode-xid"
5412-
version = "0.2.1"
5412+
version = "0.2.2"
54135413
source = "registry+https://github.com/rust-lang/crates.io-index"
5414-
checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
5414+
checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
54155415

54165416
[[package]]
54175417
name = "unicode_categories"

compiler/rustc_lexer/src/lib.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -273,24 +273,14 @@ pub fn is_whitespace(c: char) -> bool {
273273
/// a formal definition of valid identifier name.
274274
pub fn is_id_start(c: char) -> bool {
275275
// This is XID_Start OR '_' (which formally is not a XID_Start).
276-
// We also add fast-path for ascii idents
277-
('a'..='z').contains(&c)
278-
|| ('A'..='Z').contains(&c)
279-
|| c == '_'
280-
|| (c > '\x7f' && unicode_xid::UnicodeXID::is_xid_start(c))
276+
c == '_' || unicode_xid::UnicodeXID::is_xid_start(c)
281277
}
282278

283279
/// True if `c` is valid as a non-first character of an identifier.
284280
/// See [Rust language reference](https://doc.rust-lang.org/reference/identifiers.html) for
285281
/// a formal definition of valid identifier name.
286282
pub fn is_id_continue(c: char) -> bool {
287-
// This is exactly XID_Continue.
288-
// We also add fast-path for ascii idents
289-
('a'..='z').contains(&c)
290-
|| ('A'..='Z').contains(&c)
291-
|| ('0'..='9').contains(&c)
292-
|| c == '_'
293-
|| (c > '\x7f' && unicode_xid::UnicodeXID::is_xid_continue(c))
283+
unicode_xid::UnicodeXID::is_xid_continue(c)
294284
}
295285

296286
/// The passed string is lexically an identifier.

0 commit comments

Comments
 (0)