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

Cargo should warn when creating a new project with a hyphen #380

Closed
arpd opened this issue Aug 15, 2014 · 5 comments
Closed

Cargo should warn when creating a new project with a hyphen #380

arpd opened this issue Aug 15, 2014 · 5 comments

Comments

@arpd
Copy link

arpd commented Aug 15, 2014

Cargo doesn't warn about hyphenated crate names, although it means that you'll need to:
extern crate foo = "foo-bar"
Rather than:
extern crate foo-bar

Following along with the guide this threw me for a minute.

@steveklabnik
Copy link
Member

👍

Does the guide still have a hyphen in it somewhere, or did you just typo?

@alexcrichton
Copy link
Member

Rustc has explicit support for allowing crate names with hyphens, and I personally believe they're more aesthetically appealing than underscores. I also personally wouldn't want cargo to warn about something which is valid rust syntax.

I'm curious, but what led you to expect extern crate foo-bar to work?

@arpd
Copy link
Author

arpd commented Aug 16, 2014

The guide didn't have a hyphen in it, but nor did it mention that you'd have to use different syntax for hyphenated names.
Alex, I too prefer using them, hence my finding this. I wasn't aware that it was explicit support crate names with hyphens, it looked like support for crate names with identifiers that break standard rust identifier rules.

In this case, I think you're definitely correct, perhaps instead this should be mentioned in the guide.

@steveklabnik
Copy link
Member

I also personally wouldn't want cargo to warn about something which is valid rust syntax.

We already have warnings for things that are considered bad style, but are valid syntax.

@alexcrichton
Copy link
Member

The current plan of record is to actually encourage packages with hyphens in them. They are often more aesthetically appealing and are sometimes more natural to type as well. This is likely a trend that will develop over time with the cargo ecosystem (especially when a registry appears).

For now I'm going to close this as I don't think we'd like to do this at this time, but we can certainly revisit this if it looks like it's becoming a more official trend!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants