Closed
Description
AIUI currently the standard is for crate names to be hyphenated, but the module name (not sure on the correct terminology) must be underscored.
For example you add bit-vec
to the Cargo.toml
, but extern crate bit_vec;
to src/lib.rs
.
cargo new rust-foo && cd rust-foo
cargo add bit_vec
sed -i '1s/^/extern crate bit-vec;\n/' src/lib.rs
cat src/lib.rs
cargo build
sed -i 's/bit-vec/bit_vec/' src/lib.rs
cargo build
So instead of this error, it would be great if the compiler could suggest extern crate bit_vec;
.
cargo build ~/tmp/rust-foo (!✦)
Compiling foo v0.1.0 (file:///Users/gib/tmp/rust-foo)
error: expected one of `;` or `as`, found `-`
--> src/lib.rs:1:17
|
1 | extern crate bit-vec;
| ^ expected one of `;` or `as` here
error: aborting due to previous error
error: Could not compile `foo`.
To learn more, run the command again with --verbose.
Came from a discussion with @nrc on twitter: https://twitter.com/gibfahn/status/966755092383739904
I couldn't find an existing issue for this, sorry if it's a duplicate.