diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-09-05 12:11:04 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-09-05 12:11:04 +0200 |
| commit | a8d4e4f435a3287989ac1b20f86b87f6fca5e09b (patch) | |
| tree | 69b3a040b81a76b51ee36ce5000249971020c7c4 /src/libsyntax/ext/proc_macro_server.rs | |
| parent | a24f636e60a5da57ab641d800ac5952bbde98b65 (diff) | |
| parent | 206fe8e1c37d55d0bf3a82baaa23eb5fb148880b (diff) | |
| download | rust-a8d4e4f435a3287989ac1b20f86b87f6fca5e09b.tar.gz rust-a8d4e4f435a3287989ac1b20f86b87f6fca5e09b.zip | |
Rollup merge of #62848 - matklad:xid-unicode, r=petrochenkov
Use unicode-xid crate instead of libcore This PR proposes to remove `char::is_xid_start` and `char::is_xid_continue` functions from `libcore` and use `unicode_xid` crate from crates.io (note that this crate is already present in rust-lang/rust's Cargo.lock). Reasons to do this: * removing rustc-binary-specific stuff from libcore * making sure that, across the ecosystem, there's a single definition of what rust identifier is (`unicode-xid` has almost 10 million downs, as a `proc_macro2` dependency) * making it easier to share `rustc_lexer` crate with rust-analyzer: no need to `#[cfg]` if we are building as a part of the compiler Reasons not to do this: * increased maintenance burden: we'll need to upgrade unicode version both in libcore and in unicode-xid. However, this shouldn't be a too heavy burden: just running `./unicode.py` after new unicode version. I (@matklad) am ready to be a t-compiler side maintainer of unicode-xid. Moreover, given that xid-unicode is an important dependency of syn, *someone* needs to maintain it anyway. * xid-unicode implementation is significantly slower. It uses a more compact table with binary search, instead of a trie. However, this shouldn't matter in practice, because we have fast-path for ascii anyway, and code size savings is a plus. Moreover, in #59706 not using libcore turned out to be *faster*, presumably beacause checking for whitespace with match is even faster. <details> <summary>old description</summary> Followup to #59706 r? @eddyb Note that this doesn't actually remove tables from libcore, to avoid conflict with https://github.com/rust-lang/rust/pull/62641. cc https://github.com/unicode-rs/unicode-xid/pull/11 </details>
Diffstat (limited to 'src/libsyntax/ext/proc_macro_server.rs')
| -rw-r--r-- | src/libsyntax/ext/proc_macro_server.rs | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/src/libsyntax/ext/proc_macro_server.rs b/src/libsyntax/ext/proc_macro_server.rs index 1a26b17dac7..544ec789d80 100644 --- a/src/libsyntax/ext/proc_macro_server.rs +++ b/src/libsyntax/ext/proc_macro_server.rs @@ -322,8 +322,7 @@ impl Ident { fn is_valid(string: &str) -> bool { let mut chars = string.chars(); if let Some(start) = chars.next() { - (start == '_' || start.is_xid_start()) - && chars.all(|cont| cont == '_' || cont.is_xid_continue()) + rustc_lexer::is_id_start(start) && chars.all(rustc_lexer::is_id_continue) } else { false } |
