add a warning when compiling a user crate named core
#7760
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.
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 standardcore
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 forstd
, 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 thecore
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 cratecore
" and silencing the warning.Possible alternative 2: warn on explicitly depending on
core
fromCargo.toml
.The text was updated successfully, but these errors were encountered: