Why allow hyphens in crate names?
For me it's crate names. When I find a cool new crate foo_bar, I go to my Cargo.lock and write it there. (It's more convenient for me than cargo add).
And then my rust-analyzer fails to load the workspace - turns out the crate is actually called foo-bar so I must change it.
If hyphens turn into underscores in the code anyway, why even name the crate with hyphens, the extra step doesn't add any benefit.
I think I would do this:
- When referring to a crate in
Cargo.tomlwith underscores, they always translate into hyphens automatically (as a minimum) - When displaying names of crates, always use underscores even if in
Cargo.tomlit uses hyphens - in Edition 2027, disallow naming crates with hyphens