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

add a warning when compiling a user crate named core #7760

Open
tanriol opened this issue Jan 1, 2020 · 0 comments
Open

add a warning when compiling a user crate named core #7760

tanriol opened this issue Jan 1, 2020 · 0 comments
Labels
A-diagnostics Area: Error and warning messages generated by Cargo itself. C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.

Comments

@tanriol
Copy link

tanriol commented Jan 1, 2020

Problem: I've seen several times in Gitter/Matrix channels that people had weird errors because they had a dependency on their own crate named core that shadowed the default and caused import errors in proc macros that generated code assuming the standard core crate.

This is a mistake that's easy to make for a newcomer (core is an obvious choice for a base crate others depend on, and, unlike for std, it's not obvious that Rust uses this crate name for its own purposes) and causes strange-looking errors ("it cannot find something that's not even mentioned in its docs? how could it get that broken?").

Suggested solution: add a warning when compiling a crate named core telling the user that the core crate name is used internally by Rust and one shall not use it for their own crates unless they're making an alternate standard library.

Possible alternative: make this a deny-by-default lint in rustc instead to actually provide the user with a way of saying "yes, I really meant to call this crate core" and silencing the warning.

Possible alternative 2: warn on explicitly depending on core from Cargo.toml.

@tanriol tanriol added the C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` label Jan 1, 2020
@ehuss ehuss added the A-diagnostics Area: Error and warning messages generated by Cargo itself. label Feb 2, 2020
@epage epage added the S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted. label Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Error and warning messages generated by Cargo itself. C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.
Projects
None yet
Development

No branches or pull requests

3 participants