Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update non-ASCII crate name warning message #11017

Merged
merged 1 commit into from
Aug 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/cargo/ops/cargo_new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,7 @@ fn check_name(
if restricted_names::is_non_ascii_name(name) {
shell.warn(format!(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am wondering if this should be a warning or an error. To me, it seems like it should be an error but one of the cargo team members may have a different idea.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Such a package rename still works. I feel like changing it to hard error is a bit rush at this moment.

[dependencies]
hello = { path = "./你好", package = "你好" }

"the name `{}` contains non-ASCII characters\n\
Support for non-ASCII crate names is experimental and only valid \
on the nightly toolchain.",
Non-ASCII crate names are not supported by Rust.",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should say cargo not Rust since it is emitted by cargo

Suggested change
Non-ASCII crate names are not supported by Rust.",
Non-ASCII crate names are not supported by cargo.",

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had also considered that but currently Cargo does support non-ASCII crates without much issue. Its just rustc that doesn't. For example, this works fine with cargo check:

[dependencies]
"ああああ" = { path = "../ああああ" }

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure whether it's too much, but I might put something like "it will become a hard error in a future release" if we are trying to scare away folks using non-ASCII crate name 😆.

Either way, they will evenutually figure out it won't work when using as an extern crate (dependency).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally, I wouldn't mind if Cargo still supported it so that you could make binaries with non-ASCII names, regardless of how well everything else on the system handles it :D

name
))?;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ fn non_ascii_name() {
.with_stderr(
"\
[WARNING] the name `Привет` contains non-ASCII characters
Support for non-ASCII crate names is experimental and only valid on the nightly toolchain.
Non-ASCII crate names are not supported by Rust.
[CREATED] binary (application) `Привет` package
",
)
Expand Down