Skip to content

Commit 211aad4

Browse files
authored
build: remove duplicate dependency, consolidate over unicode-ident (#16137)
Hello, The crates `unicode-ident` and `unicode-xid` do the exact same job. This PR replaces the few `unicode-xid` usages and converges over `unicode-ident` across the workspace. Thanks!
2 parents 344c456 + 391c970 commit 211aad4

File tree

6 files changed

+15
-16
lines changed

6 files changed

+15
-16
lines changed

Cargo.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,8 @@ tracing = { version = "0.1.41", default-features = false, features = ["std"] } #
112112
tracing-chrome = "0.7.2"
113113
tracing-subscriber = { version = "0.3.20", features = ["env-filter"] }
114114
unicase = "2.8.1"
115-
unicode-ident = "1.0.19"
115+
unicode-ident = "1.0.20"
116116
unicode-width = "0.2.1"
117-
unicode-xid = "0.2.6"
118117
url = "2.5.7"
119118
varisat = "0.2.2"
120119
walkdir = "2.5.0"
@@ -219,7 +218,7 @@ tracing = { workspace = true, features = ["attributes"] }
219218
tracing-subscriber.workspace = true
220219
unicase.workspace = true
221220
unicode-width.workspace = true
222-
unicode-xid.workspace = true
221+
unicode-ident.workspace = true
223222
url.workspace = true
224223
walkdir.workspace = true
225224
winnow.workspace = true

crates/cargo-util-schemas/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ serde-untagged.workspace = true
1717
serde-value.workspace = true
1818
thiserror.workspace = true
1919
toml = { workspace = true, features = ["serde"] }
20-
unicode-xid.workspace = true
20+
unicode-ident.workspace = true
2121
url.workspace = true
2222

2323
[lints]

crates/cargo-util-schemas/src/restricted_names.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pub(crate) fn validate_name(name: &str, what: &'static str) -> Result<()> {
6161
}
6262
.into());
6363
}
64-
if !(unicode_xid::UnicodeXID::is_xid_start(ch) || ch == '_') {
64+
if !(unicode_ident::is_xid_start(ch) || ch == '_') {
6565
return Err(ErrorKind::InvalidCharacter {
6666
ch,
6767
what,
@@ -73,7 +73,7 @@ pub(crate) fn validate_name(name: &str, what: &'static str) -> Result<()> {
7373
}
7474
}
7575
for ch in chars {
76-
if !(unicode_xid::UnicodeXID::is_xid_continue(ch) || ch == '-') {
76+
if !(unicode_ident::is_xid_continue(ch) || ch == '-') {
7777
return Err(ErrorKind::InvalidCharacter {
7878
ch,
7979
what,
@@ -103,13 +103,13 @@ pub(crate) fn sanitize_name(name: &str, placeholder: char) -> String {
103103
let mut slug = String::new();
104104
let mut chars = name.chars();
105105
while let Some(ch) = chars.next() {
106-
if (unicode_xid::UnicodeXID::is_xid_start(ch) || ch == '_') && !ch.is_digit(10) {
106+
if (unicode_ident::is_xid_start(ch) || ch == '_') && !ch.is_digit(10) {
107107
slug.push(ch);
108108
break;
109109
}
110110
}
111111
while let Some(ch) = chars.next() {
112-
if unicode_xid::UnicodeXID::is_xid_continue(ch) || ch == '-' {
112+
if unicode_ident::is_xid_continue(ch) || ch == '-' {
113113
slug.push(ch);
114114
} else {
115115
slug.push(placeholder);
@@ -212,7 +212,7 @@ pub(crate) fn validate_feature_name(name: &str) -> Result<()> {
212212
}
213213
let mut chars = name.chars();
214214
if let Some(ch) = chars.next() {
215-
if !(unicode_xid::UnicodeXID::is_xid_start(ch) || ch == '_' || ch.is_digit(10)) {
215+
if !(unicode_ident::is_xid_start(ch) || ch == '_' || ch.is_digit(10)) {
216216
return Err(ErrorKind::InvalidCharacter {
217217
ch,
218218
what,
@@ -224,7 +224,7 @@ pub(crate) fn validate_feature_name(name: &str) -> Result<()> {
224224
}
225225
}
226226
for ch in chars {
227-
if !(unicode_xid::UnicodeXID::is_xid_continue(ch) || ch == '-' || ch == '+' || ch == '.') {
227+
if !(unicode_ident::is_xid_continue(ch) || ch == '-' || ch == '+' || ch == '.') {
228228
return Err(ErrorKind::InvalidCharacter {
229229
ch,
230230
what,

src/bin/cargo/commands/install.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ pub fn exec(gctx: &mut GlobalContext, args: &ArgMatches) -> CliResult {
137137
let package_name = PackageName::new(crate_name);
138138
if !crate_name.contains("@") && package_name.is_err() {
139139
for (idx, ch) in crate_name.char_indices() {
140-
if !(unicode_xid::UnicodeXID::is_xid_continue(ch) || ch == '-') {
140+
if !(unicode_ident::is_xid_continue(ch) || ch == '-') {
141141
let mut suggested_crate_name = crate_name.to_string();
142142
suggested_crate_name.insert_str(idx, "@");
143143
if let Ok((_, Some(_))) = parse_crate(&suggested_crate_name.as_str()) {

src/cargo/ops/cargo_add/crate_spec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ impl CrateSpec {
3131
let package_name = PackageName::new(name);
3232
if !pkg_id.contains("@") && package_name.is_err() {
3333
for (idx, ch) in pkg_id.char_indices() {
34-
if !(unicode_xid::UnicodeXID::is_xid_continue(ch) || ch == '-') {
34+
if !(unicode_ident::is_xid_continue(ch) || ch == '-') {
3535
let mut suggested_pkg_id = pkg_id.to_string();
3636
suggested_pkg_id.insert_str(idx, "@");
3737
if let Ok(_) = CrateSpec::resolve(&suggested_pkg_id.as_str()) {

0 commit comments

Comments
 (0)