Skip to content

Commit

Permalink
rust: syn: remove unicode-ident dependency
Browse files Browse the repository at this point in the history
The `syn` crate depends on the `unicode-ident` crate
to determine whether characters have the XID_Start or XID_Continue
properties according to Unicode Standard Annex torvalds#31.

However, we only need ASCII identifiers in the kernel, thus we can
simplify the check and remove completely that dependency.

Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
  • Loading branch information
ojeda committed Apr 10, 2024
1 parent 3c7cd93 commit 181a570
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions rust/syn/ident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ impl From<Token![_]> for Ident {
pub(crate) fn xid_ok(symbol: &str) -> bool {
let mut chars = symbol.chars();
let first = chars.next().unwrap();
if !(first == '_' || unicode_ident::is_xid_start(first)) {
if !(first == '_' || first.is_ascii_alphabetic()) {
return false;
}
for ch in chars {
if !unicode_ident::is_xid_continue(ch) {
if !(ch == '_' || ch.is_ascii_alphanumeric()) {
return false;
}
}
Expand Down

0 comments on commit 181a570

Please sign in to comment.