-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Enforce crate naming rules of rustc #2708
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
I would say that it should warn before creation that it's not according to rules and offer the following options:
|
Can I try a fix for this? I've just started learning rust/cargo and this feels like a good first fix. There are several validations for crate name at function check_name in cargo_new.rs. Will adding a warning (similar to the existing ones) about the casing be a good fix? The existing validations don't prompt for a new name. Want to be consistent with the existing behavior. |
So long as its only a warning, I feel that is the most we should do. My main concern about a warning is making sure we get the language right to give people a heads up without coming across to strong (since they can just |
Rather than warning or not warning you could just be informative. Something like this name doesn't match the naming rules standard X, please see documentation blah blah blah blah. |
How is that different from a warning? |
A warning is a value judgment. |
Warns about not using snake case format when creating new packages with `cargo new` command.
If this change looks good, I can start a PR: Using the language mentioned in RFC 430. I've not added the link to API naming guidelines since it still stays The fix reuses the method that checks for snake_case when building. |
Theres details to work out in a PR but that is the general direction of what I'd expect. |
Warn about crate name's format when creating new crate ### What does this PR try to resolve? Warns about a crate's name during creation (`crate new ...`) if it doesn't follow the preferred snake_case format. Fixes #2708 The warning message uses the language mentioned in [RFC 430](https://github.com/rust-lang/rfcs/blob/master/text/0430-finalizing-naming-conventions.md#general-naming-conventions). ### How should we test and review this PR? Verified existing tests succeeded with updates. Added new tests to verify fix. ### Additional information The link to [API naming guidelines](https://rust-lang.github.io/api-guidelines/naming.html) was not used since it still stays `unclear` for naming convention for crates.
Actual behavior
Creating a new crate:
cargo new --bin 'UPPERcase_name'
No issue.
Compiling it:
Expected behavior
Cargo should only create crates with names that raise
rustc
warnings if forced.Meta
The text was updated successfully, but these errors were encountered: