-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Description
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
.