Maybe pre-RFC: improving "-"/"_" in cargo/crates.io

it seems that there is a general agreement that this is a good idea and that it is not possible to do without changing Cargo.

through there are still some open questions, mainly how far to go with treating “-”/"_" as the same character:

  • for crates.io dependencies (yes, that’s what this thread is about :wink: )
  • for “git” dependencies? (probably)
  • for “path” dependencies? (probably)
  • for all dependencies??
    • while I think it is a good idea to also do so for git and path dependencies to prevent any surprises I’m not sure if standarizing it for all possible crate sources is a good idea, e.g. this might lead to problems if cargo at some point supports some not language specific crate source, through then this could be changed if it ever comes to this hypothetical scenario

Also if it treats “-”/"_" the same for package dependencies, maybe it should do so also for other dependencies:

  • cargo features?
    • i.e. “some-feature” == “some_feature”?
    • this would not only needs changes wrt. cargo but also rustc
  • some fields in Cargo.toml?
    • e.g. badges, allowing both travis-ci and travis_ci
  • all cargo fields?
    • probably not, especially wrt. to custom metadata fields this could cause trouble

Also like @ExpHP mentioned crates.io treats crate names case insensitive, which could also be adapted.

  • But given that rust crates shouldn’t ever contain any capital letters this is maybe something where we might want to keep it the current way (and it’s probably also the reason why crates.io converts the names to lower case)

EDIT: for clarification with for “git” / “path” I mean for crate names specified through “git”/“path”, not the whole url/path as this hardly makes sense :wink:

1 Like